entity load handler and rework of handling of events.

This commit is contained in:
gnembon committed 2020-10-30 22:59:27 -03:00
1 parent 51f34643db
commit 7ccd46433a
15 files changed
+413 -299

No files matched your search

@@ -21,9 +21,34 @@ public class FunctionArgument extends Argument
this.function = function;
this.args = args;
}
public static FunctionArgument findIn(Context c, Module module, List<LazyValue> params, int offset, boolean prematureEvaluation, boolean allowNone)
/**
* @param c context
* @param module module
* @param params list of lazy params
* @param offset offset where to start looking for functional argument
* @param prematureEvaluation evaluates eagerly arguments in current context before returning
* @param allowNone none indicates no function present, otherwise it will croak
* @param checkArgs whether the caller expects trailing parameters to fully resolve function argument list
* if not - argument count check will not be performed and its up to the caller to verify
* if the number of supplied arguments is right
* @return argument data
*/
public static FunctionArgument findIn(
Context c,
Module module,
List<LazyValue> params,
int offset,
boolean prematureEvaluation,
boolean allowNone,
boolean checkArgs)
{
Value functionValue = params.get(offset).evalValue(c);
if (functionValue.isNull())
{
if (allowNone) return new FunctionArgument(null, offset+1, null);
throw new InternalExpressionException("function argument cannot be null");
}
if (!(functionValue instanceof FunctionValue))
{
String name = functionValue.getString();
@@ -31,11 +56,14 @@ public class FunctionArgument extends Argument
}
FunctionValue fun = (FunctionValue)functionValue;
int argsize = fun.getArguments().size();
int extraargs = params.size() - argsize - offset - 1;
if (extraargs < 0)
throw new InternalExpressionException("Function "+fun.getPrettyString()+" requires at least "+fun.getArguments().size()+" arguments");
if (extraargs > 0 && fun.getVarArgs()==null)
throw new InternalExpressionException("Function "+fun.getPrettyString()+" requires "+fun.getArguments().size()+" arguments");
if (checkArgs)
{
int extraargs = params.size() - argsize - offset - 1;
if (extraargs < 0)
throw new InternalExpressionException("Function " + fun.getPrettyString() + " requires at least " + fun.getArguments().size() + " arguments");
if (extraargs > 0 && fun.getVarArgs() == null)
throw new InternalExpressionException("Function " + fun.getPrettyString() + " requires " + fun.getArguments().size() + " arguments");
}
List<LazyValue> lvargs = new ArrayList<>();
if (prematureEvaluation)
{