mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- extended the grammar so that the DECORATE function declaration list can almost be used as-is, with the sole exception of requiring any action function to declare a return type, even if it is void.
This adds: * builtin types color, state and sound. * ending a parameter list with an ellipsis to declare a varargs list. (A_Jump uses this.) * allowing to declare optional arguments by giving them a default value. * adding an 'action' qualifier for function declarations.
This commit is contained in:
parent
acec2e5b07
commit
6989b81688
5 changed files with 59 additions and 1 deletions
|
@ -54,7 +54,12 @@ static const char *BuiltInTypeNames[] =
|
|||
"vector3",
|
||||
"vector4",
|
||||
"name",
|
||||
"usertype"
|
||||
"color",
|
||||
"state",
|
||||
"sound",
|
||||
|
||||
"usertype",
|
||||
|
||||
};
|
||||
|
||||
class FLispString
|
||||
|
@ -767,6 +772,7 @@ static void PrintFuncParamDecl(FLispString &out, ZCC_TreeNode *node)
|
|||
PrintNodes(out, dnode->Type);
|
||||
out.AddName(dnode->Name);
|
||||
out.AddHex(dnode->Flags);
|
||||
PrintNodes(out, dnode->Default);
|
||||
out.Close();
|
||||
}
|
||||
|
||||
|
|
|
@ -188,6 +188,7 @@ class_ancestry(X) ::= COLON dottable_id(A). { X = A; /*X-overwrites-A*/ }
|
|||
class_flags(X) ::= . { X.Flags = 0; X.Replaces = NULL; }
|
||||
class_flags(X) ::= class_flags(A) ABSTRACT. { X.Flags = A.Flags | ZCC_Abstract; X.Replaces = A.Replaces; }
|
||||
class_flags(X) ::= class_flags(A) NATIVE. { X.Flags = A.Flags | ZCC_Native; X.Replaces = A.Replaces; }
|
||||
class_flags(X) ::= class_flags(A) ACTION. { X.Flags = A.Flags | ZCC_Action; X.Replaces = A.Replaces; }
|
||||
class_flags(X) ::= class_flags(A) REPLACES dottable_id(B). { X.Flags = A.Flags; X.Replaces = B; }
|
||||
|
||||
/*----- Dottable Identifier -----*/
|
||||
|
@ -585,6 +586,9 @@ type_name1(X) ::= DOUBLE(T). { X.Int = ZCC_Float64; X.SourceLoc = T.SourceLoc
|
|||
type_name1(X) ::= STRING(T). { X.Int = ZCC_String; X.SourceLoc = T.SourceLoc; }
|
||||
type_name1(X) ::= VECTOR(T) vector_size(A). { X.Int = A.Int; X.SourceLoc = T.SourceLoc; }
|
||||
type_name1(X) ::= NAME(T). { X.Int = ZCC_Name; X.SourceLoc = T.SourceLoc; }
|
||||
type_name1(X) ::= SOUND(T). { X.Int = ZCC_Sound; X.SourceLoc = T.SourceLoc; }
|
||||
type_name1(X) ::= STATE(T). { X.Int = ZCC_State; X.SourceLoc = T.SourceLoc; }
|
||||
type_name1(X) ::= COLOR(T). { X.Int = ZCC_Color; X.SourceLoc = T.SourceLoc; }
|
||||
|
||||
type_name(X) ::= type_name1(A).
|
||||
{
|
||||
|
@ -841,6 +845,17 @@ func_params(X) ::= . /* empty */ { X = NULL; }
|
|||
func_params(X) ::= VOID. { X = NULL; }
|
||||
func_params(X) ::= func_param_list(X).
|
||||
|
||||
func_params(X) ::= func_param_list(A) COMMA ELLIPSIS.
|
||||
{
|
||||
NEW_AST_NODE(FuncParamDecl,parm,stat->sc->GetMessageLine());
|
||||
parm->Type = nullptr;
|
||||
parm->Name = NAME_None;
|
||||
parm->Flags = 0;
|
||||
parm->Default = nullptr;
|
||||
X = A; /*X-overwrites-A*/
|
||||
X->AppendSibling(parm);
|
||||
}
|
||||
|
||||
func_param_list(X) ::= func_param(X).
|
||||
func_param_list(X) ::= func_param_list(A) COMMA func_param(B). { X = A; /*X-overwrites-A*/ X->AppendSibling(B); }
|
||||
|
||||
|
@ -850,6 +865,17 @@ func_param(X) ::= func_param_flags(A) type(B) IDENTIFIER(C).
|
|||
parm->Type = B;
|
||||
parm->Name = C.Name();
|
||||
parm->Flags = A.Int;
|
||||
parm->Default = nullptr;
|
||||
X = parm;
|
||||
}
|
||||
|
||||
func_param(X) ::= func_param_flags(A) type(B) IDENTIFIER(C) EQ expr(D).
|
||||
{
|
||||
NEW_AST_NODE(FuncParamDecl,parm,A.SourceLoc ? A.SourceLoc : B->SourceLoc);
|
||||
parm->Type = B;
|
||||
parm->Name = C.Name();
|
||||
parm->Flags = A.Int;
|
||||
parm->Default = D;
|
||||
X = parm;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ static void InitTokenMap()
|
|||
TOKENDEF (TK_LtGtEq, ZCC_LTGTEQ);
|
||||
TOKENDEF (TK_Is, ZCC_IS);
|
||||
TOKENDEF (TK_DotDot, ZCC_DOTDOT);
|
||||
TOKENDEF (TK_Ellipsis, ZCC_ELLIPSIS);
|
||||
TOKENDEF ('|', ZCC_OR);
|
||||
TOKENDEF ('^', ZCC_XOR);
|
||||
TOKENDEF ('&', ZCC_AND);
|
||||
|
@ -112,6 +113,7 @@ static void InitTokenMap()
|
|||
TOKENDEF (TK_Class, ZCC_CLASS);
|
||||
TOKENDEF (TK_Abstract, ZCC_ABSTRACT);
|
||||
TOKENDEF (TK_Native, ZCC_NATIVE);
|
||||
TOKENDEF (TK_Action, ZCC_ACTION);
|
||||
TOKENDEF (TK_Replaces, ZCC_REPLACES);
|
||||
TOKENDEF (TK_Static, ZCC_STATIC);
|
||||
TOKENDEF (TK_Private, ZCC_PRIVATE);
|
||||
|
@ -172,6 +174,9 @@ static void InitTokenMap()
|
|||
TOKENDEF (TK_Loop, ZCC_LOOP);
|
||||
TOKENDEF (TK_Goto, ZCC_GOTO);
|
||||
TOKENDEF (TK_States, ZCC_STATES);
|
||||
TOKENDEF (TK_State, ZCC_STATE);
|
||||
TOKENDEF (TK_Color, ZCC_COLOR);
|
||||
TOKENDEF (TK_Sound, ZCC_SOUND);
|
||||
|
||||
TOKENDEF (TK_Identifier, ZCC_IDENTIFIER);
|
||||
TOKENDEF (TK_StringConst, ZCC_STRCONST);
|
||||
|
|
|
@ -119,6 +119,11 @@ enum EZCCBuiltinType
|
|||
ZCC_Vector3,
|
||||
ZCC_Vector4,
|
||||
ZCC_Name,
|
||||
|
||||
ZCC_Color, // special types for ZDoom.
|
||||
ZCC_State,
|
||||
ZCC_Sound,
|
||||
|
||||
ZCC_UserType,
|
||||
|
||||
ZCC_NUM_BUILT_IN_TYPES
|
||||
|
@ -437,6 +442,7 @@ struct ZCC_LocalVarStmt : ZCC_Statement
|
|||
struct ZCC_FuncParamDecl : ZCC_TreeNode
|
||||
{
|
||||
ZCC_Type *Type;
|
||||
ZCC_Expression *Default;
|
||||
ENamedName Name;
|
||||
int Flags;
|
||||
};
|
||||
|
|
|
@ -804,3 +804,18 @@ enum ERenderStyle
|
|||
STYLE_AddStencil,
|
||||
STYLE_AddShaded,
|
||||
};
|
||||
|
||||
// Type definition for the implicit 'callingstate' parameter that gets passed to action functions.
|
||||
enum EStateType
|
||||
{
|
||||
STATE_Actor,
|
||||
STATE_Psprite,
|
||||
STATE_StateChain,
|
||||
}
|
||||
|
||||
struct FStateParamInfo
|
||||
{
|
||||
state mCallingState;
|
||||
EStateType mStateType;
|
||||
int mPSPIndex;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue