Exemplo n.º 1
0
 public SpokeObject Run()
 {
     SpokeObject dm = new SpokeObject(new SpokeObject[9], "");
     var gm = new SpokeObject[9];
     gm[0] = dm;
     return Mainctor(gm);
 }
Exemplo n.º 2
0
        public void Run(SpokeConstruct so)
        {
            var         fm = Methods[so.MethodIndex];
            SpokeObject dm = new SpokeObject()
            {
                Type = ObjectType.Object
            };

            dm.Variables = new SpokeObject[so.NumOfVars];
            for (int index = 0; index < so.NumOfVars; index++)
            {
                dm.SetVariable(index, new SpokeObject());
            }
#if stacktrace
            try {
#endif
            evaluateMethod(fm, new SpokeObject[1] {
                dm
            });
#if stacktrace
        }
        catch (Exception er) {
            dfss.AppendLine(er.ToString());
            File.WriteAllText("C:\\ded.txt", dfss.ToString());
            throw er;
        }
#endif



            // evaluate(fm, dm, new List<SpokeObject>() { dm });
        }
Exemplo n.º 3
0
        public SpokeObject(SpokeObject[] inde, string className)
        {
            Array.Resize(ref inde, 20);

            Variables = inde;
            Type = ObjectType.Object;
            ClassName = className; ID = ids++;
        }
Exemplo n.º 4
0
        public SpokeObject Run()
        {
            SpokeObject dm = new SpokeObject(new SpokeObject[9]);
            var         gm = new SpokeObject[9];

            gm[0] = dm;
            return(Mainctor(gm));
        }
Exemplo n.º 5
0
        public RunExpressions(Func<SpokeObject[], SpokeObject>[] internalMethods, SpokeMethod[] mets)
        {
            Methods = mets;
            InternalMethods = internalMethods;
            ints=new SpokeObject[100];
            for (int i = 0; i < 100; i++) {
                ints[i] = new SpokeObject(ObjectType.Int) {IntVal = i};

            }
        }
Exemplo n.º 6
0
        public SpokeObject GetVariable(int name, bool forSet)
        {
            SpokeObject g = Variables[name];

            if (g == null || forSet)
            {
                return(Variables[name] = new SpokeObject());
            }
            return(g);
        }
Exemplo n.º 7
0
 public void loadUp(Func <SpokeObject[], SpokeObject>[] internalMethods, SpokeMethod[] mets)
 {
     Methods         = mets;
     InternalMethods = internalMethods;
     ints            = new SpokeObject[100];
     for (int i = 0; i < 100; i++)
     {
         ints[i] = new SpokeObject(i);
     }
 }
Exemplo n.º 8
0
 public void loadUp(Func<SpokeObject[], SpokeObject>[] internalMethods, SpokeMethod[] mets)
 {
     Methods = mets;
     InternalMethods = internalMethods;
     ints = new SpokeObject[100];
     for (int i = 0; i < 100; i++)
     {
         ints[i] = new SpokeObject(i);
     }
 }
Exemplo n.º 9
0
        private SpokeObject Mainctor(SpokeObject[] variables)
        {
            SpokeObject[] specVariables = new SpokeObject[0]; SpokeObject[] sps;
            SpokeObject   bm2;
            SpokeObject   bm;
            SpokeObject   lastStack;
            var           b = new SpokeObject(new List <SpokeObject>(20));

            variables[0].Variables[0] = b.AddArray(ints[0]);
            var c = new SpokeObject(new List <SpokeObject>(20));

            variables[0].Variables[1] = c.AddArray(ints[0]);
            var d = new SpokeObject(new List <SpokeObject>(20));

            variables[0].Variables[2] = d.AddArray(ints[0]);
            Methods[1].MethodFunc(new SpokeObject[] { variables[0].Variables[0] });
            Methods[1].MethodFunc(new SpokeObject[] { variables[0].Variables[1] });
            Methods[1].MethodFunc(new SpokeObject[] { variables[0].Variables[2] });
            variables[1] = intCache(ints[10].IntVal);
            InternalMethods[9](new SpokeObject[] { variables[0], new SpokeObject("Start") });
            variables[2] = intCache(ints[1].IntVal);
            variables[3] = intCache(variables[1].IntVal);
            var e = new SpokeObject(new List <SpokeObject>(20));

            variables[4] = e;
_topOfWhile_160:
            if (!(((variables[2].IntVal <= variables[3].IntVal) ? TRUE : FALSE)).BoolVal)
            {
                goto EndLoop160;
            }
            Methods[0].MethodFunc(new SpokeObject[] { variables[4], variables[2] });
            variables[2] = intCache(intCache(variables[2].IntVal + ints[1].IntVal).IntVal);
            goto _topOfWhile_160;
EndLoop160:
            variables[5] = variables[4];
            variables[6] = variables[5];
            variables[7] = intCache(ints[0].IntVal);
_topOfForeach_172:
            if (!(((variables[7].IntVal < Methods[2].MethodFunc(new SpokeObject[] { variables[6] }).IntVal) ? TRUE : FALSE)).BoolVal)
            {
                goto EndLoop172;
            }
            variables[8] = variables[6].ArrayItems[variables[7].IntVal];
            Methods[0].MethodFunc(new SpokeObject[] { variables[0].Variables[0], variables[8] });
            variables[7] = intCache(intCache(variables[7].IntVal + ints[1].IntVal).IntVal);
            goto _topOfForeach_172;
EndLoop172:
            Maindraw(new SpokeObject[] { variables[0], null, null, null, null, null, null, null, null, null, null, null, null, null });
            MaindoHanoi(new SpokeObject[] { variables[0], variables[1], new SpokeObject("1"), new SpokeObject("3"), new SpokeObject("2") });
            InternalMethods[9](new SpokeObject[] { variables[0], new SpokeObject("Done") });

            return(null);
        }
Exemplo n.º 10
0
 public void Run(SpokeConstruct so)
 {
     var fm = Methods[so.MethodIndex];
     //            var fm = _cla.First(a => a.Name == so.ClassName).Methods.First(a => a.MethodName == ".ctor");
     SpokeObject dm = new SpokeObject(ObjectType.Object) ;
     dm.Variables = new SpokeObject[so.NumOfVars];
     for (int index = 0; index < so.NumOfVars; index++){
         dm.SetVariable(index, new SpokeObject(ObjectType.Null));
     }
     evaluate(fm, dm, new SpokeObject[1] { dm });
     // evaluate(fm, dm, new List<SpokeObject>() { dm });
 }
Exemplo n.º 11
0
 public RunInstructions(Func <SpokeObject[], SpokeObject>[] internalMethods, SpokeMethod[] mets)
 {
     Methods         = mets;
     InternalMethods = internalMethods;
     ints            = new SpokeObject[100];
     for (int i = 0; i < 100; i++)
     {
         ints[i] = new SpokeObject(ObjectType.Int)
         {
             IntVal = i
         };
     }
 }
Exemplo n.º 12
0
        private SpokeObject Mainmove(SpokeObject[] variables)
        {
            SpokeObject[] specVariables = new SpokeObject[0]; SpokeObject[] sps;
            SpokeObject   bm2;
            SpokeObject   bm;
            SpokeObject   lastStack;

            InternalMethods[10](new SpokeObject[] { variables[0] });
            InternalMethods[9](new SpokeObject[] { variables[0], new SpokeObject("Move Disk"), variables[1], new SpokeObject("From"), variables[2], new SpokeObject("To"), variables[3] });
            if (!(((variables[2].Compare(new SpokeObject("1")) ? TRUE : FALSE))).BoolVal)
            {
                goto EndIf235;
            }
            Methods[3].MethodFunc(new SpokeObject[] { variables[0].Variables[0], variables[1] });
EndIf235:
            if (!(((variables[2].Compare(new SpokeObject("2")) ? TRUE : FALSE))).BoolVal)
            {
                goto EndIf244;
            }
            Methods[3].MethodFunc(new SpokeObject[] { variables[0].Variables[1], variables[1] });
EndIf244:
            if (!(((variables[2].Compare(new SpokeObject("3")) ? TRUE : FALSE))).BoolVal)
            {
                goto EndIf253;
            }
            Methods[3].MethodFunc(new SpokeObject[] { variables[0].Variables[2], variables[1] });
EndIf253:
            if (!(((variables[3].Compare(new SpokeObject("1")) ? TRUE : FALSE))).BoolVal)
            {
                goto EndIf262;
            }
            Methods[6].MethodFunc(new SpokeObject[] { variables[0].Variables[0], variables[3], variables[1] });
EndIf262:
            if (!(((variables[3].Compare(new SpokeObject("2")) ? TRUE : FALSE))).BoolVal)
            {
                goto EndIf272;
            }
            Methods[6].MethodFunc(new SpokeObject[] { variables[0].Variables[1], variables[3], variables[1] });
EndIf272:
            if (!(((variables[3].Compare(new SpokeObject("3")) ? TRUE : FALSE))).BoolVal)
            {
                goto EndIf282;
            }
            Methods[6].MethodFunc(new SpokeObject[] { variables[0].Variables[2], variables[3], variables[1] });
EndIf282:

            return(null);
        }
Exemplo n.º 13
0
        public RunInstructions(Func<SpokeObject[], SpokeObject>[] internalMethods, SpokeMethod[] mets, string stack, int returnIndex, Dictionary<string, string[]> variableLookup)
        {
            Methods = mets;
            myVariableLookup = variableLookup;
            InternalMethods = internalMethods;
            ints = new SpokeObject[100];
            for (int i = 0; i < 100; i++)
            {
                ints[i] = new SpokeObject(ObjectType.Int) { IntVal = i };
            }

            if (stack.Length != 0)
            {
                deserialize(stack);
                reprintStackTrace[reprintStackIndex - 1].Answer = new SpokeObject(returnIndex);
            }
        }
Exemplo n.º 14
0
        private SpokeObject Mainctor(SpokeObject[] variables)
        {
            SpokeObject[] specVariables = new SpokeObject[0]; SpokeObject[] sps;
            SpokeObject bm2;
            SpokeObject bm;
            SpokeObject lastStack;
            var b = new SpokeObject(new List<SpokeObject>(20));
            variables[0].Variables[0] = b.AddArray(ints[0]);
            var c = new SpokeObject(new List<SpokeObject>(20));
            variables[0].Variables[1] = c.AddArray(ints[0]);
            var d = new SpokeObject(new List<SpokeObject>(20));
            variables[0].Variables[2] = d.AddArray(ints[0]);
            Methods[1].MethodFunc(new SpokeObject[] { variables[0].Variables[0] });
            Methods[1].MethodFunc(new SpokeObject[] { variables[0].Variables[1] });
            Methods[1].MethodFunc(new SpokeObject[] { variables[0].Variables[2] });
            variables[1] = intCache(ints[10].IntVal);
            InternalMethods[9](new SpokeObject[] { variables[0], new SpokeObject("Start") });
            variables[2] = intCache(ints[1].IntVal);
            variables[3] = intCache(variables[1].IntVal);
            var e = new SpokeObject(new List<SpokeObject>(20));
            variables[4] = e;
            _topOfWhile_160:
            if (!(((variables[2].IntVal <= variables[3].IntVal) ? TRUE : FALSE)).BoolVal)
                goto EndLoop160;
            Methods[0].MethodFunc(new SpokeObject[] { variables[4], variables[2] });
            variables[2] = intCache(intCache(variables[2].IntVal + ints[1].IntVal).IntVal);
            goto _topOfWhile_160;
            EndLoop160:
            variables[5] = variables[4];
            variables[6] = variables[5];
            variables[7] = intCache(ints[0].IntVal);
            _topOfForeach_172:
            if (!(((variables[7].IntVal < Methods[2].MethodFunc(new SpokeObject[] { variables[6] }).IntVal) ? TRUE : FALSE)).BoolVal)
                goto EndLoop172;
            variables[8] = variables[6].ArrayItems[variables[7].IntVal];
            Methods[0].MethodFunc(new SpokeObject[] { variables[0].Variables[0], variables[8] });
            variables[7] = intCache(intCache(variables[7].IntVal + ints[1].IntVal).IntVal);
            goto _topOfForeach_172;
            EndLoop172:
            Maindraw(new SpokeObject[] { variables[0], null, null, null, null, null, null, null, null, null, null, null, null, null });
            MaindoHanoi(new SpokeObject[] { variables[0], variables[1], new SpokeObject("1"), new SpokeObject("3"), new SpokeObject("2") });
            InternalMethods[9](new SpokeObject[] { variables[0], new SpokeObject("Done") });

            return null;
        }
Exemplo n.º 15
0
        private SpokeObject evaluate(SpokeMethod fm, SpokeObject parent, SpokeObject[] paras)
        {
            #if Stacktrace
            dfss.AppendLine(fm.MethodName);
            #endif

            SpokeObject[] variables = new SpokeObject[fm.NumOfVars];

            for (int i = 0; i < fm.Parameters.Length; i++)
            {
                variables[i] = paras[i];
            }

            var sm = new SpokeMethodRun();
            sm.RunningClass = parent;

            return evaluateLines(fm.Lines, sm, variables);
        }
