- implemented local vector variables. Currently only the definition plus initial assignment works.
- removed all vector4 handling that had already been added, now that this type can no longer be defined.
This commit is contained in:
parent
f2f365bfef
commit
9400f97189
8 changed files with 278 additions and 44 deletions
|
|
@ -52,7 +52,6 @@ static const char *BuiltInTypeNames[] =
|
|||
"string",
|
||||
"vector2",
|
||||
"vector3",
|
||||
"vector4",
|
||||
"name",
|
||||
"color",
|
||||
"state",
|
||||
|
|
@ -622,6 +621,16 @@ static void PrintExprTrinary(FLispString &out, ZCC_TreeNode *node)
|
|||
out.Close();
|
||||
}
|
||||
|
||||
static void PrintVectorInitializer(FLispString &out, ZCC_TreeNode *node)
|
||||
{
|
||||
ZCC_VectorInitializer *enode = (ZCC_VectorInitializer *)node;
|
||||
OpenExprType(out, enode->Operation);
|
||||
PrintNodes(out, enode->X);
|
||||
PrintNodes(out, enode->Y);
|
||||
PrintNodes(out, enode->Z);
|
||||
out.Close();
|
||||
}
|
||||
|
||||
static void PrintFuncParam(FLispString &out, ZCC_TreeNode *node)
|
||||
{
|
||||
ZCC_FuncParm *pnode = (ZCC_FuncParm *)node;
|
||||
|
|
@ -889,7 +898,8 @@ void (* const TreeNodePrinter[NUM_AST_NODE_TYPES])(FLispString &, ZCC_TreeNode *
|
|||
PrintFuncDeclarator,
|
||||
PrintDefault,
|
||||
PrintFlagStmt,
|
||||
PrintPropertyStmt
|
||||
PrintPropertyStmt,
|
||||
PrintVectorInitializer,
|
||||
};
|
||||
|
||||
FString ZCC_PrintAST(ZCC_TreeNode *root)
|
||||
|
|
|
|||
|
|
@ -945,6 +945,7 @@ func_param_flags(X) ::= func_param_flags(A) OPTIONAL(T). { X.Int = A.Int | ZCC_O
|
|||
|
||||
%type expr{ZCC_Expression *}
|
||||
%type primary{ZCC_Expression *}
|
||||
%type vectorinit{ZCC_VectorInitializer*}
|
||||
%type unary_expr{ZCC_Expression *}
|
||||
%type constant{ZCC_ExprConstant *}
|
||||
|
||||
|
|
@ -966,29 +967,7 @@ primary(X) ::= SUPER(T).
|
|||
X = expr;
|
||||
}
|
||||
primary(X) ::= constant(A). { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
primary(XX) ::= LPAREN expr(A) COMMA expr(B) COMMA expr(C) RPAREN.
|
||||
{
|
||||
NEW_AST_NODE(VectorInitializer, expr, A);
|
||||
expr->Operation = PEX_Vector;
|
||||
expr->Type = TypeVector3;
|
||||
expr->X = A;
|
||||
expr->Y = B;
|
||||
expr->Z = C;
|
||||
XX = expr;
|
||||
}
|
||||
|
||||
|
||||
primary(XX) ::= LPAREN expr(A) COMMA expr(B) RPAREN.
|
||||
{
|
||||
NEW_AST_NODE(VectorInitializer, expr, A);
|
||||
expr->Operation = PEX_Vector;
|
||||
expr->Type = TypeVector2;
|
||||
expr->X = A;
|
||||
expr->Y = B;
|
||||
expr->Z = nullptr;
|
||||
XX = expr;
|
||||
}
|
||||
primary(X) ::= vectorinit(A). { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
primary(X) ::= LPAREN expr(A) RPAREN.
|
||||
{
|
||||
|
|
@ -1039,6 +1018,30 @@ primary(X) ::= SCOPE primary(B).
|
|||
X = expr2;
|
||||
}
|
||||
*/
|
||||
|
||||
vectorinit(XX) ::= LPAREN expr(A) COMMA expr(B) COMMA expr(C) RPAREN. [DOT]
|
||||
{
|
||||
NEW_AST_NODE(VectorInitializer, expr, A);
|
||||
expr->Operation = PEX_Vector;
|
||||
expr->Type = TypeVector3;
|
||||
expr->X = A;
|
||||
expr->Y = B;
|
||||
expr->Z = C;
|
||||
XX = expr;
|
||||
}
|
||||
|
||||
|
||||
vectorinit(XX) ::= LPAREN expr(A) COMMA expr(B) RPAREN. [DOT]
|
||||
{
|
||||
NEW_AST_NODE(VectorInitializer, expr, A);
|
||||
expr->Operation = PEX_Vector;
|
||||
expr->Type = TypeVector2;
|
||||
expr->X = A;
|
||||
expr->Y = B;
|
||||
expr->Z = nullptr;
|
||||
XX = expr;
|
||||
}
|
||||
|
||||
/*----- Unary Expressions -----*/
|
||||
|
||||
unary_expr(X) ::= primary(X).
|
||||
|
|
|
|||
|
|
@ -1387,11 +1387,6 @@ PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_TreeNode *field, FName n
|
|||
retval = TypeVector3;
|
||||
break;
|
||||
|
||||
case ZCC_Vector4:
|
||||
// This has almost no use, so we really shouldn't bother.
|
||||
Error(field, "vector<4> not implemented for %s", name.GetChars());
|
||||
return TypeError;
|
||||
|
||||
case ZCC_State:
|
||||
retval = TypeState;
|
||||
break;
|
||||
|
|
@ -2710,6 +2705,15 @@ FxExpression *ZCCCompiler::ConvertNode(ZCC_TreeNode *ast)
|
|||
return new FxConditional(condition, left, right);
|
||||
}
|
||||
|
||||
case AST_VectorInitializer:
|
||||
{
|
||||
auto vecini = static_cast<ZCC_VectorInitializer *>(ast);
|
||||
auto xx = ConvertNode(vecini->X);
|
||||
auto yy = ConvertNode(vecini->Y);
|
||||
auto zz = ConvertNode(vecini->Z);
|
||||
return new FxVectorInitializer(xx, yy, zz, *ast);
|
||||
}
|
||||
|
||||
case AST_LocalVarStmt:
|
||||
{
|
||||
auto loc = static_cast<ZCC_LocalVarStmt *>(ast);
|
||||
|
|
|
|||
|
|
@ -301,7 +301,8 @@ static void DoParse(int lumpnum)
|
|||
|
||||
parser = ZCCParseAlloc(malloc);
|
||||
ZCCParseState state;
|
||||
#if 0 // this costs a lot of time and should only be activated when it's really needed.
|
||||
//#define TRACE
|
||||
#ifdef TRACE // this costs a lot of time and should only be activated when it's really needed.
|
||||
FILE *f = fopen("trace.txt", "w");
|
||||
char prompt = '\0';
|
||||
ZCCParseTrace(f, &prompt);
|
||||
|
|
@ -335,7 +336,7 @@ static void DoParse(int lumpnum)
|
|||
I_Error("%d errors while parsing %s", FScriptPosition::ErrorCounter, Wads.GetLumpFullPath(lumpnum).GetChars());
|
||||
}
|
||||
|
||||
#if 0
|
||||
#ifdef TRACE
|
||||
if (f != NULL)
|
||||
{
|
||||
fclose(f);
|
||||
|
|
|
|||
|
|
@ -120,7 +120,6 @@ enum EZCCBuiltinType
|
|||
ZCC_String,
|
||||
ZCC_Vector2,
|
||||
ZCC_Vector3,
|
||||
ZCC_Vector4,
|
||||
ZCC_Name,
|
||||
|
||||
ZCC_Color, // special types for ZDoom.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue