Esempio n. 1
0
 protected override void DoEvaluate(EvaluationContext context)
 {
     Test.Evaluate(context);
       if (context.Runtime.IsTrue(context.CurrentResult)) {
     if (IfTrue != null)    IfTrue.Evaluate(context);
       } else {
     if (IfFalse != null)   IfFalse.Evaluate(context);
       }
 }
Esempio n. 2
0
 public void Evaluate(EvaluationContext context)
 {
     context.PushFrame(MethodName, Node, ParentFrame);
       try {
     BindingInfo.Evaluate(context);
       } finally {
     context.PopFrame();
       }//finally
 }
Esempio n. 3
0
 protected override void DoEvaluate(EvaluationContext context)
 {
     foreach (CondClauseNode clause in Clauses) {
     clause.Test.Evaluate(context);
     if (context.Runtime.IsTrue(context.CurrentResult)) {
       clause.Expressions.Evaluate(context);
       return;
     }
       }//foreach
       if (ElseClause != null)
     ElseClause.Evaluate(context);
 }
Esempio n. 4
0
 protected override void DoEvaluate(EvaluationContext context)
 {
     try {
     Left.Evaluate(context);
     object arg1 = context.CurrentResult;
     Right.Evaluate(context);
     context.Arg2 = context.CurrentResult;
     context.Arg1 = arg1;
     _dispatcher.Evaluate(context);
       } catch (RuntimeException e) {
     e.Location = this.Location;
     throw;
       }
 }
Esempio n. 5
0
 protected void EvaluateReadParent(EvaluationContext context)
 {
     try {
     context.CurrentResult = context.CurrentFrame.Parent.Locals[Slot.Index];
       } catch (RuntimeException rex) {
     rex.Location = this.Location;
     throw;
       }
 }
Esempio n. 6
0
 protected void EvaluateDoNothing(EvaluationContext context)
 {
 }
Esempio n. 7
0
 protected void EvaluateRead(EvaluationContext context)
 {
     try {
     context.CurrentResult = context.CurrentFrame.GetValue(Slot);
       } catch (RuntimeException rex) {
     rex.Location = this.Location;
     throw;
       }
 }
Esempio n. 8
0
        private void EvaluateArgs(EvaluationContext context, FunctionBindingInfo targetInfo)
        {
            object[] values = context.CreateCallArgs(this.Arguments.Count);
              //Just for perfomance, we implement two cases separately
              if (targetInfo.IsSet(FunctionFlags.HasParamArray)) {
            //with params array
            for (int i = 0; i < targetInfo.ParamCount-1; i++)  {
              Arguments[i].Evaluate(context);
              values[i] = context.CurrentResult;
            }
            //Now combine all remaining arguments into one array and put it into the last element
            int startIndex = targetInfo.ParamCount - 1;
            int arrayLen = Arguments.Count - startIndex;
            object[] arrayArgs = new object[arrayLen];
            for (int i = 0; i < arrayLen; i++) {
              Arguments[startIndex + i].Evaluate(context);
              arrayArgs[i] = context.CurrentResult;
            }
            values[startIndex] = arrayArgs;

              } else {
            //No params array
            for (int i = 0; i < Arguments.Count; i++)  {
              Arguments[i].Evaluate(context);
              values[i] = context.CurrentResult;
            }
              }

              context.CallArgs = values;
        }
Esempio n. 9
0
        protected void InvokeDynamic(EvaluationContext context)
        {
            NameRef.Evaluate(context);
              Closure target;
              try {
            target = (Closure)context.CurrentResult;
            if (target.MethodName == null)
              target.MethodName = NameRef.Name;
              } catch (InvalidCastException castExc) {
            throw new sones.Lib.Frameworks.CLIrony.Runtime.RuntimeException("Method [" + NameRef.Name + "] not found or method reference is not set.", castExc, NameRef.Location);
              } catch (NullReferenceException) {
            throw new sones.Lib.Frameworks.CLIrony.Runtime.RuntimeException("Method reference is not set in variable " + NameRef.Name, null, NameRef.Location);
              }

              EvaluateArgs(context, target.BindingInfo);
              if (_isTail) {
            context.Tail = target;
            return;
              }
              //execute non-tail call
              target.Evaluate(context);
              if (context.Tail == null) return;
              //check returning tail
              while (context.Tail != null) {
            Closure tail = context.Tail;
            context.Tail = null;
            tail.Evaluate(context);
              }
              context.CallArgs = null;
        }
Esempio n. 10
0
 protected void EvaluateOnDefine(EvaluationContext context)
 {
     context.CurrentResult = new Closure(context.CurrentFrame, this, BindingInfo); // Body.Evaluate);
 }
Esempio n. 11
0
 private void EvaluateOther(EvaluationContext context)
 {
     Arg.Evaluate(context);
       context.Arg1 = context.CurrentResult;
       _dispatcher.Evaluate(context);
 }
Esempio n. 12
0
 private void ListImpl(EvaluationContext context)
 {
     object[] data = (object[])context.CallArgs[0];
       Pair p = null;
       foreach (object v in data) {
     p = new Pair(v, p);
       }
       context.CurrentResult = p;
 }
Esempio n. 13
0
 protected override void DoEvaluate(EvaluationContext context)
 {
     Expressions.Evaluate(context);
 }
Esempio n. 14
0
 private void DisplayImpl(EvaluationContext context)
 {
     object[] data = (object[])context.CallArgs[0];
       foreach (object v in data) {
     if (v == null) continue;
     OnConsoleWrite(v.ToString());
       }
       context.CurrentResult = null;
 }
Esempio n. 15
0
 private Pair GetPair(EvaluationContext context)
 {
     Pair result = context.CallArgs[0] as Pair;
       Check(result != null, "Invalid argument type - expected a pair");
       return result;
 }
Esempio n. 16
0
 private void ConsImpl(EvaluationContext context)
 {
     context.CurrentResult = new Pair(context.CallArgs[0], context.CallArgs[1]);
 }
Esempio n. 17
0
 private void CdrImpl(EvaluationContext context)
 {
     context.CurrentResult = GetPair(context).Cdr;
 }
Esempio n. 18
0
 private void EvaluatePlus(EvaluationContext context)
 {
     Arg.Evaluate(context);
 }
Esempio n. 19
0
 protected void EvaluateWrite(EvaluationContext context)
 {
     context.CurrentFrame.SetValue(Slot, context.CurrentResult);
 }
Esempio n. 20
0
 private void NullQImpl(EvaluationContext context)
 {
     context.CurrentResult = (BoolToSchemeObject(context.CallArgs[0] == NullObject));
 }
Esempio n. 21
0
 protected void EvaluateWriteParent(EvaluationContext context)
 {
     context.CurrentFrame.Parent.Locals[Slot.Index] = context.CurrentResult;
 }
Esempio n. 22
0
 protected void InvokeFixed(EvaluationContext context)
 {
     EvaluateArgs(context, FixedTargetInfo);
       FixedTargetInfo.Evaluate(context);
       //check returning tail
       if (context.Tail == null) return;
       while (context.Tail != null) {
     Closure tail = context.Tail;
     context.Tail = null;
     tail.Evaluate(context);
       }
       context.CallArgs = null;
 }
Esempio n. 23
0
 private void NewLineImpl(EvaluationContext context)
 {
     OnConsoleWrite(Environment.NewLine);
 }
Esempio n. 24
0
 protected override void DoEvaluate(EvaluationContext context)
 {
     Expression.Evaluate(context);
       Identifier.Evaluate(context); //writes the value into the slot
 }