tscript change

Adds the ability to declare defaults for function arguments

eg
function testFunc(%x = 1, %y = 1)
{
    return %x + %y;
}

can now be called as
testFunc(10) and it will return the value of 11.
This commit is contained in:
marauder2k7 2025-11-15 17:34:33 +00:00
parent 7e64493dbf
commit b0f8a5f9bd
8 changed files with 1375 additions and 1206 deletions

View file

@ -311,8 +311,13 @@ struct VarNode : ExprNode
StringTableEntry varName;
ExprNode* arrayIndex;
ExprNode* defaultValue; // optional expression
static VarNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* arrayIndex);
// function params initialization.
static VarNode* allocParam(S32 lineNumber, StringTableEntry varName, ExprNode* defaultValue);
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
ExprNodeName getExprNodeNameEnum() const override { return NameVarNode; }