Пример #1
0
        private void EmitI(eVM_Instruction _inst, string _val)
        {
            VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 6));
            int count = Strings.Count;

            Strings.Add(_val);
            StringPatches.Add(VMB.Buffer.Position);
            VMB.Buffer.WriteInteger(count);
        }
Пример #2
0
 public void Patch()
 {
     foreach (int patch in Patches)
     {
         long address = Address;
         int  @int    = VMB.GetInt(patch);
         int  value   = VMBuffer.EncodeInstructionBranch(VMBuffer.GetInstruction(@int), patch);
         VMB.SetInt(patch, value);
     }
     Patches.Clear();
 }
Пример #3
0
 private void Emit(eVM_Instruction _inst, VMLabel _label)
 {
     if (!_label.Marked)
     {
         _label.Patches.Add((int)VMB.Buffer.Position);
         VMB.Add(VMBuffer.EncodeInstructionBranch((int)_inst, 0));
     }
     else
     {
         long num = _label.Address - VMB.Buffer.Position;
         VMB.Add(VMBuffer.EncodeInstructionBranch((int)_inst, (int)num));
     }
 }
Пример #4
0
        private void CompileConstant(GMLToken _tok)
        {
            switch (_tok.Value.Kind)
            {
            case eKind.eConstant:
                Error("constant token", _tok);
                break;

            case eKind.eNone:
                Error("None constant token", _tok);
                break;

            case eKind.eNumber:
            {
                double num = (long)_tok.Value.ValueI;
                if (num == _tok.Value.ValueI)
                {
                    long num2 = (long)_tok.Value.ValueI;
                    if (num2 > int.MaxValue || num2 < int.MinValue)
                    {
                        EmitI(eVM_Instruction.eVMI_PUSH, num2);
                        TypeStack.Push(eVM_Type.eVMT_Long);
                    }
                    else if (num2 > 32767 || num2 < -32768)
                    {
                        EmitI(eVM_Instruction.eVMI_PUSH, (int)num2);
                        TypeStack.Push(eVM_Type.eVMT_Int);
                    }
                    else
                    {
                        VMB.Add(VMBuffer.EncodeInstructionArg(192, 15) | (int)(num2 & 0xFFFF));
                        TypeStack.Push(eVM_Type.eVMT_Int);
                    }
                }
                else
                {
                    EmitI(eVM_Instruction.eVMI_PUSH, _tok.Value.ValueI);
                    TypeStack.Push(eVM_Type.eVMT_Double);
                }
                break;
            }

            case eKind.eString:
                EmitI(eVM_Instruction.eVMI_PUSH, _tok.Value.ValueS);
                TypeStack.Push(eVM_Type.eVMT_String);
                break;
            }
        }
    public MainWindow()
    {
        InitializeComponent();
        var rnd = new Random();
        var vm  = new VM();

        this.DataContext = vm;
        //enum "A"
        foreach (var a in Enum.GetNames(typeof(A)))
        {
            var vma = new VMA();
            vma.Title = a;
            vm.AItems.Add(vma);
            //enum "B"
            foreach (var b in Enum.GetNames(typeof(B)))
            {
                var vmb = new VMB();
                vmb.Title = b;
                vmb.Value = rnd.Next(1000).ToString();
                vma.BItems.Add(vmb);
            }
        }
    }
Пример #6
0
 private void EmitIVar(eVM_Instruction _inst, int _var, eVM_Type _target)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, VMBuffer.EncodeArgDouble(5, (int)_target)));
     VMB.Buffer.WriteInteger(_var);
 }
Пример #7
0
 private void EmitIVar(eVM_Instruction _inst, int _var)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 5));
     VMB.Buffer.WriteInteger(_var);
 }
Пример #8
0
 private void EmitI(eVM_Instruction _inst, bool _val)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 4));
     VMB.Buffer.WriteBoolean(_val);
 }
Пример #9
0
 private void EmitI(eVM_Instruction _inst, long _val)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 3));
     VMB.Buffer.WriteLong(_val);
 }
Пример #10
0
 private void EmitI(eVM_Instruction _inst, float _val)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 1));
     VMB.Buffer.WriteSingle(_val);
 }
Пример #11
0
 private void EmitI(eVM_Instruction _inst, double _val)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 0));
     VMB.Buffer.WriteDouble(_val);
 }
Пример #12
0
 private void Emit(eVM_Instruction _inst, eVM_Type _type1, eVM_Type _type2)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, VMBuffer.EncodeArgDouble((int)_type1, (int)_type2)));
 }
Пример #13
0
 private void Emit(eVM_Instruction _inst, eVM_Type _type1)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, (int)_type1));
 }
Пример #14
0
 private void EmitBreak(ushort _v)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg(255, 15) | _v);
 }