Esempio n. 1
0
        public Pop(Int32 _instruction, Game _game, LCode _code, BinaryReader _reader) : base(_instruction)
        {
            this.ArgTo   = (LArgumentType)(this.Argument & 0xF);
            this.ArgFrom = (LArgumentType)((this.Argument >> 4) & 0xF);
            switch (this.ArgTo)
            {
            case LArgumentType.Variable: {
                Int32 _varOffset = (int)((_code.Base + _reader.BaseStream.Position)) - 4;
                this.Variable = _game.Variables[_game.VariableMapping[_varOffset]];
                _reader.ReadInt32();
                break;
            }

            default: {
                throw new Exception(String.Format("Could not pop from {0} to {1}", this.ArgTo, this.ArgFrom));
            }
            }
        }
Esempio n. 2
0
        public Push(Int32 _instruction, Game _game, LCode _code, BinaryReader _reader) : base(_instruction)
        {
            this.IsArray = false;
            this.Type    = (LArgumentType)this.Argument;
            switch (this.Type)
            {
            case LArgumentType.Error: {
                this.Value = new LValue(LType.Number, (double)this.Data);
                break;
            }

            case LArgumentType.Integer: {
                this.Value = new LValue(LType.Number, (double)_reader.ReadInt32());
                break;
            }

            case LArgumentType.Long: {
                this.Value = new LValue(LType.Number, (double)_reader.ReadInt64());
                break;
            }

            case LArgumentType.Double: {
                this.Value = new LValue(LType.Number, (double)_reader.ReadDouble());
                break;
            }

            case LArgumentType.String: {
                this.Value = new LValue(LType.String, (string)_game.StringMapping[_reader.ReadInt32()].Value);
                break;
            }

            case LArgumentType.Variable: {
                this.Variable = _game.Variables[_game.VariableMapping[(int)((_code.Base + _reader.BaseStream.Position)) - 4]];
                _reader.ReadInt32();
                break;
            }

            default: {
                throw new Exception(String.Format("Could not parse unimplemented push type {0}", this.Type));
            }
            }
        }