예제 #1
0
        protected static void HandleCodes(LineBuffer Buffer, Object Data)
        {
            Stub Current = (Stub)Data;

            if (Buffer.GetKey(true).Equals("END_CODE"))
            {
                return;
            }

            LineData[]      data = Buffer.Next();
            Type            IType;
            BaseInstruction Ahh;


            if (BaseInstruction.FromName(data[0].Raw) == null)
            {
                data = data.Skip(1).ToArray();
            }

            if ((Ahh = BaseInstruction.FromName(data[0].Raw)) == null)
            {
                MessageBox.Show("Instruction not found error");
                return;
            }

            data  = data.Skip(1).ToArray();
            IType = Ahh.GetType();
            Ahh   = (BaseInstruction)Activator.CreateInstance(IType);

            Ahh.A = (int)data[0].NumVal;
            Ahh.B = (int)data[1].NumVal;

            if (Ahh.HasC())
            {
                Ahh.C = (int)data[2].NumVal;
            }

            Current.Instructions.Add(Ahh);

            HandleCodes(Buffer, Data);
        }
예제 #2
0
        protected static void HandleConstants(LineBuffer Buffer, Object Data)
        {
            Stub Current = (Stub)Data;

            if (Buffer.GetKey(true).Equals("END_CONSTANTS"))
            {
                return;
            }


            if (Buffer.GetKey(true).Equals("TSTRING"))
            {
                LineData[] data = Buffer.Next(false);
                Current.Constants.Constants.Add(ConstantIndex++, new Constant(data.Length == 1 ? "" : data[1].Raw));
                HandleConstants(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("TNUMBER"))
            {
                Current.Constants.Constants.Add(ConstantIndex++, new Constant(Buffer.GetValue().NumVal));
                HandleConstants(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("TBOOLEAN"))
            {
                Current.Constants.Constants.Add(ConstantIndex++, new Constant(Buffer.GetValue().BoolVal));
                HandleConstants(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("TNIL"))
            {
                Buffer.GetValue();
                Current.Constants.Constants.Add(ConstantIndex++, new Constant());
                HandleConstants(Buffer, Data);
                return;
            }
        }
예제 #3
0
        protected static void HandleMethod(LineBuffer Buffer, Object Data)
        {
            Stub Current = (Stub)Data;

            if (Buffer.GetKey(true).Equals("START_DBG"))
            {
                if (!ReadBlock(Buffer, "DBG", HandleDebug, Data))
                {
                    return;
                }
                HandleMethod(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("START_CONSTANTS"))
            {
                ConstantIndex = 0;
                if (!ReadBlock(Buffer, "CONSTANTS", HandleConstants, Data))
                {
                    return;
                }
                HandleMethod(Buffer, Data);
                return;
            }


            if (Buffer.GetKey(true).Equals("START_CODE"))
            {
                if (!ReadBlock(Buffer, "CODE", HandleCodes, Data))
                {
                    return;
                }
                HandleMethod(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("START_CLOSURE"))
            {
                if (!ReadBlock(Buffer, "CLOSURE", HandleClosure, new Stub(Current, (int)Buffer.Next(true)[1].NumVal)))
                {
                    return;
                }

                HandleMethod(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("FLAGS"))
            {
                //TODO assert
                Current.Flags = (int)Buffer.GetValue().NumVal;
                HandleMethod(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("PARAMS"))
            {
                //TODO assert
                Current.Parameters = (int)Buffer.GetValue().NumVal;
                HandleMethod(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("UPVALS"))
            {
                //TODO assert
                Current.UpVals = (int)Buffer.GetValue().NumVal;
                HandleMethod(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("REGCNT"))
            {
                //TODO assert
                Current.Registers = (int)Buffer.GetValue().NumVal;
                HandleMethod(Buffer, Data);
                return;
            }
        }
예제 #4
0
 protected static void HandleDebug(LineBuffer Buffer, Object Data)
 {
     Buffer.Next();
     Buffer.Next();
 }