public static eeObject newFunctionObject( string fnName, Dictionary <string, eeObject> defaultArgs, EelooParser.LinesContext codeblock ) { // Create function obj eeFunction newFnObject = new eeFunction(fnName, codeblock, defaultArgs); // Create eeObject return(new eeObject(newFnObject) { type = eeObjectType.FUNCTION, }); }
public eeFunction( string name, EelooParser.LinesContext codeblock, Dictionary <string, eeObject> defaultArgs ) { this.name = name; this.codeblock = codeblock; this.scope = new Scope(null, codeblock); // Assign each argument to a variable in the scope foreach (var arg in defaultArgs) { scope.assignVar( arg.Key, // argument name arg.Value ); argNames.Add(arg.Key); } }
public override eeObject VisitLines([NotNull] EelooParser.LinesContext ctx) { var stmtArr = ctx.stmt(); foreach (var stmt in stmtArr) { var val = Visit(stmt); /* val might be equal to eeObject.None, because expressions like * function calls and that will return eeObjects and not null. However, stmts * will return null instead. We can't pass down eeObject.None as a return value * so we'll have to treat it like a null and skip it. */ if (val == null || val == eeObject.None) { continue; } return(val); } return(null); }