public LispFunction(LispList parameters, LispElement body, LispEnvironment funcEnv, LispSymbol funcName) { this.parameters = parameters; this.body = body; this.funcName = funcName; this.funcEnv = (LispEnvironment)funcEnv.Clone(); }
public dynamic Eval(LispEnvironment env, dynamic e = null) { dynamic[] args = (dynamic[])e.Elems; if (args.Any()) { var par = (from p in args.Skip(1) select p.Eval(env)); object[] methParams = unmarshal(par); Type[] paramTypes = (from mParam in methParams select mParam.GetType()).ToArray(); // MethodInfo meth = objType.GetMethod(par.First().ToString(), BindingFlags.Default, Type.DefaultBinder, paramTypes, null); MethodInfo meth = objType.GetMethod(args[0].ToString(), paramTypes); Type resultType = meth.ReturnType; return(marshal(meth.Invoke(obj, methParams), resultType)); } else { return(this); } }
public dynamic Eval(Stream stream, LispEnvironment global) { global.Parent = builtInFunctions; var expressions = parser.parse(stream); dynamic result = null; foreach (LispElement expression in expressions) { result = expression.Eval(global); } global.Parent = null; return(result); }
public dynamic Eval(LispEnvironment env, dynamic e = null) { var val = e.Enumerator; LispEnvironment childEnv = new LispEnvironment(funcEnv); // we need support for recursion if (funcName != null) { childEnv.Add(funcName, this); } foreach (var parameter in parameters.Elems) { val.MoveNext(); childEnv.Add(parameter, val.Current.Eval(env)); } return(body.Eval(null, childEnv)); }
public dynamic Eval(LispEnvironment env, dynamic e = null) { return(this); }
public dynamic Eval(LispEnvironment env, dynamic e = null) { return(env.Lookup(this)); }
internal LispEnvironment(LispEnvironment parent) { Parent = parent; }
public LispFunction(LispList parameters, LispElement body, LispEnvironment funcEnv) : this(parameters, body, funcEnv, null) { }
public dynamic Eval(LispEnvironment env, dynamic e = null) { dynamic elem = First; return(elem.Eval(env).Eval(env, Rest)); }
public LispMacro(LispList parameters, LispElement body, LispEnvironment funcEnv) { throw new NotImplementedException(); }
public dynamic Eval(LispEnvironment env, dynamic e = null) { throw new NotImplementedException(); }
public dynamic Eval(LispEnvironment env, dynamic args = null) { return(func(args, env)); }