Exemplo n.º 16
0
        private SpokeObject MaindoHanoi(SpokeObject[] variables)
        {
            SpokeObject[] specVariables = new SpokeObject[0]; SpokeObject[] sps;
            SpokeObject   bm2;
            SpokeObject   bm;
            SpokeObject   lastStack;

            if (!(((variables[1].IntVal > ints[0].IntVal) ? TRUE : FALSE)).BoolVal)
            {
                goto EndIf192;
            }
            MaindoHanoi(new SpokeObject[] { variables[0], intCache(variables[1].IntVal - ints[1].IntVal), variables[2], variables[4], variables[3] });
            Mainmove(new SpokeObject[] { variables[0], variables[1], variables[2], variables[3], null, null, null });
            Maindraw(new SpokeObject[] { variables[0], null, null, null, null, null, null, null, null, null, null, null, null, null });
            MaindoHanoi(new SpokeObject[] { variables[0], intCache(variables[1].IntVal - ints[1].IntVal), variables[4], variables[3], variables[2] });
EndIf192:

            return(null);
        }
Exemplo n.º 17
0
        internal static bool Compare(SpokeObject left, SpokeObject right)
        {
            if (left == null)
            {
                if (right == null)
                {
                    return true;
                }
                if (right.Type == ObjectType.Null)
                {
                    return true;
                }
            }
            else
            {
                if (left.Type == ObjectType.Null && right == null)
                {
                    return true;
                }
            }
            if (left.Type != right.Type)
            {
                return false;
            }
            switch (left.Type)
            {
                case ObjectType.Null:
                    return true;
                    break;
                case ObjectType.Unset:
                    return true;
                    break;
                case ObjectType.Int:
                    return left.IntVal == right.IntVal;
                    break;
                case ObjectType.Float:
                    return left.FloatVal == right.FloatVal;
                    break;
                case ObjectType.String:
                    return left.StringVal == right.StringVal;
                    break;
                case ObjectType.Bool:
                    return left.BoolVal == right.BoolVal;
                    break;

                case ObjectType.Object:
                    //                    throw new AbandonedMutexException("not yet cowbow");

                    for (int i = 0; i < left.Variables.Length; i++)
                    {
                        if (!Compare(left.Variables[i],right.Variables[i]))
                        {
                            return false;
                        }

                    }
                    return true;
                    break;
                case ObjectType.Array:

                    if (left.ArrayItems.Count != right.ArrayItems.Count) return false;

                    for (int i = 0; i < left.ArrayItems.Count; i++)
                    {
                        if (!Compare(right.ArrayItems[i], left.ArrayItems[i]))
                        {
                            return false;
                        }
                    }
                    return true;
                    break;

                case ObjectType.Method:
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 18
0
 public bool TryGetVariable(int name, out SpokeObject obj)
 {
     return (obj = Variables[name]) != null;
 }
Exemplo n.º 19
0
 public void SetVariable(int name, SpokeObject obj)
 {
     Variables[name] = obj;
 }
Exemplo n.º 20
0
        private SpokeObject Maindraw(SpokeObject[] variables)
        {
            SpokeObject[] specVariables = new SpokeObject[0]; SpokeObject[] sps;
            SpokeObject bm2;
            SpokeObject bm;
            SpokeObject lastStack;
            variables[1] = intCache(ints[2].IntVal);
            variables[2] = new SpokeObject(new SpokeObject(" ").StringVal);
            variables[3] = new SpokeObject(new SpokeObject("0").StringVal);
            variables[4] = intCache(ints[0].IntVal);
            InternalMethods[12](new SpokeObject[] { variables[0], variables[4], ints[1] });
            InternalMethods[0](new SpokeObject[] { variables[0], new SpokeObject("Peg1") });
            variables[5] = variables[0].Variables[0];
            variables[6] = intCache(ints[0].IntVal);
            _topOfForeach_310:
            if (!(((variables[6].IntVal < Methods[2].MethodFunc(new SpokeObject[] { variables[5] }).IntVal) ? TRUE : FALSE)).BoolVal)
                goto EndLoop310;
            variables[7] = variables[5].ArrayItems[variables[6].IntVal];
            InternalMethods[12](new SpokeObject[] { variables[0], variables[4], variables[1] });
            if (!(((variables[7].IntVal < ints[10].IntVal) ? TRUE : FALSE)).BoolVal)
                goto EndIf316;
            EndIf316:
            InternalMethods[0](new SpokeObject[] { variables[0], variables[7] });
            InternalMethods[0](new SpokeObject[] { variables[0], variables[2] });
            variables[1] = intCache(intCache(variables[1].IntVal + ints[1].IntVal).IntVal);
            variables[6] = intCache(intCache(variables[6].IntVal + ints[1].IntVal).IntVal);
            goto _topOfForeach_310;
            EndLoop310:
            variables[1] = intCache(ints[2].IntVal);
            variables[4] = intCache(intCache(variables[4].IntVal + ints[5].IntVal).IntVal);
            InternalMethods[12](new SpokeObject[] { variables[0], variables[4], ints[1] });
            InternalMethods[0](new SpokeObject[] { variables[0], new SpokeObject("Peg2") });
            variables[8] = variables[0].Variables[1];
            variables[9] = intCache(ints[0].IntVal);
            _topOfForeach_356:
            if (!(((variables[9].IntVal < Methods[2].MethodFunc(new SpokeObject[] { variables[8] }).IntVal) ? TRUE : FALSE)).BoolVal)
                goto EndLoop356;
            variables[10] = variables[8].ArrayItems[variables[9].IntVal];
            InternalMethods[12](new SpokeObject[] { variables[0], variables[4], variables[1] });
            if (!(((variables[10].IntVal < ints[10].IntVal) ? TRUE : FALSE)).BoolVal)
                goto EndIf362;
            EndIf362:
            InternalMethods[0](new SpokeObject[] { variables[0], variables[10] });
            InternalMethods[0](new SpokeObject[] { variables[0], variables[2] });
            variables[1] = intCache(intCache(variables[1].IntVal + ints[1].IntVal).IntVal);
            variables[9] = intCache(intCache(variables[9].IntVal + ints[1].IntVal).IntVal);
            goto _topOfForeach_356;
            EndLoop356:
            variables[1] = intCache(ints[2].IntVal);
            variables[4] = intCache(intCache(variables[4].IntVal + ints[5].IntVal).IntVal);
            InternalMethods[12](new SpokeObject[] { variables[0], variables[4], ints[1] });
            InternalMethods[0](new SpokeObject[] { variables[0], new SpokeObject("Peg3") });
            variables[11] = variables[0].Variables[2];
            variables[12] = intCache(ints[0].IntVal);
            _topOfForeach_402:
            if (!(((variables[12].IntVal < Methods[2].MethodFunc(new SpokeObject[] { variables[11] }).IntVal) ? TRUE : FALSE)).BoolVal)
                goto EndLoop402;
            variables[13] = variables[11].ArrayItems[variables[12].IntVal];
            InternalMethods[12](new SpokeObject[] { variables[0], variables[4], variables[1] });
            if (!(((variables[13].IntVal < ints[10].IntVal) ? TRUE : FALSE)).BoolVal)
                goto EndIf408;
            EndIf408:
            InternalMethods[0](new SpokeObject[] { variables[0], variables[13] });
            InternalMethods[0](new SpokeObject[] { variables[0], variables[2] });
            variables[1] = intCache(intCache(variables[1].IntVal + ints[1].IntVal).IntVal);
            variables[12] = intCache(intCache(variables[12].IntVal + ints[1].IntVal).IntVal);
            goto _topOfForeach_402;
            EndLoop402:

            return null;
        }
Exemplo n.º 21
0
 public void AddRangeArray(SpokeObject lastStack)
 {
     ArrayItems.AddRange(lastStack.ArrayItems);
 }
Exemplo n.º 22
0
 public SpokeObject AddArrayRange(SpokeObject lastStack)
 {
     ArrayItems.AddRange(lastStack.ArrayItems);
     return(this);
 }
Exemplo n.º 23
0
 public void SetVariable(int name, SpokeObject obj)
 {
     Variables[name] = obj;
 }
Exemplo n.º 24
0
        public Tuple<SpokeQuestion, string, GameBoard> Run(SpokeConstruct so)
        {
            var fm = Methods[so.MethodIndex];
            SpokeObject dm = new SpokeObject(new SpokeObject[so.NumOfVars], "Main");
            for (int index = 0; index < so.NumOfVars; index++)
            {
                dm.SetVariable(index, new SpokeObject());
            }
            try
            {
                evaluateMethod(fm, new SpokeObject[1] { dm });
            }
            catch (AskQuestionException aq)
            {
                return new Tuple<SpokeQuestion, string, GameBoard>(aq.Question, serialize(), aq.GameBoard);
            }

            #if stacktrace

            catch (Exception er) {
                dfss.AppendLine(er.ToString());
                File.WriteAllText("C:\\ded.txt", dfss.ToString());
                throw er;
            }
            #endif

            return null;

            // evaluate(fm, dm, new List<SpokeObject>() { dm });
        }
Exemplo n.º 25
0
 public StackTracer(SpokeObject[] stack, SpokeObject[] variables)
 {
     StackObjects = stack;
     StackVariables = variables;
 }
Exemplo n.º 26
0
        private SpokeObject evaluateMethod(SpokeMethod fm, SpokeObject[] paras)
        {
            SpokeObject[] variables = new SpokeObject[fm.NumOfVars];

            for (int i = 0; i < fm.Parameters.Length; i++)
            {
                variables[i] = paras[i];
            }

#if stacktrace
            dfss.AppendLine(fm.Class.Name + " : : " + fm.MethodName + " Start");
#endif

            SpokeObject   lastStack;
            int           stackIndex = 0;
            SpokeObject[] stack      = new SpokeObject[3000];


            for (int index = 0; index < fm.Instructions.Length; index++)
            {
                var ins = fm.Instructions[index];
#if stacktrace
                dfss.AppendLine(stackIndex + " ::  " + ins.ToString());
#endif

                SpokeObject[] sps;

                SpokeObject bm;
                switch (ins.Type)
                {
                case SpokeInstructionType.CreateReference:
                    stack[stackIndex++] = new SpokeObject(new SpokeObject[ins.Index]);
                    break;

                case SpokeInstructionType.CreateArray:
                    stack[stackIndex++] = new SpokeObject(new List <SpokeObject>(20));
                    break;

                case SpokeInstructionType.CreateMethod:
                    stack[stackIndex++] = NULL;    //new SpokeObject(ObjectType.Method) { AnonMethod = ins.anonMethod };
                    break;

                case SpokeInstructionType.Label:
                    //   throw new NotImplementedException("");
                    break;

                case SpokeInstructionType.Goto:

                    index = ins.Index;

                    break;

                case SpokeInstructionType.Comment:


                    break;

                case SpokeInstructionType.CallMethod:
                    sps = new SpokeObject[ins.Index3];
                    for (int i = ins.Index3 - 1; i >= 0; i--)
                    {
                        sps[i] = stack[--stackIndex];
                    }
                    stack[stackIndex++] = evaluateMethod(Methods[ins.Index], sps);
                    break;

                case SpokeInstructionType.CallMethodFunc:
                    sps = new SpokeObject[ins.Index3];
                    for (int i = ins.Index3 - 1; i >= 0; i--)
                    {
                        sps[i] = stack[--stackIndex];
                    }

                    stack[stackIndex++] = Methods[ins.Index].MethodFunc(sps);
                    break;

                case SpokeInstructionType.CallInternal:

                    sps = new SpokeObject[ins.Index3];
                    for (int i = ins.Index3 - 1; i >= 0; i--)
                    {
                        sps[i] = stack[--stackIndex];
                    }
                    stack[stackIndex++] = InternalMethods[ins.Index](sps);
                    break;

                case SpokeInstructionType.BreakpointInstruction:
                    Console.WriteLine("BreakPoint");
                    break;

                case SpokeInstructionType.Return:
#if stacktrace
                    dfss.AppendLine(fm.Class.Name + " : : " + fm.MethodName + " End");
#endif
                    return(stack[--stackIndex]);

                    break;

                case SpokeInstructionType.IfTrueContinueElse:

                    if (stack[--stackIndex].BoolVal)
                    {
                        continue;
                    }

                    index = ins.Index;

                    break;

                case SpokeInstructionType.Or:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].BoolVal || stack[stackIndex - 1].BoolVal) ? TRUE : FALSE;
                    stackIndex--;
                    break;

                case SpokeInstructionType.And:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].BoolVal && stack[stackIndex - 1].BoolVal) ? TRUE : FALSE;
                    stackIndex--;
                    break;

                case SpokeInstructionType.StoreLocalInt:
                    lastStack            = stack[--stackIndex];
                    bm                   = variables[ins.Index];
                    variables[ins.Index] = new SpokeObject(ObjectType.Int)
                    {
                        IntVal = lastStack.IntVal
                    };
                    break;

                case SpokeInstructionType.StoreLocalFloat:
                    lastStack            = stack[--stackIndex];
                    bm                   = variables[ins.Index];
                    variables[ins.Index] = new SpokeObject(ObjectType.Float)
                    {
                        FloatVal = lastStack.FloatVal
                    };
                    break;

                case SpokeInstructionType.StoreLocalBool:
                    lastStack            = stack[--stackIndex];
                    bm                   = variables[ins.Index];
                    variables[ins.Index] = lastStack.BoolVal ? TRUE : FALSE;
                    break;

                case SpokeInstructionType.StoreLocalString:
                    lastStack            = stack[--stackIndex];
                    bm                   = variables[ins.Index];
                    variables[ins.Index] = new SpokeObject(ObjectType.String)
                    {
                        StringVal = lastStack.StringVal
                    };
                    break;

                case SpokeInstructionType.StoreLocalMethod:
                case SpokeInstructionType.StoreLocalObject:
                    lastStack            = stack[--stackIndex];
                    bm                   = variables[ins.Index];
                    variables[ins.Index] = lastStack;
                    break;

                case SpokeInstructionType.StoreLocalRef:
                    lastStack     = stack[--stackIndex];
                    bm            = variables[ins.Index];
                    bm.Variables  = lastStack.Variables;
                    bm.ArrayItems = lastStack.ArrayItems;
                    bm.StringVal  = lastStack.StringVal;
                    bm.IntVal     = lastStack.IntVal;
                    bm.BoolVal    = lastStack.BoolVal;
                    bm.FloatVal   = lastStack.FloatVal;
                    break;



                case SpokeInstructionType.StoreFieldBool:
                    lastStack = stack[--stackIndex];
                    lastStack.Variables[ins.Index] = stack[--stackIndex].BoolVal ? TRUE : FALSE;

                    break;

                case SpokeInstructionType.StoreFieldInt:
                    lastStack = stack[--stackIndex];
                    lastStack.Variables[ins.Index] = new SpokeObject(ObjectType.Int)
                    {
                        IntVal = stack[--stackIndex].IntVal
                    };

                    break;

                case SpokeInstructionType.StoreFieldFloat:
                    lastStack = stack[--stackIndex];
                    lastStack.Variables[ins.Index] = new SpokeObject(ObjectType.Float)
                    {
                        FloatVal = stack[--stackIndex].FloatVal
                    };

                    break;

                case SpokeInstructionType.StoreFieldString:
                    lastStack = stack[--stackIndex];
                    lastStack.Variables[ins.Index] = new SpokeObject(ObjectType.String)
                    {
                        StringVal = stack[--stackIndex].StringVal
                    };
                    break;

                case SpokeInstructionType.StoreFieldMethod:
                case SpokeInstructionType.StoreFieldObject:
                    lastStack = stack[--stackIndex];
                    lastStack.Variables[ins.Index] = stack[--stackIndex];

                    break;


                case SpokeInstructionType.StoreToReference:

                    lastStack = stack[--stackIndex];
                    stack[stackIndex - 1].Variables[ins.Index] = lastStack;
                    break;

                case SpokeInstructionType.GetField:

                    stack[stackIndex - 1] = stack[stackIndex - 1].Variables[ins.Index];

                    break;

                case SpokeInstructionType.GetLocal:

                    stack[stackIndex++] = variables[ins.Index];
                    break;

                case SpokeInstructionType.PopStack:
                    stackIndex--;
                    break;

                case SpokeInstructionType.Not:
                    stack[stackIndex - 1] = stack[stackIndex - 1].BoolVal ? FALSE : TRUE;
                    break;

                case SpokeInstructionType.AddStringInt:
                    stack[stackIndex - 2] = new SpokeObject(ObjectType.String)
                    {
                        StringVal = stack[stackIndex - 2].StringVal + stack[stackIndex - 1].IntVal
                    };
                    stackIndex--;

                    break;

                case SpokeInstructionType.AddIntString:

                    stack[stackIndex - 2] = new SpokeObject(ObjectType.String)
                    {
                        StringVal = stack[stackIndex - 2].IntVal + stack[stackIndex - 1].StringVal
                    };
                    stackIndex--;
                    break;

                case SpokeInstructionType.IntConstant:
                    stack[stackIndex++] = intCache(ins.Index);
                    break;

                case SpokeInstructionType.BoolConstant:

                    stack[stackIndex++] = ins.BoolVal ? TRUE : FALSE;
                    break;

                case SpokeInstructionType.FloatConstant:
                    stack[stackIndex++] = new SpokeObject(ObjectType.Float)
                    {
                        FloatVal = ins.FloatVal
                    };
                    break;

                case SpokeInstructionType.StringConstant:

                    stack[stackIndex++] = new SpokeObject(ObjectType.String)
                    {
                        StringVal = ins.StringVal
                    };
                    break;

                case SpokeInstructionType.Null:
                    stack[stackIndex++] = NULL;
                    break;

                case SpokeInstructionType.AddIntInt:
                    stack[stackIndex - 2] = intCache(stack[stackIndex - 2].IntVal + stack[stackIndex - 1].IntVal);
                    stackIndex--;
                    break;

                case SpokeInstructionType.AddIntFloat:
                    break;

                case SpokeInstructionType.AddFloatInt:
                    break;

                case SpokeInstructionType.AddFloatFloat:
                    break;

                case SpokeInstructionType.AddFloatString:
                    stack[stackIndex - 2] = new SpokeObject(ObjectType.String)
                    {
                        StringVal = stack[stackIndex - 2].FloatVal + stack[stackIndex - 1].StringVal
                    };
                    stackIndex--;
                    break;

                case SpokeInstructionType.AddStringFloat:
                    stack[stackIndex - 2] = new SpokeObject(ObjectType.String)
                    {
                        StringVal = stack[stackIndex - 2].StringVal + stack[stackIndex - 1].FloatVal
                    };
                    stackIndex--;
                    break;

                case SpokeInstructionType.AddStringString:
                    stack[stackIndex - 2] = new SpokeObject(ObjectType.String)
                    {
                        StringVal = stack[stackIndex - 2].StringVal + stack[stackIndex - 1].StringVal
                    };
                    stackIndex--;
                    break;

                case SpokeInstructionType.SubtractIntInt:
                    stack[stackIndex - 2] = intCache(stack[stackIndex - 2].IntVal - stack[stackIndex - 1].IntVal);
                    stackIndex--;

                    break;

                case SpokeInstructionType.SubtractIntFloat:
                    break;

                case SpokeInstructionType.SubtractFloatInt:
                    break;

                case SpokeInstructionType.SubtractFloatFloat:
                    break;

                case SpokeInstructionType.MultiplyIntInt:

                    stack[stackIndex - 2] = intCache(stack[stackIndex - 2].IntVal * stack[stackIndex - 1].IntVal);
                    stackIndex--;
                    break;

                case SpokeInstructionType.MultiplyIntFloat:
                    break;

                case SpokeInstructionType.MultiplyFloatInt:
                    break;

                case SpokeInstructionType.MultiplyFloatFloat:
                    break;

                case SpokeInstructionType.DivideIntInt:

                    stack[stackIndex - 2] = intCache(stack[stackIndex - 2].IntVal / stack[stackIndex - 1].IntVal);
                    stackIndex--;
                    break;

                case SpokeInstructionType.DivideIntFloat:
                    break;

                case SpokeInstructionType.DivideFloatInt:
                    break;

                case SpokeInstructionType.DivideFloatFloat:
                    break;

                case SpokeInstructionType.GreaterIntInt:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal > stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.GreaterIntFloat:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal > stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.GreaterFloatInt:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal > stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.GreaterFloatFloat:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal > stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.LessIntInt:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal < stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.LessIntFloat:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal < stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.LessFloatInt:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal < stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.LessFloatFloat:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal < stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.GreaterEqualIntInt:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal >= stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.GreaterEqualIntFloat:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal >= stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.GreaterEqualFloatInt:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal >= stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.GreaterEqualFloatFloat:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal >= stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.LessEqualIntInt:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal <= stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.LessEqualIntFloat:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal <= stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.LessEqualFloatInt:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal <= stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.LessEqualFloatFloat:
                    stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal <= stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.Equal:
                    stack[stackIndex - 2] = SpokeObject.Compare(stack[stackIndex - 2], stack[stackIndex - 1]) ? TRUE : FALSE;
                    stackIndex            = stackIndex - 1;
                    break;

                case SpokeInstructionType.InsertToArray:
                    break;

                case SpokeInstructionType.RemoveToArray:
                    break;

                case SpokeInstructionType.AddToArray:
                    lastStack = stack[--stackIndex];
                    stack[stackIndex - 1].AddArray(lastStack);
                    break;

                case SpokeInstructionType.AddRangeToArray:
                    lastStack = stack[--stackIndex];
                    stack[stackIndex - 1].AddRangeArray(lastStack);
                    break;

                case SpokeInstructionType.LengthOfArray:
                    break;

                case SpokeInstructionType.ArrayElem:

                    lastStack             = stack[--stackIndex];
                    stack[stackIndex - 1] = stack[stackIndex - 1].ArrayItems[lastStack.IntVal];

                    break;

                case SpokeInstructionType.StoreArrayElem:

                    var indexs = stack[--stackIndex];
                    var ars    = stack[--stackIndex];

                    ars.ArrayItems[indexs.IntVal] = stack[--stackIndex];


                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

#if stacktrace
            dfss.AppendLine(fm.Class.Name + " : : " + fm.MethodName + " End");
#endif

            return(null);
        }
Exemplo n.º 27
0
        private GameBoard buildBoard(SpokeObject spokeObject)
        {
            GameBoard gb = new GameBoard();

            var mainArea = getVariableByName(spokeObject, "mainArea");
            var userAreas = getVariableByName(spokeObject, "userAreas");

            gb.MainArea = buildArea(mainArea, getVariableByName(spokeObject, "piles"));
            gb.UserAreas = new List<TableArea>();
            foreach (var area in userAreas.ArrayItems)
            {
                gb.UserAreas.Add(buildArea(area, getVariableByName(spokeObject, "piles")));

            }

            return gb;
        }
Exemplo n.º 28
0
        private SpokeObject MaindoHanoi(SpokeObject[] variables)
        {
            SpokeObject[] specVariables = new SpokeObject[0]; SpokeObject[] sps;
            SpokeObject bm2;
            SpokeObject bm;
            SpokeObject lastStack;
            if (!(((variables[1].IntVal > ints[0].IntVal) ? TRUE : FALSE)).BoolVal)
                goto EndIf192;
            MaindoHanoi(new SpokeObject[] { variables[0], intCache(variables[1].IntVal - ints[1].IntVal), variables[2], variables[4], variables[3] });
            Mainmove(new SpokeObject[] { variables[0], variables[1], variables[2], variables[3], null, null, null });
            Maindraw(new SpokeObject[] { variables[0], null, null, null, null, null, null, null, null, null, null, null, null, null });
            MaindoHanoi(new SpokeObject[] { variables[0], intCache(variables[1].IntVal - ints[1].IntVal), variables[4], variables[3], variables[2] });
            EndIf192:

            return null;
        }
Exemplo n.º 29
0
        private SpokeObject evalute(SpokeItem condition, SpokeMethodRun currentObject, SpokeObject[] variables, bool parentIsNull = false)
        {
            #if Stacktrace
                dfss.AppendLine(condition.ToString());
            #endif

            SpokeObject r;
            SpokeObject l;
            switch (condition.IType)
            {
                case ISpokeItem.Array:
                    var ar = new SpokeObject() { Type = ObjectType.Array};

                    ar.ArrayItems = new List<SpokeObject>(20);

                    foreach (var spokeItem in ((SpokeArray)condition).Parameters)
                    {
                        var grb = evalute(spokeItem, currentObject, variables);
                        if (grb.Type == ObjectType.Array)
                            ar.ArrayItems.AddRange(grb.ArrayItems);

                        else
                            ar.ArrayItems.Add(grb);
                    }

                    return ar;
                    break;
                case ISpokeItem.Float:
                    return new SpokeObject() { FloatVal = ((SpokeFloat)condition).Value, Type = ObjectType.Float };
                    break;
                case ISpokeItem.Int:
                    return intCache(((SpokeInt)condition).Value);
                    break;

                case ISpokeItem.String:
                    return new SpokeObject() { StringVal = ((SpokeString)condition).Value, Type = ObjectType.String };
                    break;
                case ISpokeItem.Bool:
                    return ((SpokeBool)condition).Value ? TRUE : FALSE;
                    break;
                case ISpokeItem.Variable:
                    SpokeObject g;
                    SpokeVariable mv = ((SpokeVariable)condition);

                    if (mv.Parent != null)
                    {
                        var ca = evalute(mv.Parent, currentObject, variables);

                        return ca.GetVariable(mv.VariableIndex, mv.ForSet);
                    }

                    if (mv.This)
                    {
                        g = currentObject.RunningClass.Variables[mv.VariableIndex];
                        if (g == null)
                        {
                            return currentObject.RunningClass.Variables[mv.VariableIndex] = new SpokeObject();
                        }
                        if (mv.ForSet)
                        {

                            return currentObject.RunningClass.Variables[mv.VariableIndex] = new SpokeObject();
                        }
                        return g;
                    }

                    if ((g = variables[mv.VariableIndex]) != null)
                    {
                        if (mv.ForSet)
                        {
                            return variables[mv.VariableIndex] = new SpokeObject();
                        }
                        return g;
                    }

                    return variables[((SpokeVariable)condition).VariableIndex] = new SpokeObject();

                    break;
                case ISpokeItem.ArrayIndex:
                    var pa = evalute(((SpokeArrayIndex)condition).Parent, currentObject, variables);

                    var ind = evalute(((SpokeArrayIndex)condition).Index, currentObject, variables);

                    if (ind.Type == ObjectType.String)
                    {
                        throw new AbandonedMutexException("hmmmm");
                        if (((SpokeArrayIndex)condition).ForSet)
                        {
                            var drb = new SpokeObject();
                            //                            pa.Variables[ind.StringVal] = drb;
                            return drb;
                        }

                        //                      return pa.Variables[ind.StringVal];
                    }

                    if (ind.Type == ObjectType.Array)
                    {
                        specialIndeces = new List<int>(ind.ArrayItems.Count);
                        foreach (var spokeObject in ind.ArrayItems)
                        {
                            specialIndeces.Add(spokeObject.IntVal);
                        }
                        return pa;

                    }
                    if (((SpokeArrayIndex)condition).ForSet)
                    {
                        var drb = new SpokeObject();
                        pa.ArrayItems[ind.IntVal] = drb;
                        return drb;
                    }

                    return pa.ArrayItems[ind.IntVal];
                    break;
                case ISpokeItem.Current:

                    return currentObject.RunningClass;
                    break;
                case ISpokeItem.Null:

                    return NULL;
                    break;
                case ISpokeItem.AnonMethod:

                    if (((SpokeAnonMethod)condition).HasYield || ((SpokeAnonMethod)condition).HasYieldReturn)
                    {
                        if (((SpokeAnonMethod)condition).ReturnYield != null)
                        {

                            var d = evalute(((SpokeAnonMethod)condition).ReturnYield, currentObject, variables);

                            d.ArrayItems = new List<SpokeObject>();
                            d.Type = ObjectType.Array;
                        }
                    }

                    if (((SpokeAnonMethod)condition).Parent != null)
                    {

            #if Stacktrace
                        dfss.AppendLine(((SpokeAnonMethod)condition).Parent.ToString());
            #endif
                        var rl = evalute(((SpokeAnonMethod)condition).Parent, currentObject, variables);
                        SpokeMethodRun df;

                        if (((SpokeAnonMethod)condition).RunOnVar != null)
                        {
                            df = new SpokeMethodRun() { RunningClass = evalute(((SpokeAnonMethod)condition).RunOnVar, currentObject, variables) };

                            if (df.RunningClass.AnonMethod != null)
                            {
                                var d = evalute(df.RunningClass.AnonMethod.ReturnYield, currentObject, variables);
                                d.ArrayItems = new List<SpokeObject>();

                                d.Type = ObjectType.Array;
                            }

                        }
                        else
                        {
                            df = new SpokeMethodRun() { RunningClass = currentObject.RunningClass };

                        }

                        if (rl.Type == ObjectType.Array)
                        {
                            if (rl.ArrayItems.Count == 0)
                            {
                                if (((SpokeAnonMethod)condition).HasReturn)
                                {
                                    return NULL;
                                }
                                else
                                {

                                }
                            }

                            if (specialIndeces != null)
                            {
                                foreach (var item in specialIndeces)
                                {
                                    var spokeObject = rl.ArrayItems[item];

                                    if (((SpokeAnonMethod)condition).RunOnVar != null)
                                    {

                                        for (int i = 0; i < df.RunningClass.AnonMethod.Parameters.Count(); i++)
                                        {
                                            variables[i] = spokeObject;
                                            if (df.RunningClass.AnonMethod.Parameters[i].ByRef)
                                            {
                                                spokeObject.ByRef = true;
                                            }
                                        }

                                        var rme = evaluateLines(df.RunningClass.AnonMethod.Lines, df, variables);

                                        if (rme != null)
                                            if (df.RunningClass.AnonMethod.HasReturn)
                                            {
                                                //for (int i = 0; i < df.RunningClass.AnonMethod.Parameters.Count(); i++)
                                                //{
                                                //    variables.Remove(df.RunningClass.AnonMethod.Parameters[i].Name);
                                                //}

                                                return rme;
                                            }

                                        //for (int i = 0; i < df.RunningClass.AnonMethod.Parameters.Count(); i++)
                                        //{
                                        //    var c = df.RunningClass.AnonMethod.Parameters[i].Name;
                                        //    variables[c].ByRef = false;
                                        //    variables.Remove(c);
                                        //}

                                    }
                                    else
                                    {
                                        if (((SpokeAnonMethod)condition).Parameters != null)
                                        {

                                            variables[((SpokeAnonMethod)condition).Parameters[0].Index] = spokeObject;

                                            if (((SpokeAnonMethod)condition).Parameters.Length == 2)
                                                variables[((SpokeAnonMethod)condition).Parameters[1].Index] = intCache(item);

                                        }
                                        var rme = evaluateLines(((SpokeAnonMethod)condition).Lines, df, variables);
                                        //yield return
                                        if (rme != null)
                                            if (((SpokeAnonMethod)condition).HasReturn)
                                            {
                                                return rme;
                                            }

                                    }

                                } specialIndeces = null;

                            }
                            else {

                                var vmr = rl.ArrayItems.ToArray();

                                for (int index = 0; index < vmr.Length; index++)
                                {
                                    var spokeObject = vmr[index];

                                    if (((SpokeAnonMethod)condition).RunOnVar != null)
                                    {
                                        for (int i = 0; i < df.RunningClass.AnonMethod.Parameters.Count(); i++)
                                        {
                                            variables[df.RunningClass.AnonMethod.Parameters[i].Index] = spokeObject;
                                            if (df.RunningClass.AnonMethod.Parameters[i].ByRef)
                                            {
                                                spokeObject.ByRef = true;
                                            }
                                        }

                                        var rme = evaluateLines(df.RunningClass.AnonMethod.Lines, df, variables);

                                        if (rme != null)
                                            if (df.RunningClass.AnonMethod.HasReturn)
                                            {
                                                //for (int i = 0; i < df.RunningClass.AnonMethod.Parameters.Count(); i++)
                                                //{
                                                //    variables.Remove(df.RunningClass.AnonMethod.Parameters[i].Name);
                                                //}

                                                return rme;
                                            }

                                        //for (int i = 0; i < df.RunningClass.AnonMethod.Parameters.Count(); i++)
                                        //{
                                        //    var c = df.RunningClass.AnonMethod.Parameters[i].Name;
                                        //    variables[c].ByRef = false;
                                        //    variables.Remove(c);
                                        //}
                                    }
                                    else
                                    {
                                        if (((SpokeAnonMethod)condition).Parameters != null)
                                        {
                                            variables[((SpokeAnonMethod)condition).Parameters[0].Index] = spokeObject;

                                            if (((SpokeAnonMethod)condition).Parameters.Length == 2)
                                                variables[((SpokeAnonMethod)condition).Parameters[1].Index] = intCache(index);
                                        }
                                        var rme = evaluateLines(((SpokeAnonMethod)condition).Lines, df, variables);
                                        //yield return
                                        if (rme != null && rme.Type != ObjectType.Null)
                                            if (((SpokeAnonMethod)condition).HasReturn)
                                            {
                                                return rme;
                                            }
                                    }
                                }
                            }
                        }
                        else if (rl.Type == ObjectType.Bool)
                        {

                        g:
                            if (rl.BoolVal)
                            {
                                var def = evaluateLines(((SpokeAnonMethod)condition).Lines, df, variables);
                                if (def != null)
                                {
                                    if (((SpokeAnonMethod)condition).HasReturn)
                                    {
                                        return def;
                                    }

                                }

                                rl = evalute(((SpokeAnonMethod)condition).Parent, currentObject, variables);
                                goto g;
                            }

                        }

                        if (((SpokeAnonMethod)condition).ReturnYield != null)
                        {

                            return evalute(((SpokeAnonMethod)condition).ReturnYield, currentObject, variables);

                        }

                        if (df.RunningClass.AnonMethod != null)
                        {
                            var d = evalute(df.RunningClass.AnonMethod.ReturnYield, currentObject, variables);
                            return d;
                        }

                        if (((SpokeAnonMethod)condition).HasReturn)
                        {
                            return null;
                            return new SpokeObject() { Type = ObjectType.Null };//should have returned earlier
                        }
                    }
                    else
                    {
                        return new SpokeObject()
                                   {

                                       Type = ObjectType.Method,
                                       AnonMethod =
                                           new SpokeObjectMethod()
                                               {
                                                   ReturnYield = ((SpokeAnonMethod)condition).ReturnYield,
                                                   Lines = ((SpokeAnonMethod)condition).Lines,
                                                   Parameters = ((SpokeAnonMethod)condition).Parameters,
                                                   HasReturn = ((SpokeAnonMethod)condition).HasReturn,
                                               }
                                   };
                    }

                    break;
                case ISpokeItem.MethodCall:

                    var gf = ((SpokeMethodCall)condition);

                    if (gf.Parent is SpokeAnonMethod)
                    {
                        for (int index = 1; index < gf.Parameters.Length; index++)
                        {
                            var spokeItem = gf.Parameters[index];
                            SpokeObject eh;
                            variables[((SpokeAnonMethod)gf.Parent).Parameters[index - 1].Index] =
                                eh = evalute(spokeItem, currentObject, variables);

                            eh.ByRef = ((SpokeAnonMethod)gf.Parent).Parameters[index - 1].ByRef;
                        }
                        var fd = evaluateLines(((SpokeAnonMethod)gf.Parent).Lines, currentObject, variables);

                        if (!parentIsNull)
                        {
                            return fd;
                        }
                        else
                        {
                          //Console.Write("Hmm");
                        }
                    }
                    else
                    {
                        var d = ((SpokeVariable)gf.Parent);
                        if (d.Parent == null)
                        {

                            SpokeMethod meth;

                            SpokeObject[] parms;
                            switch (d.VType)
                            {
                                case SpokeVType.V:
                                    if ((g = variables[d.VariableIndex]) != null && g.Type == ObjectType.Method)
                                    {
                                        for (int i = 0; i < g.AnonMethod.Parameters.Count(); i++)
                                        {
                                            SpokeObject cg;
                                            variables[g.AnonMethod.Parameters[i].Index] = cg = evalute(gf.Parameters[i + 1], currentObject, variables);
                                            cg.ByRef = g.AnonMethod.Parameters[i].ByRef;

                                        }
                                        if (g.AnonMethod.ReturnYield != null)
                                        {
                                            var dr = evalute(g.AnonMethod.ReturnYield, currentObject, variables);

                                            dr.ArrayItems = new List<SpokeObject>();

                                            dr.Type = ObjectType.Array;
                                        }

                                        var rme = evaluateLines(g.AnonMethod.Lines, currentObject, variables);

                                        if (g.AnonMethod.ReturnYield != null)
                                        {
                                            return evalute(g.AnonMethod.ReturnYield, currentObject, variables);

                                        }

                                        return rme;

                                    }
                                    break;
                                case SpokeVType.MethodName:
                                    meth = Methods[d.VariableIndex];

                                        parms = new SpokeObject[gf.Parameters.Length];
                                        for (int i = 0; i < parms.Length; i++)
                                        {
                                            parms[i] = evalute(gf.Parameters[i], currentObject, variables);
                                        }

                                        return evaluate(meth, currentObject.RunningClass, parms);

                                    break;
                                case SpokeVType.InternalMethodName:
                                    parms = new SpokeObject[gf.Parameters.Length];
                                    for (int i = 0; i < parms.Length; i++)
                                    {
                                        parms[i] = evalute(gf.Parameters[i], currentObject, variables);
                                    }

                                    return InternalMethods[d.VariableIndex](parms);

                                    break;
                                case SpokeVType.ThisV:
                                    if ((g = currentObject.RunningClass.Variables[d.VariableIndex]) != null && g.Type == ObjectType.Method)
                                    {
                                        for (int i = 0; i < g.AnonMethod.Parameters.Count(); i++)
                                        {
                                            SpokeObject cg;
                                            variables[g.AnonMethod.Parameters[i].Index] = cg = evalute(gf.Parameters[i + 1], currentObject, variables);
                                            cg.ByRef = g.AnonMethod.Parameters[i].ByRef;
                                        }

                                        var rme = evaluateLines(g.AnonMethod.Lines, currentObject, variables);
                                        return rme;

                                    }
                                    break;
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }

                        }
                        else
                        {
                            var pp = evalute(d.Parent, currentObject, variables);

                            var meth =Methods[d.VariableIndex];
                            if (meth != null)
                            {
                                if (meth.MethodFunc != null)
                                {
                                    var gm = new SpokeObject[gf.Parameters.Length];

                                    gm[0] = pp;

                                    for (int index = 1; index < gf.Parameters.Length; index++)
                                    {
                                        gm[index] = evalute(gf.Parameters[index], currentObject, variables);
                                    }
                                    return meth.MethodFunc(gm);
                                }
                                else
                                {
                                    var parms = new SpokeObject[gf.Parameters.Length];
                                    parms[0] = pp;
                                    for (int i = 1; i < parms.Length; i++)
                                    {
                                        parms[i] = evalute(gf.Parameters[i], currentObject, variables);
                                    }

                                    return evaluate(meth, pp,
                                                    parms);
                                }

                            }

                            if (pp.TryGetVariable(d.VariableIndex, out g) && g.Type == ObjectType.Method)
                            {
                                for (int i = 0; i < g.AnonMethod.Parameters.Count(); i++)
                                {
                                    SpokeObject cg;
                                    variables[g.AnonMethod.Parameters[i].Index] = cg = evalute(gf.Parameters[i + 1], currentObject, variables);
                                    cg.ByRef = g.AnonMethod.Parameters[i].ByRef;
                                }

                                var rme = evaluateLines(g.AnonMethod.Lines, new SpokeMethodRun() { RunningClass = pp }, variables);
                                return rme;

                            }

                            else

                                throw new AbandonedMutexException("no method: " + d.VariableName);

                        }
                    }

                    break;
                case ISpokeItem.Construct:

                    var cons = new SpokeObject();
                    cons.Type = ObjectType.Object;
                    var rf = (SpokeConstruct)condition;

                    if (rf.MethodIndex >=0)
                    {

                        var fd =Methods[rf.MethodIndex];

                        cons.Variables = new SpokeObject[rf.NumOfVars];

                        var parms = new SpokeObject[fd.NumOfVars];
                        parms[0] = cons;
                        for (int i = 1; i < rf.Parameters.Length + 1; i++)
                        {
                            parms[i] = evalute(rf.Parameters[i - 1], currentObject, variables);
                        }

                        evaluate(fd, cons, parms);
                    }

                    else
                    {
                        cons.Variables = new SpokeObject[rf.SetVars.Length];

                    }

                    for (int index = 0; index < rf.SetVars.Length; index++)
                    {
                        SVarItems spokeItem = rf.SetVars[index];
                        cons.Variables[spokeItem.Index] = evalute(spokeItem.Item, currentObject, variables);
                    }
                    return cons;

                    break;
                case ISpokeItem.Addition:

                    l = evalute(((SpokeAddition)condition).LeftSide, currentObject, variables);
                    r = evalute(((SpokeAddition)condition).RightSide, currentObject, variables);

                    switch (l.Type)
                    {

                        case ObjectType.Int:
                            switch (r.Type)
                            {
                                case ObjectType.Int: return intCache(l.IntVal + r.IntVal);

                                    break;
                                case ObjectType.Float: return new SpokeObject() { FloatVal = l.IntVal + r.FloatVal, Type = r.Type };

                                    break;
                                case ObjectType.String: return new SpokeObject() { StringVal = l.IntVal + r.StringVal, Type = r.Type };
                                    break;
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }
                            break;
                        case ObjectType.Float: switch (r.Type)
                            {
                                case ObjectType.Int: return new SpokeObject() { FloatVal = l.FloatVal + r.IntVal, Type = l.Type };

                                    break;
                                case ObjectType.Float: return new SpokeObject() { FloatVal = l.FloatVal + r.FloatVal, Type = l.Type };

                                    break;
                                case ObjectType.String: return new SpokeObject() { StringVal = l.FloatVal + r.StringVal, Type = r.Type };
                                    break;
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }

                            break;
                        case ObjectType.String: switch (r.Type)
                            {
                                case ObjectType.Int: return new SpokeObject() { StringVal = l.StringVal + r.IntVal, Type = l.Type };
                                    break;
                                case ObjectType.Float: return new SpokeObject() { StringVal = l.StringVal + r.FloatVal, Type = l.Type };
                                    break;
                                case ObjectType.String: return new SpokeObject() { StringVal = l.StringVal + r.StringVal, Type = l.Type };
                                    break;
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }

                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                    break;
                case ISpokeItem.Subtraction:

                    l = evalute(((SpokeSubtraction)condition).LeftSide, currentObject, variables);
                    r = evalute(((SpokeSubtraction)condition).RightSide, currentObject, variables);

                    switch (l.Type)
                    {

                        case ObjectType.Int:
                            switch (r.Type)
                            {
                                case ObjectType.Int: return intCache(l.IntVal- r.IntVal);

                                    break;
                                case ObjectType.Float: return new SpokeObject() { FloatVal = l.IntVal - r.FloatVal, Type = r.Type };

                                    break;

                                default:
                                    throw new ArgumentOutOfRangeException();
                            }
                            break;
                        case ObjectType.Float: switch (r.Type)
                            {
                                case ObjectType.Int: return new SpokeObject() { FloatVal = l.FloatVal - r.IntVal, Type = l.Type };

                                    break;
                                case ObjectType.Float: return new SpokeObject() { FloatVal = l.FloatVal - r.FloatVal, Type = l.Type };

                                    break;
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }

                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                    break;
                case ISpokeItem.Multiplication:

                    l = evalute(((SpokeMultiplication)condition).LeftSide, currentObject, variables);
                    r = evalute(((SpokeMultiplication)condition).RightSide, currentObject, variables);

                    switch (l.Type)
                    {

                        case ObjectType.Int:
                            switch (r.Type)
                            {
                                case ObjectType.Int: return intCache(l.IntVal * r.IntVal);

                                    break;
                                case ObjectType.Float: return new SpokeObject() { FloatVal = l.IntVal * r.FloatVal, Type = r.Type };

                                    break;

                                default:
                                    throw new ArgumentOutOfRangeException();
                            }
                            break;
                        case ObjectType.Float: switch (r.Type)
                            {
                                case ObjectType.Int: return new SpokeObject() { FloatVal = l.FloatVal * r.IntVal, Type = l.Type };

                                    break;
                                case ObjectType.Float: return new SpokeObject() { FloatVal = l.FloatVal * r.FloatVal, Type = l.Type };

                                    break;
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }

                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                    break;
                case ISpokeItem.Division:
                    l = evalute(((SpokeDivision)condition).LeftSide, currentObject, variables);
                    r = evalute(((SpokeDivision)condition).RightSide, currentObject, variables);

                    switch (l.Type)
                    {

                        case ObjectType.Int:
                            switch (r.Type)
                            {
                                case ObjectType.Int: return intCache(l.IntVal /r.IntVal);

                                    break;
                                case ObjectType.Float: return new SpokeObject(l.IntVal / r.FloatVal)  ;

                                    break;

                                default:
                                    throw new ArgumentOutOfRangeException();
                            }
                            break;
                        case ObjectType.Float: switch (r.Type)
                            {
                                case ObjectType.Int: return new SpokeObject(l.FloatVal / r.IntVal)  ;

                                    break;
                                case ObjectType.Float: return new SpokeObject(l.FloatVal / r.FloatVal)  ;

                                    break;
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }

                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                    break;
                case ISpokeItem.Greater:
                    l = evalute(((SpokeGreaterThan)condition).LeftSide, currentObject, variables);
                    r = evalute(((SpokeGreaterThan)condition).RightSide, currentObject, variables);
                    switch (l.Type)
                    {

                        case ObjectType.Int:
                            switch (r.Type)
                            {
                                case ObjectType.Int: return l.IntVal > r.IntVal?TRUE:FALSE;

                                    break;
                                case ObjectType.Float: return l.IntVal > r.FloatVal ? TRUE : FALSE;

                                    break;

                                default:
                                    throw new ArgumentOutOfRangeException();
                            }
                            break;
                        case ObjectType.Float: switch (r.Type)
                            {
                            case ObjectType.Int: return l.FloatVal > r.IntVal?TRUE:FALSE;

                                    break;
                            case ObjectType.Float: return l.FloatVal > r.FloatVal?TRUE:FALSE;

                                    break;
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }

                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                    break;
                case ISpokeItem.Less:

                    l = evalute(((SpokeLessThan)condition).LeftSide, currentObject, variables);
                    r = evalute(((SpokeLessThan)condition).RightSide, currentObject, variables);

                    switch (l.Type)
                    {

                        case ObjectType.Int:
                            switch (r.Type)
                            {
                                case ObjectType.Int:
                                    return l.IntVal < r.IntVal ? TRUE : FALSE;

                                    break;
                                case ObjectType.Float: return l.IntVal < r.FloatVal?TRUE:FALSE;

                                    break;

                                default:
                                    throw new ArgumentOutOfRangeException();
                            }
                            break;
                        case ObjectType.Float: switch (r.Type)
                            {
                            case ObjectType.Int: return l.FloatVal < r.IntVal?TRUE:FALSE;

                                    break;
                            case ObjectType.Float: return l.FloatVal < r.FloatVal?TRUE:FALSE;

                                    break;
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }

                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                    break;
                case ISpokeItem.And:

                    l = evalute(((SpokeAnd)condition).LeftSide, currentObject, variables);

                    if (l.BoolVal)
                    {
                        r = evalute(((SpokeAnd)condition).RightSide, currentObject, variables);
                        return r.BoolVal?TRUE:FALSE;
                    }
                    return FALSE;

                    break;
                case ISpokeItem.Or:

                    l = evalute(((SpokeOr)condition).LeftSide, currentObject, variables);
                    if (l.BoolVal)
                    {
                        return TRUE;
                    }
                    r = evalute(((SpokeOr)condition).RightSide, currentObject, variables);
                    return r.BoolVal?TRUE:FALSE;
                    break;
                case ISpokeItem.GreaterEqual:
                    l = evalute(((SpokeGreaterThanOrEqual)condition).LeftSide, currentObject, variables);
                    r = evalute(((SpokeGreaterThanOrEqual)condition).RightSide, currentObject, variables);

                    switch (l.Type)
                    {

                        case ObjectType.Int:
                            switch (r.Type)
                            {
                                case ObjectType.Int: return l.IntVal >= r.IntVal?TRUE:FALSE;

                                    break;
                                case ObjectType.Float: return l.IntVal >= r.FloatVal?TRUE:FALSE;

                                    break;

                                default:
                                    throw new ArgumentOutOfRangeException();
                            }
                            break;
                        case ObjectType.Float: switch (r.Type)
                            {
                            case ObjectType.Int: return l.FloatVal >= r.IntVal?TRUE:FALSE;

                                    break;
                            case ObjectType.Float: return l.FloatVal >= r.FloatVal?TRUE:FALSE;

                                    break;
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }

                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                    break;
                case ISpokeItem.LessEqual:
                    l = evalute(((SpokeLessThanOrEqual)condition).LeftSide, currentObject, variables);
                    r = evalute(((SpokeLessThanOrEqual)condition).RightSide, currentObject, variables);

                    switch (l.Type)
                    {

                        case ObjectType.Int:
                            switch (r.Type)
                            {
                                case ObjectType.Int: return l.IntVal <= r.IntVal?TRUE:FALSE;

                                    break;
                                case ObjectType.Float: return l.IntVal <= r.FloatVal?TRUE:FALSE;

                                    break;

                                default:
                                    throw new ArgumentOutOfRangeException();
                            }
                            break;
                        case ObjectType.Float: switch (r.Type)
                            {
                            case ObjectType.Int: return l.FloatVal <= r.IntVal?TRUE:FALSE;

                                    break;
                            case ObjectType.Float: return l.FloatVal <= r.FloatVal?TRUE:FALSE;

                                    break;
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }

                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                    break;
                case ISpokeItem.Equality:
                    l = evalute(((SpokeEquality)condition).LeftSide, currentObject, variables);
                    r = evalute(((SpokeEquality)condition).RightSide, currentObject, variables);

                    return SpokeObject.Compare(l, r)?TRUE:FALSE;
                    break;
                case ISpokeItem.NotEqual:
                    l = evalute(((SpokeNotEqual)condition).LeftSide, currentObject, variables);
                    r = evalute(((SpokeNotEqual)condition).RightSide, currentObject, variables);

                    return SpokeObject.Compare(l, r)?FALSE:TRUE;

                default:
                    throw new ArgumentOutOfRangeException();
            }
            return null;
        }
Exemplo n.º 30
0
 public bool TryGetVariable(int name, out SpokeObject obj)
 {
     return((obj = Variables[name]) != null);
 }
Exemplo n.º 31
0
        internal static bool Compare(SpokeObject left, SpokeObject right)
        {
            if (left == null)
            {
                if (right == null)
                {
                    return(true);
                }
                if (right.Type == ObjectType.Null)
                {
                    return(true);
                }
            }
            else
            {
                if (left.Type == ObjectType.Null && right == null)
                {
                    return(true);
                }
            }
            if (left.Type != right.Type)
            {
                return(false);
            }
            switch (left.Type)
            {
            case ObjectType.Null:
                return(true);

                break;

            case ObjectType.Int:
                return(left.IntVal == right.IntVal);

                break;

            case ObjectType.Float:
                return(left.FloatVal == right.FloatVal);

                break;

            case ObjectType.String:
                return(left.StringVal == right.StringVal);

                break;

            case ObjectType.Bool:
                return(left.BoolVal == right.BoolVal);

                break;

            case ObjectType.Object:
                //                    throw new AbandonedMutexException("not yet cowbow");

                for (int i = 0; i < left.Variables.Length; i++)
                {
                    if (!Compare(right.Variables[i], left.Variables[i]))
                    {
                        return(false);
                    }
                }
                return(true);

                break;

            case ObjectType.Array:

            case ObjectType.Method:
            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 32
0
 public void AddRangeArray(SpokeObject lastStack)
 {
     ArrayItems.AddRange(lastStack.ArrayItems);
 }
Exemplo n.º 33
0
        private SpokeObject Maindraw(SpokeObject[] variables)
        {
            SpokeObject[] specVariables = new SpokeObject[0]; SpokeObject[] sps;
            SpokeObject   bm2;
            SpokeObject   bm;
            SpokeObject   lastStack;

            variables[1] = intCache(ints[2].IntVal);
            variables[2] = new SpokeObject(new SpokeObject(" ").StringVal);
            variables[3] = new SpokeObject(new SpokeObject("0").StringVal);
            variables[4] = intCache(ints[0].IntVal);
            InternalMethods[12](new SpokeObject[] { variables[0], variables[4], ints[1] });
            InternalMethods[0](new SpokeObject[] { variables[0], new SpokeObject("Peg1") });
            variables[5] = variables[0].Variables[0];
            variables[6] = intCache(ints[0].IntVal);
_topOfForeach_310:
            if (!(((variables[6].IntVal < Methods[2].MethodFunc(new SpokeObject[] { variables[5] }).IntVal) ? TRUE : FALSE)).BoolVal)
            {
                goto EndLoop310;
            }
            variables[7] = variables[5].ArrayItems[variables[6].IntVal];
            InternalMethods[12](new SpokeObject[] { variables[0], variables[4], variables[1] });
            if (!(((variables[7].IntVal < ints[10].IntVal) ? TRUE : FALSE)).BoolVal)
            {
                goto EndIf316;
            }
EndIf316:
            InternalMethods[0](new SpokeObject[] { variables[0], variables[7] });
            InternalMethods[0](new SpokeObject[] { variables[0], variables[2] });
            variables[1] = intCache(intCache(variables[1].IntVal + ints[1].IntVal).IntVal);
            variables[6] = intCache(intCache(variables[6].IntVal + ints[1].IntVal).IntVal);
            goto _topOfForeach_310;
EndLoop310:
            variables[1] = intCache(ints[2].IntVal);
            variables[4] = intCache(intCache(variables[4].IntVal + ints[5].IntVal).IntVal);
            InternalMethods[12](new SpokeObject[] { variables[0], variables[4], ints[1] });
            InternalMethods[0](new SpokeObject[] { variables[0], new SpokeObject("Peg2") });
            variables[8] = variables[0].Variables[1];
            variables[9] = intCache(ints[0].IntVal);
_topOfForeach_356:
            if (!(((variables[9].IntVal < Methods[2].MethodFunc(new SpokeObject[] { variables[8] }).IntVal) ? TRUE : FALSE)).BoolVal)
            {
                goto EndLoop356;
            }
            variables[10] = variables[8].ArrayItems[variables[9].IntVal];
            InternalMethods[12](new SpokeObject[] { variables[0], variables[4], variables[1] });
            if (!(((variables[10].IntVal < ints[10].IntVal) ? TRUE : FALSE)).BoolVal)
            {
                goto EndIf362;
            }
EndIf362:
            InternalMethods[0](new SpokeObject[] { variables[0], variables[10] });
            InternalMethods[0](new SpokeObject[] { variables[0], variables[2] });
            variables[1] = intCache(intCache(variables[1].IntVal + ints[1].IntVal).IntVal);
            variables[9] = intCache(intCache(variables[9].IntVal + ints[1].IntVal).IntVal);
            goto _topOfForeach_356;
EndLoop356:
            variables[1] = intCache(ints[2].IntVal);
            variables[4] = intCache(intCache(variables[4].IntVal + ints[5].IntVal).IntVal);
            InternalMethods[12](new SpokeObject[] { variables[0], variables[4], ints[1] });
            InternalMethods[0](new SpokeObject[] { variables[0], new SpokeObject("Peg3") });
            variables[11] = variables[0].Variables[2];
            variables[12] = intCache(ints[0].IntVal);
_topOfForeach_402:
            if (!(((variables[12].IntVal < Methods[2].MethodFunc(new SpokeObject[] { variables[11] }).IntVal) ? TRUE : FALSE)).BoolVal)
            {
                goto EndLoop402;
            }
            variables[13] = variables[11].ArrayItems[variables[12].IntVal];
            InternalMethods[12](new SpokeObject[] { variables[0], variables[4], variables[1] });
            if (!(((variables[13].IntVal < ints[10].IntVal) ? TRUE : FALSE)).BoolVal)
            {
                goto EndIf408;
            }
EndIf408:
            InternalMethods[0](new SpokeObject[] { variables[0], variables[13] });
            InternalMethods[0](new SpokeObject[] { variables[0], variables[2] });
            variables[1]  = intCache(intCache(variables[1].IntVal + ints[1].IntVal).IntVal);
            variables[12] = intCache(intCache(variables[12].IntVal + ints[1].IntVal).IntVal);
            goto _topOfForeach_402;
EndLoop402:

            return(null);
        }
Exemplo n.º 34
0
 public bool Compare(SpokeObject obj)
 {
     return Compare(this, obj);
 }
Exemplo n.º 35
0
 public SpokeObject AddArray(SpokeObject lastStack)
 {
     ArrayItems.Add(lastStack);
     return(this);
 }
Exemplo n.º 36
0
        public SpokeObject GetVariable(int name, bool forSet)
        {
            SpokeObject g = Variables[name];

            if (g == null || forSet)
            {
                return Variables[name] = new SpokeObject();
            }
            return g;
        }
Exemplo n.º 37
0
        private TableArea buildArea(SpokeObject mainArea, SpokeObject cardgamePiles)
        {
            var tca = new TableArea();
            tca.Dimensions = getRect(getVariableByName(mainArea, "dimensions"));
            tca.NumberOfCardsHorizontal = getVariableByName(mainArea, "numberOfCardsHorizontal").IntVal;
            tca.NumberOfCardsVertical = getVariableByName(mainArea, "numberOfCardsVertical").IntVal;
            tca.Spaces = new List<TableSpace>();
            tca.TextAreas = new List<TableTextArea>();

            foreach (var space in getVariableByName(mainArea, "spaces").ArrayItems)
            {
                TableSpace ts;
                tca.Spaces.Add(ts = new TableSpace());
                ts.Visible = getVariableByName(space, "visible").BoolVal;
                ts.Width = getVariableByName(space, "width").IntVal;
                ts.Height = getVariableByName(space, "height").IntVal;
                ts.X = getVariableByName(space, "xPosition").IntVal;
                ts.Y = getVariableByName(space, "yPosition").IntVal;
                ts.DrawCardsBent = getVariableByName(space, "drawCardsBent").BoolVal;
                ts.Name = getVariableByName(space, "name").StringVal;
                ts.StackCards = getVariableByName(space, "stackCards").BoolVal;
                ts.Cards = new List<Card>();

                foreach (var card in getVariableByName(getVariableByName(space, "pile"), "Cards").ArrayItems)
                    ts.Cards.Add(new Card(getVariableByName(card, "Value").IntVal, getVariableByName(card, "Type").IntVal, getVariableByName(card, "CardName").StringVal));

            }

            foreach (var textarea in getVariableByName(mainArea, "textAreas").ArrayItems)
            {
                TableTextArea ta;
                tca.TextAreas.Add(ta = new TableTextArea());
                ta.Name = getVariableByName(textarea, "name").StringVal;
                ta.RotateAngle = getVariableByName(textarea, "rotateAngle").IntVal;
                ta.Text = getVariableByName(textarea, "text").StringVal;
                ta.X = getVariableByName(textarea, "xPosition").IntVal;
                ta.Y = getVariableByName(textarea, "yPosition").IntVal;

            }
            return tca;
        }
Exemplo n.º 38
0
        private SpokeObject Mainmove(SpokeObject[] variables)
        {
            SpokeObject[] specVariables = new SpokeObject[0]; SpokeObject[] sps;
            SpokeObject bm2;
            SpokeObject bm;
            SpokeObject lastStack;
            InternalMethods[10](new SpokeObject[] { variables[0] });
            InternalMethods[9](new SpokeObject[] { variables[0], new SpokeObject("Move Disk"), variables[1], new SpokeObject("From"), variables[2], new SpokeObject("To"), variables[3] });
            if (!(((variables[2].Compare(new SpokeObject("1")) ? TRUE : FALSE))).BoolVal)
                goto EndIf235;
            Methods[3].MethodFunc(new SpokeObject[] { variables[0].Variables[0], variables[1] });
            EndIf235:
            if (!(((variables[2].Compare(new SpokeObject("2")) ? TRUE : FALSE))).BoolVal)
                goto EndIf244;
            Methods[3].MethodFunc(new SpokeObject[] { variables[0].Variables[1], variables[1] });
            EndIf244:
            if (!(((variables[2].Compare(new SpokeObject("3")) ? TRUE : FALSE))).BoolVal)
                goto EndIf253;
            Methods[3].MethodFunc(new SpokeObject[] { variables[0].Variables[2], variables[1] });
            EndIf253:
            if (!(((variables[3].Compare(new SpokeObject("1")) ? TRUE : FALSE))).BoolVal)
                goto EndIf262;
            Methods[6].MethodFunc(new SpokeObject[] { variables[0].Variables[0], variables[3], variables[1] });
            EndIf262:
            if (!(((variables[3].Compare(new SpokeObject("2")) ? TRUE : FALSE))).BoolVal)
                goto EndIf272;
            Methods[6].MethodFunc(new SpokeObject[] { variables[0].Variables[1], variables[3], variables[1] });
            EndIf272:
            if (!(((variables[3].Compare(new SpokeObject("3")) ? TRUE : FALSE))).BoolVal)
                goto EndIf282;
            Methods[6].MethodFunc(new SpokeObject[] { variables[0].Variables[2], variables[3], variables[1] });
            EndIf282:

            return null;
        }
Exemplo n.º 39
0
        private SpokeObject evaluateMethod(SpokeMethod fm, SpokeObject[] paras)
        {
            SpokeObject[] variables;

            #if stacktrace
            dfss.AppendLine( fm.Class.Name +" : : "+fm.MethodName+" Start");
            #endif

            SpokeObject lastStack;
            int stackIndex = 0;
            SpokeObject[] stack = new SpokeObject[3000];
            int index = 0;
            StackTracer st;
            if (reprintStackIndex == -1)
            {
                variables = new SpokeObject[fm.NumOfVars];

                for (int i = 0; i < fm.Parameters.Length; i++)
                {
                    variables[i] = paras[i];
                }

                stackTrace.Add(st = new StackTracer(stack, variables));
            }
            else
            {
                StackTracer rp = reprintStackTrace[stackTrace.Count];
                stack = rp.StackObjects;
                variables = rp.StackVariables;
                index = rp.InstructionIndex;
                stackIndex = rp.StackIndex;
                stackTrace.Add(st = new StackTracer(stack, variables));
                if (stackTrace.Count == reprintStackIndex)
                {
                    stack[stackIndex++] = rp.Answer;
                    reprintStackIndex = -1;
                    reprintStackTrace = null;
                }
            }

            for (; index < fm.Instructions.Length; index++)
            {
                var ins = fm.Instructions[index];
            #if stacktrace
                dfss.AppendLine(stackIndex + " ::  " + ins.ToString());
            #endif

                //        var fs = new fixStackTracer(stackTrace.ToArray());
                //       stackTrace = new List<StackTracer>(fs.Start(true));

                SpokeObject[] sps;

                SpokeObject bm;
                switch (ins.Type)
                {
                    case SpokeInstructionType.CreateReference:
                        stack[stackIndex++] = new SpokeObject(new SpokeObject[ins.Index], ins.StringVal);
                        break;
                    case SpokeInstructionType.CreateArray:
                        stack[stackIndex++] = new SpokeObject(new List<SpokeObject>(20));
                        break;
                    case SpokeInstructionType.CreateMethod:
                        stack[stackIndex++] = NULL;//new SpokeObject(ObjectType.Method) { AnonMethod = ins.anonMethod };
                        break;
                    case SpokeInstructionType.Label:
                        //   throw new NotImplementedException("");
                        break;
                    case SpokeInstructionType.Goto:

                        index = ins.Index;

                        break;
                    case SpokeInstructionType.Comment:

                        break;
                    case SpokeInstructionType.CallMethod:
                        st.InstructionIndex = index;
                        st.StackIndex = stackIndex;
                        sps = new SpokeObject[ins.Index3];
                        for (int i = ins.Index3 - 1; i >= 0; i--)
                        {
                            sps[i] = stack[--stackIndex];
                        }
                        stack[stackIndex++] = evaluateMethod(Methods[ins.Index], sps);
                        break;
                    case SpokeInstructionType.CallMethodFunc:
                        st.InstructionIndex = index;
                        st.StackIndex = stackIndex;
                        sps = new SpokeObject[ins.Index3];
                        for (int i = ins.Index3 - 1; i >= 0; i--)
                        {
                            sps[i] = stack[--stackIndex];
                        }

                        stack[stackIndex++] = Methods[ins.Index].MethodFunc(sps);
                        break;
                    case SpokeInstructionType.CallInternal:
                        sps = new SpokeObject[ins.Index3];
                        for (int i = ins.Index3 - 1; i >= 0; i--)
                        {
                            sps[i] = stack[--stackIndex];
                        }
                        st.InstructionIndex = index + 1;
                        st.StackIndex = stackIndex;

                        SpokeObject l = InternalMethods[ins.Index](sps);

                        if (ins.Index == 16)
                        {
                            GameBoard d = buildBoard(sps[4]);

                            throw new AskQuestionException(stackTrace,
                                                           new SpokeQuestion(sps[1].Variables[0].StringVal, sps[2].StringVal,
                                                                             sps[3].ArrayItems.Select(a => a.StringVal).ToArray()), d);
                        }
                        else
                        {
                            stack[stackIndex++] = l;
                        }

                        break;
                    case SpokeInstructionType.BreakpointInstruction:
                        Console.WriteLine("BreakPoint");
                        break;
                    case SpokeInstructionType.Return:
            #if stacktrace
                        dfss.AppendLine(fm.Class.Name + " : : " + fm.MethodName + " End");
            #endif
                        stackTrace.Remove(st);
                        return stack[--stackIndex];
                        break;
                    case SpokeInstructionType.IfTrueContinueElse:

                        if (stack[--stackIndex].BoolVal)
                            continue;

                        index = ins.Index;

                        break;
                    case SpokeInstructionType.Or:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].BoolVal || stack[stackIndex - 1].BoolVal) ? TRUE : FALSE;
                        stackIndex--;
                        break;
                    case SpokeInstructionType.And:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].BoolVal && stack[stackIndex - 1].BoolVal) ? TRUE : FALSE;
                        stackIndex--;
                        break;
                    case SpokeInstructionType.StoreLocalInt:
                        lastStack = stack[--stackIndex];
                        bm = variables[ins.Index];
                        variables[ins.Index] = new SpokeObject(ObjectType.Int) { IntVal = lastStack.IntVal };
                        break;
                    case SpokeInstructionType.StoreLocalFloat:
                        lastStack = stack[--stackIndex];
                        bm = variables[ins.Index];
                        variables[ins.Index] = new SpokeObject(ObjectType.Float) { FloatVal = lastStack.FloatVal };
                        break;
                    case SpokeInstructionType.StoreLocalBool:
                        lastStack = stack[--stackIndex];
                        bm = variables[ins.Index];
                        variables[ins.Index] = lastStack.BoolVal ? TRUE : FALSE;
                        break;
                    case SpokeInstructionType.StoreLocalString:
                        lastStack = stack[--stackIndex];
                        bm = variables[ins.Index];
                        variables[ins.Index] = new SpokeObject(ObjectType.String) { StringVal = lastStack.StringVal };
                        break;

                    case SpokeInstructionType.StoreLocalMethod:
                    case SpokeInstructionType.StoreLocalObject:
                        lastStack = stack[--stackIndex];
                        variables[ins.Index] = lastStack;
                        break;
                    case SpokeInstructionType.StoreLocalRef:
                        lastStack = stack[--stackIndex];
                        bm = variables[ins.Index];
                        bm.ClassName = lastStack.ClassName;
                        bm.Type = lastStack.Type;
                        //bm.Variables = lastStack.Variables;
                        //bm.ArrayItems = lastStack.ArrayItems;
                        bm.StringVal = lastStack.StringVal;
                        bm.IntVal = lastStack.IntVal;
                        bm.BoolVal = lastStack.BoolVal;
                        bm.FloatVal = lastStack.FloatVal;
                        break;

                    case SpokeInstructionType.StoreFieldBool:
                        lastStack = stack[--stackIndex];
                        lastStack.Variables[ins.Index] = stack[--stackIndex].BoolVal ? TRUE : FALSE;

                        break;
                    case SpokeInstructionType.StoreFieldInt:
                        lastStack = stack[--stackIndex];
                        lastStack.Variables[ins.Index] = new SpokeObject(ObjectType.Int) { IntVal = stack[--stackIndex].IntVal };

                        break;
                    case SpokeInstructionType.StoreFieldFloat:
                        lastStack = stack[--stackIndex];
                        lastStack.Variables[ins.Index] = new SpokeObject(ObjectType.Float) { FloatVal = stack[--stackIndex].FloatVal };

                        break;
                    case SpokeInstructionType.StoreFieldString:
                        lastStack = stack[--stackIndex];
                        lastStack.Variables[ins.Index] = new SpokeObject(ObjectType.String) { StringVal = stack[--stackIndex].StringVal };
                        break;

                    case SpokeInstructionType.StoreFieldMethod:
                    case SpokeInstructionType.StoreFieldObject:
                        lastStack = stack[--stackIndex];
                        lastStack.Variables[ins.Index] = stack[--stackIndex];

                        break;

                    case SpokeInstructionType.IfEqualsContinueAndPopElseGoto:

                        if (SpokeObject.Compare(stack[stackIndex - 2],
                                stack[stackIndex - 1]))
                        {
                            stackIndex = stackIndex - 2;
                            continue;
                        }

                        stackIndex = stackIndex - 1;
                        index = ins.Index;
                        break;
                    case SpokeInstructionType.StoreToReference:

                        lastStack = stack[--stackIndex];
                        stack[stackIndex - 1].Variables[ins.Index] = lastStack;
                        break;
                    case SpokeInstructionType.GetField:

                        stack[stackIndex - 1] = stack[stackIndex - 1].Variables[ins.Index];

                        break;
                    case SpokeInstructionType.GetLocal:

                        stack[stackIndex++] = variables[ins.Index];
                        break;
                    case SpokeInstructionType.PopStack:
                        stackIndex--;
                        break;
                    case SpokeInstructionType.Not:
                        stack[stackIndex - 1] = stack[stackIndex - 1].BoolVal ? FALSE : TRUE;
                        break;
                    case SpokeInstructionType.AddStringInt:
                        stack[stackIndex - 2] = new SpokeObject(ObjectType.String) { StringVal = stack[stackIndex - 2].StringVal + stack[stackIndex - 1].IntVal };
                        stackIndex--;

                        break;
                    case SpokeInstructionType.AddIntString:

                        stack[stackIndex - 2] = new SpokeObject(ObjectType.String) { StringVal = stack[stackIndex - 2].IntVal + stack[stackIndex - 1].StringVal };
                        stackIndex--;
                        break;
                    case SpokeInstructionType.IntConstant:
                        stack[stackIndex++] = intCache(ins.Index);
                        break;
                    case SpokeInstructionType.BoolConstant:

                        stack[stackIndex++] = ins.BoolVal ? TRUE : FALSE;
                        break;
                    case SpokeInstructionType.FloatConstant:
                        stack[stackIndex++] = new SpokeObject(ObjectType.Float) { FloatVal = ins.FloatVal };
                        break;
                    case SpokeInstructionType.StringConstant:

                        stack[stackIndex++] = new SpokeObject(ObjectType.String) { StringVal = ins.StringVal };
                        break;

                    case SpokeInstructionType.Null:
                        stack[stackIndex++] = NULL;
                        break;
                    case SpokeInstructionType.AddIntInt:
                        stack[stackIndex - 2] = intCache(stack[stackIndex - 2].IntVal + stack[stackIndex - 1].IntVal);
                        stackIndex--;
                        break;
                    case SpokeInstructionType.AddIntFloat:
                        break;
                    case SpokeInstructionType.AddFloatInt:
                        break;
                    case SpokeInstructionType.AddFloatFloat:
                        break;
                    case SpokeInstructionType.AddFloatString:
                        stack[stackIndex - 2] = new SpokeObject(ObjectType.String) { StringVal = stack[stackIndex - 2].FloatVal + stack[stackIndex - 1].StringVal };
                        stackIndex--;
                        break;
                    case SpokeInstructionType.AddStringFloat:
                        stack[stackIndex - 2] = new SpokeObject(ObjectType.String) { StringVal = stack[stackIndex - 2].StringVal + stack[stackIndex - 1].FloatVal };
                        stackIndex--;
                        break;
                    case SpokeInstructionType.AddStringString:
                        stack[stackIndex - 2] = new SpokeObject(ObjectType.String) { StringVal = stack[stackIndex - 2].StringVal + stack[stackIndex - 1].StringVal };
                        stackIndex--;
                        break;
                    case SpokeInstructionType.SubtractIntInt:
                        stack[stackIndex - 2] = intCache(stack[stackIndex - 2].IntVal - stack[stackIndex - 1].IntVal);
                        stackIndex--;

                        break;
                    case SpokeInstructionType.SubtractIntFloat:
                        break;
                    case SpokeInstructionType.SubtractFloatInt:
                        break;
                    case SpokeInstructionType.SubtractFloatFloat:
                        break;
                    case SpokeInstructionType.MultiplyIntInt:

                        stack[stackIndex - 2] = intCache(stack[stackIndex - 2].IntVal * stack[stackIndex - 1].IntVal);
                        stackIndex--;
                        break;
                    case SpokeInstructionType.MultiplyIntFloat:
                        break;
                    case SpokeInstructionType.MultiplyFloatInt:
                        break;
                    case SpokeInstructionType.MultiplyFloatFloat:
                        break;
                    case SpokeInstructionType.DivideIntInt:

                        stack[stackIndex - 2] = intCache(stack[stackIndex - 2].IntVal / stack[stackIndex - 1].IntVal);
                        stackIndex--;
                        break;
                    case SpokeInstructionType.DivideIntFloat:
                        break;
                    case SpokeInstructionType.DivideFloatInt:
                        break;
                    case SpokeInstructionType.DivideFloatFloat:
                        break;

                    case SpokeInstructionType.GreaterIntInt:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal > stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.GreaterIntFloat:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal > stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.GreaterFloatInt:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal > stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.GreaterFloatFloat:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal > stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.LessIntInt:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal < stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.LessIntFloat:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal < stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.LessFloatInt:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal < stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.LessFloatFloat:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal < stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.GreaterEqualIntInt:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal >= stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.GreaterEqualIntFloat:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal >= stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.GreaterEqualFloatInt:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal >= stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.GreaterEqualFloatFloat:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal >= stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.LessEqualIntInt:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal <= stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.LessEqualIntFloat:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].IntVal <= stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.LessEqualFloatInt:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal <= stack[stackIndex - 1].IntVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.LessEqualFloatFloat:
                        stack[stackIndex - 2] = (stack[stackIndex - 2].FloatVal <= stack[stackIndex - 1].FloatVal) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.Equal:
                        stack[stackIndex - 2] = SpokeObject.Compare(stack[stackIndex - 2], stack[stackIndex - 1]) ? TRUE : FALSE;
                        stackIndex = stackIndex - 1;
                        break;
                    case SpokeInstructionType.InsertToArray:
                        break;
                    case SpokeInstructionType.RemoveToArray:
                        break;
                    case SpokeInstructionType.AddToArray:
                        lastStack = stack[--stackIndex];
                        stack[stackIndex - 1].AddArray(lastStack);
                        break;
                    case SpokeInstructionType.AddRangeToArray:
                        lastStack = stack[--stackIndex];
                        stack[stackIndex - 1].AddRangeArray(lastStack);
                        break;
                    case SpokeInstructionType.LengthOfArray:
                        break;

                    case SpokeInstructionType.ArrayElem:

                        lastStack = stack[--stackIndex];
                        stack[stackIndex - 1] = stack[stackIndex - 1].ArrayItems[lastStack.IntVal];

                        break;
                    case SpokeInstructionType.StoreArrayElem:

                        var indexs = stack[--stackIndex];
                        var ars = stack[--stackIndex];

                        ars.ArrayItems[indexs.IntVal] = stack[--stackIndex];

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }

            #if stacktrace
            dfss.AppendLine(fm.Class.Name + " : : " + fm.MethodName + " End");
            #endif
            stackTrace.Remove(st);
            return null;
        }
Exemplo n.º 40
0
        private SpokeObject evaluateLines(SpokeLine[] lines, SpokeMethodRun currentObject, SpokeObject[] variables)
        {
            #if Stacktrace
            File.WriteAllText("C:\\mna.txt", dfss.ToString());
            #endif

            foreach (var spokeLine in lines)
            {

            #if Stacktrace
                dfss.AppendLine(spokeLine.ToString());
            #endif

                switch (spokeLine.LType)
                {
                    case ISpokeLine.If:
                        var b = evalute(((SpokeIf)spokeLine).Condition, currentObject, variables);
                        if (b.BoolVal)
                        {
                            var df = evaluateLines(((SpokeIf)spokeLine).IfLines, currentObject, variables);
                            if (df != null)
                            {
                                return df;
                            }
                        }
                        else
                        {
                            if (((SpokeIf)spokeLine).ElseLines != null)
                            {
                                var df = evaluateLines(((SpokeIf)spokeLine).ElseLines, currentObject, variables);
                                if (df != null)
                                {
                                    return df;
                                }
                            }
                        }
                        break;
                    case ISpokeLine.Return:
                        if (((SpokeReturn)spokeLine).Return == null)
                        {
                            return NULL;
                        }
                        return evalute(((SpokeReturn)spokeLine).Return, currentObject, variables);
                        break;
                    //case ISpokeLine.Yield:
                    //    currentObject.ForYield.Add(evalute(((SpokeYield)spokeLine).Yield, currentObject, variables));
                    //    break;
                    //case ISpokeLine.YieldReturn:
                    //    SpokeObject d;
                    //    currentObject.ForYield.Add(d = evalute(((SpokeYieldReturn)spokeLine).YieldReturn, currentObject, variables));
                    //    return d;
                    //    break;
                    case ISpokeLine.MethodCall:

                        evalute((SpokeItem)spokeLine, currentObject, variables, true);
                        break;
                    case ISpokeLine.AnonMethod:
                        var arm = evalute((SpokeItem)spokeLine, currentObject, variables, true);
                        if (arm != null && !((SpokeAnonMethod)spokeLine).SpecAnon)
                        {
                            return arm;
                        }
                        break;
                    case ISpokeLine.Construct:
                        return evalute((SpokeItem)spokeLine, currentObject, variables);
                        break;
                    case ISpokeLine.Set:

                        var grf = ((SpokeEqual)spokeLine);

                        var right = evalute(grf.RightSide, currentObject, variables);

                        SpokeObject left;
                        switch (right.Type)
                        {
                            case ObjectType.Null:
                                break;
                            case ObjectType.Int:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.Int;
                                left.IntVal = right.IntVal;

                                break;
                            case ObjectType.String:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.String;
                                left.StringVal = right.StringVal;

                                break;
                            case ObjectType.Float:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.Float;
                                left.FloatVal = right.FloatVal;

                                break;
                            case ObjectType.Bool:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.Bool;
                                left.BoolVal = right.BoolVal;

                                break;
                            case ObjectType.Array:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.Array;
                                left.ArrayItems = new List<SpokeObject>(right.ArrayItems);
                                break;
                            case ObjectType.Object:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.Object;
                                left.Variables = (SpokeObject[])right.Variables.Clone();

                                break;
                            case ObjectType.Method:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.Method;
                                left.AnonMethod = right.AnonMethod;
                                left.Variables = right.Variables;
                                break;
                            default:
                                throw new ArgumentOutOfRangeException();
                        }

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
            return null;
        }
Exemplo n.º 41
0
 public Rectangle getRect(SpokeObject so)
 {
     return new Rectangle(getVariableByName(so, "x").IntVal, getVariableByName(so, "y").IntVal, getVariableByName(so, "width").IntVal, getVariableByName(so, "height").IntVal);
 }
Exemplo n.º 42
0
 public SpokeObject AddArray(SpokeObject lastStack)
 {
     ArrayItems.Add(lastStack);
     return this;
 }
Exemplo n.º 43
0
 public SpokeObject getVariableByName(SpokeObject so, string name)
 {
     return so.Variables[Array.IndexOf(myVariableLookup[so.ClassName], name)];
 }
Exemplo n.º 44
0
 public SpokeObject AddArrayRange(SpokeObject lastStack)
 {
     ArrayItems.AddRange(lastStack.ArrayItems);
     return this;
 }
Exemplo n.º 45
0
        private static Dictionary<string, Func<SpokeObject[], SpokeObject>> getIncludedMethods(out Dictionary<string, SpokeType> vs, Dictionary<string, string> playersInGame)
        {
            var rv = new Dictionary<string, Func<SpokeObject[], SpokeObject>>() {
                                                                                    {
                                                                                        "write", (a) => {
                                                                                                     for (int index = 1;
                                                                                                          index < a.Length;
                                                                                                          index++) {
                                                                                                         var spokeObject = a[index];
            #if !dontwrite
                                                                                                         Console.Write(
                                                                                                             spokeObject.ToString() + " ");
            #endif
                                                                                                     }
                                                                                                     return null;
                                                                                                 }
                                                                                        },

                                                                                    {
                                                                                        "readLine", (a) => {
                                                                                            return new SpokeObject(Console.ReadLine());
                                                                                                    }
                                                                                        },
                                                                                    {
                                                                                        "read", (a) => {
                                                                                                    return new SpokeObject(Console
                                                                                                                                     .Read()
                                                                                                                                     .
                                                                                                                                     ToString
                                                                                                                                     ())  ;
                                                                                                }
                                                                                        },
                                                                                    {
                                                                                        "stringToInt", (a) => {
                                                                                                           return new SpokeObject(int
                                                                                                                                            .
                                                                                                                                            Parse
                                                                                                                                            (a
                                                                                                                                                 [
                                                                                                                                                     1
                                                                                                                                                 ]
                                                                                                                                                 .
                                                                                                                                                 StringVal))  ;
                                                                                                       }
                                                                                        },
                                                                                    {
                                                                                        "floatToInt", (a) => {
                                                                                            return new SpokeObject(
                                                                                                                             (
                                                                                                                             int
                                                                                                                             )
                                                                                                                             a
                                                                                                                                 [
                                                                                                                                     1
                                                                                                                                 ]
                                                                                                                                 .
                                                                                                                                 FloatVal)
                                                                                                                                  ;
                                                                                        }
                                                                                                      },
                                                                                    {
                                                                                        "debug", (a) => {
                                                                                                     return null;
                                                                                                 }
                                                                                        },
                                                                                    {
                                                                                        "writeLine", (a) => {
                                                                                                         for (int index = 1;
                                                                                                              index < a.Length;
                                                                                                              index++) {
                                                                                                             var spokeObject = a[index];
            #if !dontwrite
                                                                                                             Console.Write(
                                                                                                                 spokeObject.ToString() +
                                                                                                                 " ");
            #endif
                                                                                                         }
            #if !dontwrite
                                                                                                         Console.Write("\r\n");
            #endif
                                                                                                         return null;
                                                                                                     }
                                                                                        },
                                                                                    {
                                                                                        "clearConsole", (a) => {
            #if !dontwrite
                                                                                                            Console.Clear();
            #endif
                                                                                                            return null;
                                                                                                        }
                                                                                        },
                                                                                    {
                                                                                        "stringLength", (a) => {
                                                                                            return new SpokeObject(a
                                                                                                                             [
                                                                                                                                 1
                                                                                                                             ]
                                                                                                                             .
                                                                                                                             StringVal
                                                                                                                             .
                                                                                                                             Length);
                                                                                                        }
                                                                                        },
                                                                                    {
                                                                                        "setConsolePosition", (a) => {
            #if !dontwrite
                                                                                                                  Console.SetCursorPosition
                                                                                                                      (a[1].IntVal,
                                                                                                                       a[2].IntVal);
            #endif
                                                                                                                  return null;
                                                                                                              }
                                                                                        },
                                                                                    {
                                                                                        "abs", (a) => {
                                                                                                   switch (a[1].Type) {
                                                                                                       case ObjectType.Int:
                                                                                                           var c = a[1].IntVal;
                                                                                                           return new SpokeObject(Math.Abs(c));

                                                                                                           break;
                                                                                                       case ObjectType.Float:
                                                                                                           var cd = a[1].FloatVal;
                                                                                                           return new SpokeObject(Math.Abs(
                                                                                                                                                cd))
                                                                                                                                                 ;

                                                                                                           break;
                                                                                                       default:
                                                                                                           throw new ArgumentOutOfRangeException
                                                                                                               ();
                                                                                                   }
                                                                                               }
                                                                                        },
                                                                                    {
                                                                                        "nextRandom", (a) => {

                                                                                                          if (a.Length == 2) {
                                                                                                              return new SpokeObject(rad
                                                                                                                                               .
                                                                                                                                               Next
                                                                                                                                               (a
                                                                                                                                                    [
                                                                                                                                                        1
                                                                                                                                                    ]
                                                                                                                                                    .
                                                                                                                                                    IntVal))  ;

                                                                                                          }
                                                                                                          return new SpokeObject(rad
                                                                                                                                           .
                                                                                                                                           Next
                                                                                                                                           (a
                                                                                                                                                [
                                                                                                                                                    1
                                                                                                                                                ]
                                                                                                                                                .
                                                                                                                                                IntVal,
                                                                                                                                            a
                                                                                                                                                [
                                                                                                                                                    2
                                                                                                                                                ]
                                                                                                                                                .
                                                                                                                                                IntVal));
                                                                                                          return null;
                                                                                                      }
                                                                                        },
                                                                                    {
                                                                                        "rand", (a) => {
                                                                                            var vfd = new SpokeObject((
                                                                                                                                float
                                                                                                                                )
                                                                                                                                rad
                                                                                                                                    .
                                                                                                                                    NextDouble
                                                                                                                                    ())
                                                                                                                                     ;
                                                                                                    return vfd;
                                                                                                }
                                                                                        },
                                                                                    {
                                                                                        "wait", (a) => {
            #if !dontwrite
                                                                                                    Thread.Sleep(a[1].IntVal);
            #else
                                                                                                    //Console.WriteLine("Waiting for " + a[1].IntVal + " milliseconds");
            #endif
                                                                                                    return null;
                                                                                                }
                                                                                        },
                                                                                    {
                                                                                        "clone", (a) => {
                                                                                                     return new SpokeObject() {
                                                                                                                                  AnonMethod
                                                                                                                                      =
                                                                                                                                      a[1].
                                                                                                                                      AnonMethod,
                                                                                                                                  BoolVal =
                                                                                                                                      a[1].
                                                                                                                                      BoolVal,
                                                                                                                                  IntVal =
                                                                                                                                      a[1].
                                                                                                                                      IntVal,
                                                                                                                                  FloatVal
                                                                                                                                      =
                                                                                                                                      a[1].
                                                                                                                                      FloatVal,
                                                                                                                                  StringVal
                                                                                                                                      =
                                                                                                                                      a[1].
                                                                                                                                      StringVal,
                                                                                                                                  Variables
                                                                                                                                      =
                                                                                                                                      a[1].
                                                                                                                                      Variables,
                                                                                                                                  ArrayItems
                                                                                                                                      =
                                                                                                                                      a[1].
                                                                                                                                      ArrayItems,
                                                                                                                                  Type =
                                                                                                                                      a[1].
                                                                                                                                      Type,
                                                                                                                                  ByRef =
                                                                                                                                      a[1].
                                                                                                                                      ByRef,
                                                                                                                                  ClassName
                                                                                                                                      =
                                                                                                                                      a[1].
                                                                                                                                      ClassName,
                                                                                                                              };
                                                                                                 }
                                                                                        },
                                                                                    {
                                                                                        "populateUsers", (a) => {

                                                                                                             SpokeObject rt =
                                                                                                                 new SpokeObject(
                                                                                                                     new List<SpokeObject>());
                                                                                                             foreach (
                                                                                                                 var player in playersInGame) {
                                                                                                                 rt.AddArray(new SpokeObject(player.Value));
                                                                                                             }
                                                                                                             return rt;
                                                                                                         }
                                                                                        },
                                                                                    {
                                                                                        "askQuestion", (a) => {

                                                                                                           return new SpokeObject(0);

                                                                                                       }
                                                                                        }
                                                                                };
            vs = new Dictionary<string, SpokeType>() {
                                                         {
                                                             "write", new SpokeType(ObjectType.Void)
                                                             },
                                                         {
                                                             "readLine", new SpokeType(ObjectType.String)
                                                             },
                                                         {
                                                             "read", new SpokeType(ObjectType.String)
                                                             },
                                                         {
                                                             "stringToInt", new SpokeType(ObjectType.Int)
                                                             },
                                                         {
                                                             "floatToInt", new SpokeType(ObjectType.Int)
                                                             },
                                                         {
                                                             "debug", new SpokeType(ObjectType.Void)
                                                             },
                                                         {
                                                             "writeLine", new SpokeType(ObjectType.Void)
                                                             },
                                                         {
                                                             "clearConsole", new SpokeType(ObjectType.Void)
                                                             },
                                                         {
                                                             "stringLength", new SpokeType(ObjectType.Int)
                                                             },
                                                         {
                                                             "setConsolePosition", new SpokeType(ObjectType.Void)
                                                             },
                                                         {
                                                             "abs", new SpokeType(ObjectType.Int)
                                                             },
                                                         {
                                                             "nextRandom", new SpokeType(ObjectType.Int)
                                                             },
                                                         {
                                                             "rand", new SpokeType(ObjectType.Float)
                                                             },
                                                         {
                                                             "wait", new SpokeType(ObjectType.Void)
                                                             },
                                                         {
                                                             "clone", new SpokeType(ObjectType.Object)
                                                             },{
                                                                   "populateUsers", new SpokeType(ObjectType.Array)
                                                                   },{
                                                                         "askQuestion", new SpokeType(ObjectType.Int)
                                                                         }
                                                     };
            return rv;
        }
Exemplo n.º 46
0
 public bool Compare(SpokeObject obj)
 {
     return(Compare(this, obj));
 }