- named class functions are working. Yay!!

- converted A_BspiAttack and A_BabyMetal to script functions to test the implementation.
This commit is contained in:
Christoph Oelckers 2016-10-23 14:26:33 +02:00
parent 46c7f1151f
commit 5b952b116a
6 changed files with 33 additions and 33 deletions

View File

@ -835,7 +835,6 @@ set( NOT_COMPILED_SOURCE_FILES
${OTHER_SYSTEM_SOURCES} ${OTHER_SYSTEM_SOURCES}
sc_man_scanner.h sc_man_scanner.h
sc_man_scanner.re sc_man_scanner.re
g_doom/a_arachnotron.cpp
g_doom/a_archvile.cpp g_doom/a_archvile.cpp
g_doom/a_bossbrain.cpp g_doom/a_bossbrain.cpp
g_doom/a_bruiser.cpp g_doom/a_bruiser.cpp

View File

@ -1,30 +0,0 @@
/*
#include "actor.h"
#include "s_sound.h"
#include "p_local.h"
#include "p_enemy.h"
#include "a_action.h"
#include "vm.h"
*/
DEFINE_ACTION_FUNCTION(AActor, A_BspiAttack)
{
PARAM_SELF_PROLOGUE(AActor);
if (!self->target)
return 0;
A_FaceTarget (self);
// launch a missile
P_SpawnMissile (self, self->target, PClass::FindActor("ArachnotronPlasma"));
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, A_BabyMetal)
{
PARAM_SELF_PROLOGUE(AActor);
S_Sound (self, CHAN_BODY, "baby/walk", 1, ATTN_IDLE);
A_Chase (stack, self);
return 0;
}

View File

@ -22,7 +22,6 @@
#include "vm.h" #include "vm.h"
// Include all the other Doom stuff here to reduce compile time // Include all the other Doom stuff here to reduce compile time
#include "a_arachnotron.cpp"
#include "a_archvile.cpp" #include "a_archvile.cpp"
#include "a_bossbrain.cpp" #include "a_bossbrain.cpp"
#include "a_bruiser.cpp" #include "a_bruiser.cpp"

View File

@ -693,7 +693,7 @@ void FFunctionBuildList::Build()
FCompileContext ctx(item.Func, item.Func->SymbolName == NAME_None ? nullptr : item.Func->Variants[0].Proto, item.FromDecorate); FCompileContext ctx(item.Func, item.Func->SymbolName == NAME_None ? nullptr : item.Func->Variants[0].Proto, item.FromDecorate);
// Allocate registers for the function's arguments and create local variable nodes before starting to resolve it. // Allocate registers for the function's arguments and create local variable nodes before starting to resolve it.
VMFunctionBuilder buildit(true); VMFunctionBuilder buildit(!!(item.Func->Variants[0].Flags & VARF_Action));
for(unsigned i=0;i<item.Func->Variants[0].Proto->ArgumentTypes.Size();i++) for(unsigned i=0;i<item.Func->Variants[0].Proto->ArgumentTypes.Size();i++)
{ {
auto type = item.Func->Variants[0].Proto->ArgumentTypes[i]; auto type = item.Func->Variants[0].Proto->ArgumentTypes[i];

View File

@ -2042,6 +2042,15 @@ void ZCCCompiler::InitFunctions()
sym->AddVariant(NewPrototype(rets, args), argflags, argnames, afd == nullptr? nullptr : *(afd->VMPointer), varflags); sym->AddVariant(NewPrototype(rets, args), argflags, argnames, afd == nullptr? nullptr : *(afd->VMPointer), varflags);
c->Type()->Symbols.ReplaceSymbol(sym); c->Type()->Symbols.ReplaceSymbol(sym);
if (!(f->Flags & ZCC_Native))
{
auto code = ConvertAST(f->Body);
if (code != nullptr)
{
sym->Variants[0].Implementation = FunctionBuildList.AddFunction(sym, code, FStringf("%s.%s", c->Type()->TypeName.GetChars(), FName(f->Name).GetChars()), false);
}
}
// todo: Check inheritance. // todo: Check inheritance.
// todo: Process function bodies. // todo: Process function bodies.
} }

View File

@ -88,4 +88,27 @@ class ArachnotronPlasma : Actor
} }
} }
//===========================================================================
//
// Code (must be attached to Actor)
//
//===========================================================================
extend class Actor
{
void A_BspiAttack()
{
if (target)
{
A_FaceTarget();
P_SpawnMissile(target, "ArachnotronPlasma");
}
}
void A_BabyMetal()
{
A_PlaySound("baby/walk", CHAN_BODY, 1, false, ATTN_IDLE);
A_Chase();
}
}