예제 #1
0
 public LispFunction(LispList parameters, LispElement body, LispEnvironment funcEnv, LispSymbol funcName)
 {
     this.parameters = parameters;
     this.body       = body;
     this.funcName   = funcName;
     this.funcEnv    = (LispEnvironment)funcEnv.Clone();
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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));
        }
예제 #5
0
 public dynamic Eval(LispEnvironment env, dynamic e = null)
 {
     return(this);
 }
예제 #6
0
 public dynamic Eval(LispEnvironment env, dynamic e = null)
 {
     return(env.Lookup(this));
 }
예제 #7
0
 internal LispEnvironment(LispEnvironment parent)
 {
     Parent = parent;
 }
예제 #8
0
 public LispFunction(LispList parameters, LispElement body, LispEnvironment funcEnv)
     : this(parameters, body, funcEnv, null)
 {
 }
예제 #9
0
        public dynamic Eval(LispEnvironment env, dynamic e = null)
        {
            dynamic elem = First;

            return(elem.Eval(env).Eval(env, Rest));
        }
예제 #10
0
 public LispMacro(LispList parameters, LispElement body, LispEnvironment funcEnv)
 {
     throw new NotImplementedException();
 }
예제 #11
0
 public dynamic Eval(LispEnvironment env, dynamic e = null)
 {
     throw new NotImplementedException();
 }
 public dynamic Eval(LispEnvironment env, dynamic args = null)
 {
     return(func(args, env));
 }