public string ToPrintableString() { switch (this.type) { case eeObjectType.LIST: return(this.value == null ? "[]" // Empty list : $"[{string.Join(", ", (from elem in this.AsList() select elem.ToPrintableString()))}]"); case eeObjectType.STRING: return(this.AsString()); case eeObjectType.NUMBER: return(this.AsNumber().ToString()); case eeObjectType.BOOL: return(this.AsBool() ? "true" : "false"); case eeObjectType.FUNCTION: eeFunction func = this.AsFunction(); return($"<function object {func.name}; {func.getArgNames()}>"); case eeObjectType.internal_NONE_OBJ: return("<none>"); default: throw new Exception("default case for ToPrintableString"); } }
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 ArgumentMismatchError(eeFunction func, long thisCount, long argCount) : base("ArgumentMismatchError", $"Function \'{func.name}\' takes {thisCount} argument{(thisCount != 1 ? "s" : "")} but was given {argCount} argument{(argCount != 1 ? "s" : "")}") { }