public EFunctionOperation(EWord name, ETypeWord type, ETypeNameKey[] arguments, EOperation[] operations) { this.name = name; this.type = type; this.arguments = arguments; program = new EProgram(operations); }
public ECustomFunction(EWord name, ETypeWord type, EProgram program, ETypeNameKey[] arguments) { this.name = name; this.type = type; this.arguments = arguments; this.program = program; }
public EVariable Convert(ETypeWord to) { EVariable tryConvert = ConvertInternal(to); if (tryConvert != null) { return(tryConvert); } if (GetEType().Get() == to.Get()) { return(this); } return(CannotConvert(to)); }
protected override EVariable ConvertInternal(ETypeWord to) { switch (to.Get()) { case EType.Double: return(((EVDouble)New(to)).Set(value)); case EType.Int: return(((EVInt)New(to)).Set(value)); case EType.Boolean: return(((EVBoolean)New(to)).Set(value != 0)); } return(null); }
public override EVariable Exec(EScope scope, ESolvable[] args) { // TODO: output type casting if (args.Length != arguments.Length) { throw new ELangException("Wrong amount of args for function " + name); } EScope lowerScope = scope.GetChild(); for (int i = 0; i < arguments.Length; i++) { string argname = arguments[i].GetVariable().ToString(); ETypeWord argtype = arguments[i].GetEType(); EVariable solved = EVariable.New(argtype).Assign(args[i].Solve(lowerScope)); lowerScope.Set(argname, solved); } return(Interpreter.Run(program, lowerScope)); }
protected EVariable CannotConvert(ETypeWord type) { throw new ELangException("Cannot convert " + type + " to " + GetEType()); }
protected virtual EVariable ConvertInternal(ETypeWord to) { return(null); }
public static EVariable New(ETypeWord type) { return(New(type.Get())); }
public ECustomFunction(EWord name, ETypeWord type, EProgram program) : this(name, type, program, new ETypeNameKey[] { }) { }
public ECreateOperation(EWord[] variables, ETypeWord type, ESolvable assign) : this(variables, type) { assignOperations = variables.Select(variable => new EAssignOperation(variable, assign)).ToArray(); }
public ECreateOperation(EWord[] variables, ETypeWord type) { this.variables = variables; this.type = type; }
public EGlobalFunction(EWord name, ETypeWord type, Func <EScope, ESolvable[], EVariable> func) { this.name = name; this.type = type; this.func = func; }
public ETypeNameKey(EWord name, ETypeWord type) { variable = name; this.type = type; }