WIP unpacking of parameters.

This commit is contained in:
gnembon committed 2021-04-21 12:21:47 -03:00
1 parent 72a3d74a97
commit a65d16c9ba
11 files changed
+106 -30

No files matched your search

+10 -6
View File
@@ -773,12 +773,16 @@ public class Expression
stack.set(stack.size() - 1, stack.peek() - 2 + 1);
break;
case FUNCTION:
ILazyFunction f = functions.get(token.surface);// don't validate global - userdef functions
int numParams = stack.pop();
if (f != null && !f.numParamsVaries() && numParams != f.getNumParams())
{
throw new ExpressionException(c, this, token, "Function " + token + " expected " + f.getNumParams() + " parameters, got " + numParams);
}
//ILazyFunction f = functions.get(token.surface);// don't validate global - userdef functions
//int numParams = stack.pop();
//if (f != null && !f.numParamsVaries() && numParams != f.getNumParams())
//{
// throw new ExpressionException(c, this, token, "Function " + token + " expected " + f.getNumParams() + " parameters, got " + numParams);
//}
stack.pop();
// due to unpacking, all functions can have variable number of arguments
// we will be checking that at runtime.
// TODO try analyze arguments and assess if its possible that they are static
if (stack.size() <= 0)
{
throw new ExpressionException(c, this, token, "Too many function calls, maximum scope exceeded");