Allow multiple actions per frame
- You can now call several actions from one frame by grouping them between
curly braces. i.e. :
POSS G 3 { A_Pain; A_Log("Ow! That hurt!"); }
I will probably add an `if (something) { blah; blah; } else { wah; wah; }`
construct later, but that's the extent of the munging I plan for DECORATE. The
real work goes to the scripting language, not here. But if this branch is
getting merged to master sooner than later, here's an immediate benefit
from it right now.
This commit is contained in:
parent
9044ac9503
commit
7d0faa5bd5
5 changed files with 198 additions and 47 deletions
|
|
@ -3004,6 +3004,28 @@ ExpEmit FxActionSpecialCall::Emit(VMFunctionBuilder *build)
|
|||
return dest;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
ExpEmit FxTailable::Emit(VMFunctionBuilder *build)
|
||||
{
|
||||
return Emit(build, false);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
VMFunction *FxTailable::GetDirectFunction()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FxVMFunctionCall
|
||||
|
|
@ -3011,7 +3033,7 @@ ExpEmit FxActionSpecialCall::Emit(VMFunctionBuilder *build)
|
|||
//==========================================================================
|
||||
|
||||
FxVMFunctionCall::FxVMFunctionCall(PFunction *func, FArgumentList *args, const FScriptPosition &pos)
|
||||
: FxExpression(pos)
|
||||
: FxTailable(pos)
|
||||
{
|
||||
Function = func;
|
||||
ArgList = args;
|
||||
|
|
@ -3082,15 +3104,10 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build)
|
||||
{
|
||||
return Emit(build, false);
|
||||
}
|
||||
|
||||
ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build, bool tailcall)
|
||||
{
|
||||
assert(build->Registers[REGT_POINTER].GetMostUsed() >= 3);
|
||||
int count = ArgList->Size();
|
||||
int count = GetArgCount();
|
||||
|
||||
// Emit code to pass implied parameters
|
||||
if (Function->Flags & VARF_Method)
|
||||
|
|
@ -3105,9 +3122,12 @@ ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build, bool tailcall)
|
|||
count += 2;
|
||||
}
|
||||
// Emit code to pass explicit parameters
|
||||
for (unsigned i = 0; i < ArgList->Size(); ++i)
|
||||
if (ArgList != NULL)
|
||||
{
|
||||
(*ArgList)[i]->Emit(build);
|
||||
for (unsigned i = 0; i < ArgList->Size(); ++i)
|
||||
{
|
||||
(*ArgList)[i]->Emit(build);
|
||||
}
|
||||
}
|
||||
// Get a constant register for this function
|
||||
int funcaddr = build->GetConstantAddress(Function->Variants[0].Implementation, ATAG_OBJECT);
|
||||
|
|
@ -3132,6 +3152,24 @@ ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build, bool tailcall)
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FxVMFunctionCall :: GetDirectFunction
|
||||
//
|
||||
// If the function is not passed any explicit arguments, returns the
|
||||
// function. Otherwise returns NULL.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
VMFunction *FxVMFunctionCall::GetDirectFunction()
|
||||
{
|
||||
if (GetArgCount() == 0)
|
||||
{
|
||||
return GetVMFunction();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
@ -3221,6 +3259,58 @@ ExpEmit FxGlobalFunctionCall::Emit(VMFunctionBuilder *build)
|
|||
return v;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FxSequence :: Resolve
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FxExpression *FxSequence::Resolve(FCompileContext &ctx)
|
||||
{
|
||||
CHECKRESOLVED();
|
||||
for (unsigned i = 0; i < Expressions.Size(); ++i)
|
||||
{
|
||||
if (NULL == (Expressions[i] = static_cast<FxTailable *>(Expressions[i]->Resolve(ctx))))
|
||||
{
|
||||
delete this;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FxSequence :: Emit
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
ExpEmit FxSequence::Emit(VMFunctionBuilder *build, bool tailcall)
|
||||
{
|
||||
for (unsigned i = 0; i < Expressions.Size(); ++i)
|
||||
{
|
||||
ExpEmit v = Expressions[i]->Emit(build, tailcall ? i == Expressions.Size()-1 : false);
|
||||
// Throw away any result. We don't care about it.
|
||||
v.Free(build);
|
||||
}
|
||||
return ExpEmit();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FxSequence :: GetDirectFunction
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
VMFunction *FxSequence::GetDirectFunction()
|
||||
{
|
||||
if (Expressions.Size() == 1)
|
||||
{
|
||||
return Expressions[0]->GetDirectFunction();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue