Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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;
        }