Exemplo n.º 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);
        }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
 private void EmitIVar(eVM_Instruction _inst, int _var)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 5));
     VMB.Buffer.WriteInteger(_var);
 }
Exemplo n.º 5
0
 private void EmitI(eVM_Instruction _inst, long _val)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 3));
     VMB.Buffer.WriteLong(_val);
 }
Exemplo n.º 6
0
 private void EmitI(eVM_Instruction _inst, bool _val)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 4));
     VMB.Buffer.WriteBoolean(_val);
 }
Exemplo n.º 7
0
 private void EmitI(eVM_Instruction _inst, float _val)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 1));
     VMB.Buffer.WriteSingle(_val);
 }
Exemplo n.º 8
0
 private void EmitI(eVM_Instruction _inst, double _val)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 0));
     VMB.Buffer.WriteDouble(_val);
 }
Exemplo n.º 9
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)));
 }
Exemplo n.º 10
0
 private void Emit(eVM_Instruction _inst, eVM_Type _type1)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, (int)_type1));
 }
Exemplo n.º 11
0
 private void EmitBreak(ushort _v)
 {
     VMB.Add(VMBuffer.EncodeInstructionArg(255, 15) | _v);
 }