1
0

Allow empty OUT arguments

This commit is contained in:
otya128
2016-12-22 20:10:21 +09:00
parent c7813f38b7
commit 2d0d7e0cfc
3 changed files with 34 additions and 9 deletions

View File

@@ -2161,3 +2161,11 @@ class SetX : Code
vm.petitcomputer.xoff(func); vm.petitcomputer.xoff(func);
} }
} }
class Pop : Code
{
override void execute(VM vm)
{
vm.decSP();
}
}

View File

@@ -697,8 +697,13 @@ class Compiler
genCode(new PopVarExpression(sc)); genCode(new PopVarExpression(sc));
} }
break; break;
default: case NodeType.VoidExpression:
throw new SyntaxError(); {
genCode(new Pop());
}
break;
default:
throw new SyntaxError();
} }
} }

View File

@@ -970,18 +970,30 @@ class Parser
while(true) while(true)
{ {
token = lex.front(); token = lex.front();
Expression arg = expression(); if (token.type == TokenType.Comma)
if(!isLValue(arg))
{ {
//to support func args... OUT (no argument) func.addOut(new VoidExpression(lex.location));
if (!func.outVariable.length) }
else
{
Expression arg = expression();
if (!arg)
{ {
func.addOut(new VoidExpression(lex.location));
break; break;
} }
syntaxError(); if(!isLValue(arg))
return null; {
//to support func args... OUT (no argument)
if (!func.outVariable.length)
{
break;
}
syntaxError();
return null;
}
func.addOut(arg);
} }
func.addOut(arg);
token = lex.front(); token = lex.front();
if(token.type == TokenType.Comma) if(token.type == TokenType.Comma)
{ {