Exemplo 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);
       }
 }
Exemplo n.º 2
0
 public void Evaluate(EvaluationContext context)
 {
     context.PushFrame(MethodName, Node, ParentFrame);
       try {
     BindingInfo.Evaluate(context);
       } finally {
     context.PopFrame();
       }//finally
 }
Exemplo 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);
 }
Exemplo 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;
       }
 }
Exemplo 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;
       }
 }
Exemplo n.º 6
0
 protected void EvaluateDoNothing(EvaluationContext context)
 {
 }
Exemplo n.º 7
0
 protected void EvaluateRead(EvaluationContext context)
 {
     try {
     context.CurrentResult = context.CurrentFrame.GetValue(Slot);
       } catch (RuntimeException rex) {
     rex.Location = this.Location;
     throw;
       }
 }
Exemplo 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;
        }
Exemplo 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;
        }
Exemplo n.º 10
0
 protected void EvaluateOnDefine(EvaluationContext context)
 {
     context.CurrentResult = new Closure(context.CurrentFrame, this, BindingInfo); // Body.Evaluate);
 }
Exemplo n.º 11
0
 private void EvaluateOther(EvaluationContext context)
 {
     Arg.Evaluate(context);
       context.Arg1 = context.CurrentResult;
       _dispatcher.Evaluate(context);
 }
Exemplo 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;
 }
Exemplo n.º 13
0
 protected override void DoEvaluate(EvaluationContext context)
 {
     Expressions.Evaluate(context);
 }
Exemplo 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;
 }
Exemplo 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;
 }
Exemplo n.º 16
0
 private void ConsImpl(EvaluationContext context)
 {
     context.CurrentResult = new Pair(context.CallArgs[0], context.CallArgs[1]);
 }
Exemplo n.º 17
0
 private void CdrImpl(EvaluationContext context)
 {
     context.CurrentResult = GetPair(context).Cdr;
 }
Exemplo n.º 18
0
 private void EvaluatePlus(EvaluationContext context)
 {
     Arg.Evaluate(context);
 }
Exemplo n.º 19
0
 protected void EvaluateWrite(EvaluationContext context)
 {
     context.CurrentFrame.SetValue(Slot, context.CurrentResult);
 }
Exemplo n.º 20
0
 private void NullQImpl(EvaluationContext context)
 {
     context.CurrentResult = (BoolToSchemeObject(context.CallArgs[0] == NullObject));
 }
Exemplo n.º 21
0
 protected void EvaluateWriteParent(EvaluationContext context)
 {
     context.CurrentFrame.Parent.Locals[Slot.Index] = context.CurrentResult;
 }
Exemplo 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;
 }
Exemplo n.º 23
0
 private void NewLineImpl(EvaluationContext context)
 {
     OnConsoleWrite(Environment.NewLine);
 }
Exemplo n.º 24
0
 protected override void DoEvaluate(EvaluationContext context)
 {
     Expression.Evaluate(context);
       Identifier.Evaluate(context); //writes the value into the slot
 }