Пример #1
0
 internal static dynamic PropertyNameAndExpression(BaseInterpreterStack stack)
 {
     dynamic result = new ExpandoObject();
     result.PropertyName = stack.Pop<WARPObject>().AsString();
     result.Expression = stack.Pop<WARPObject>();
     return result;
 }
Пример #2
0
 internal override void Execute(InterpreterState state, SourceCode code, BaseInterpreterStack stack)
 {
     dynamic result = PropertyNameAndExpression(stack);
     if (result.PropertyName == Constants.KeyWords.Pop)
         Environment(state).Push(result.Expression);
     else
         Environment(state)[result.PropertyName] = result.Expression;
 }
Пример #3
0
 public void PreStackObjectAccess(BaseInterpreterStack stack, int objectsRequested)
 {
     if (stack.Size < objectsRequested)
         Enumerable.Repeat(new CanonicalNumber(), objectsRequested - stack.Size).ToList().ForEach(obj => stack.Push(obj));
 }
Пример #4
0
 internal override void Execute(InterpreterState state, SourceCode code, BaseInterpreterStack stack)
 {
     var obj = stack.Pop<WARPObject>();
     PropertyBasedExecutionEnvironment env = Environment(state);
     if (!env.HasScratchPadEntry(Constants.KeyWords.Comparison)) {
         stack.Push(obj);
         PropertyBasedExecutionEnvironment.ScratchPad[Constants.KeyWords.Comparison] = String.Empty;
     }
     else {
         var lhs = stack.Pop<WARPObject>();
         PropertyBasedExecutionEnvironment.ScratchPad.Remove(Constants.KeyWords.Comparison);
         var bothNumeric = lhs.IsNumeric && obj.IsNumeric;
         Func<int> cmp = () => {
             var f = lhs.AsNumeric(); var s = obj.AsNumeric();
             return (f < s ? -1 : (f > s ? 1 : 0));
         };
         stack.Push(new WARPObject(bothNumeric ? cmp() : string.Compare(lhs.AsString(), obj.AsString())));
     }
 }
Пример #5
0
 internal abstract void Execute(InterpreterState state, SourceCode code, BaseInterpreterStack stack);
Пример #6
0
 internal override void Execute(InterpreterState state, SourceCode code, BaseInterpreterStack stack)
 {
     var val = ((WARPObject)Environment(state)[stack.Pop<WARPObject>().AsString()]).AsString();
     state.AddExecutionEnvironment<PropertyBasedExecutionEnvironment>();
     val.Reverse().ToList().ForEach(c => Environment(state).Push(new WARPObject(new string(new[] { c }))));
 }
Пример #7
0
 internal override void Execute(InterpreterState state, SourceCode code, BaseInterpreterStack stack)
 {
     var obj = stack.Pop();
     stack.Pop();
     stack.Push(obj);
 }
Пример #8
0
 internal override void Execute(InterpreterState state, SourceCode code, BaseInterpreterStack stack)
 {
     RandomAccessStack<WARPObject> st = PropertyBasedExecutionEnvironment.ScratchPad[Constants.RASName] as RandomAccessStack<WARPObject>;
     st.Set((int)stack.Pop<WARPObject>().AsNumeric());
     Action(st, stack);
 }
Пример #9
0
 internal override void Execute(InterpreterState state, SourceCode source, BaseInterpreterStack stack)
 {
     dynamic result = PropertyNameAndExpression(stack);
     bool inPopMode = result.PropertyName == Constants.KeyWords.Pop;
     var pbee = Environment(state);
     Int64 cur = inPopMode ? stack.Pop<WARPObject>().AsNumeric() : pbee[result.PropertyName].As<WARPObject>().AsNumeric();
     var obj = new WARPObject(FlexibleNumeralSystem.Encode(Command(cur, result.Expression), WARPObject.CurrentRadix));
     if (result.PropertyName == Constants.KeyWords.Pop)
         pbee.Push(obj);
     else
         pbee[result.PropertyName] = obj;
 }
Пример #10
0
 internal override void Execute(InterpreterState state, SourceCode source, BaseInterpreterStack stack)
 {
     PropertyBasedExecutionEnvironment.ScratchPad[stack.Pop<WARPObject>().AsString()] = source.SourcePosition.Copy();
 }
Пример #11
0
 internal override void Execute(InterpreterState state, SourceCode source, BaseInterpreterStack stack)
 {
     dynamic result = PropertyNameAndExpression(stack);
     PropertyBasedExecutionEnvironment env = Environment(state);
     var val = (WARPObjectFactory.Instance.KnowsAbout(result.PropertyName) ?
                 WARPObjectFactory.Instance.Fabricate(state, result.PropertyName) : ((WARPObject)env[result.PropertyName])).AsNumeric(0L);
     if (val > 0) {
         if (!env.HasScratchPadEntry(result.Expression.AsString()))
             FindAllLabels(state);
         ExecutionSupport.Assert(env.HasScratchPadEntry(result.Expression.AsString()), string.Concat("Unknown label: ", result.Expression.AsString()));
         source.SourcePosition = ((MutableTuple<int>)PropertyBasedExecutionEnvironment.ScratchPad[result.Expression.AsString()]).Copy();
     }
 }
Пример #12
0
 internal override void Execute(InterpreterState state, SourceCode code, BaseInterpreterStack stack)
 {
     var style = stack.Pop<WARPObject>().AsString();
     ExecutionSupport.Assert(Options.Contains(style), string.Concat("Invalid argument for ',' - ", style));
     stack.Push(style == "l" ? new WARPObject(InteractionWrapper.ReadString("0").Result) : new WARPObject(Convert.ToChar(InteractionWrapper.ReadCharacter().Result)));
 }
Пример #13
0
 internal override void Execute(InterpreterState state, SourceCode code, BaseInterpreterStack stack)
 {
     var lhs = stack.Pop<WARPObject>().AsNumeric();
     var rhs = stack.Pop<WARPObject>().AsNumeric();
     dynamic res = CommandBuilder.KeyAndBuilder(state);
     CMD cmd = Gather(state, res.Key, res.Builder);
     ExecutionSupport.Emit(() => string.Concat("Comparison: ", lhs, " == ", rhs, "?"));
     if (lhs == rhs)
         cmd.Apply(state);
 }