Esempio n. 1
0
        // Generates code to compute and push the address of a named variable.
        // vname is the program phrase that names this variable.
        // currentLevel is the routine level where the vname occurs.
        // frameSize is the anticipated size of the local stack frame when
        // the variable is addressed at run-time.

        void EncodeFetchAddress(Vname vname, Frame frame)
        {
            var baseObject = vname.Visit(this, frame) as AddressableEntity;

            // If indexed = true, code will have been generated to load an index
            // value.
            baseObject.EncodeFetchAddress(_emitter, frame, vname);
        }
Esempio n. 2
0
 public override void EncodeFetchAddress(Emitter emitter, Frame frame, Vname vname)
 {
     emitter.Emit(OpCode.LOADA, 0, frame.DisplayRegister(Address),
                  Address.Displacement + vname.Offset);
     if (vname.IsIndexed)
     {
         emitter.Emit(OpCode.CALL, Register.SB, Register.PB, Primitive.ADD);
     }
 }
Esempio n. 3
0
        // Generates code to fetch the value of a named constant or variable
        // and push it on to the stack.
        // currentLevel is the routine level where the vname occurs.
        // frameSize is the anticipated size of the local stack frame when
        // the constant or variable is fetched at run-time.
        // valSize is the size of the constant or variable's value.

        void EncodeFetch(Vname vname, Frame frame, int valSize)
        {
            IFetchableEntity baseObject = vname.Visit(this, frame);

            // If indexed = true, code will have been generated to load an index
            // value.
            if (valSize > 255)
            {
                _errorReporter.ReportRestriction("can't load values larger than 255 words");
                valSize = 255; // to allow code generation to continue
            }
            baseObject.EncodeFetch(_emitter, frame, valSize, vname);
        }
Esempio n. 4
0
 public void EncodeFetch(Emitter emitter, Frame frame, int size, Vname vname)
 {
     if (vname.IsIndexed)
     {
         emitter.Emit(OpCode.LOADA, 0, frame.DisplayRegister(_address),
                      _address.Displacement + vname.Offset);
         emitter.Emit(OpCode.CALL, Register.SB, Register.PB, Primitive.ADD);
         emitter.Emit(OpCode.LOADI, size, 0, 0);
     }
     else
     {
         emitter.Emit(OpCode.LOAD, size, frame.DisplayRegister(_address),
                      _address.Displacement + vname.Offset);
     }
 }
Esempio n. 5
0
 public override void EncodeStore(Emitter emitter, Frame frame, int size, Vname vname)
 {
     if (vname.IsIndexed)
     {
         emitter.Emit(OpCode.LOADA, 0, frame.DisplayRegister(Address),
                      Address.Displacement + vname.Offset);
         emitter.Emit(OpCode.CALL, Register.SB, Register.PB, Primitive.ADD);
         emitter.Emit(OpCode.STOREI, size, 0, 0);
     }
     else
     {
         emitter.Emit(OpCode.STORE, size, frame.DisplayRegister(Address),
                      Address.Displacement + vname.Offset);
     }
 }
Esempio n. 6
0
        public override void EncodeFetchAddress(Emitter emitter, Frame frame, Vname vname)
        {
            emitter.Emit(OpCode.LOAD, Machine.AddressSize, frame.DisplayRegister(_address),
                         _address.Displacement);
            if (vname.IsIndexed)
            {
                emitter.Emit(OpCode.CALL, Register.SB, Register.PB, Primitive.ADD);
            }

            int offset = vname.Offset;

            if (offset != 0)
            {
                emitter.Emit(OpCode.LOADL, offset);
                emitter.Emit(OpCode.CALL, Register.SB, Register.PB, Primitive.ADD);
            }
        }
 public abstract void EncodeAssign(Emitter emitter, Frame frame, int size, Vname vname);
Esempio n. 8
0
 public VarActualParameter(Vname vname, SourcePosition position)
     : base(position)
 {
     _vname = vname;
 }
Esempio n. 9
0
 public void EncodeFetch(Emitter emitter, Frame frame, int size, Vname vname)
 {
     // presumably offset = 0 and indexed = false
     emitter.Emit(OpCode.LOADL, 0, 0, _value);
 }
Esempio n. 10
0
 public override void EncodeFetch(Emitter emitter, Frame frame, int size, Vname vname)
 {
     emitter.Emit(OpCode.LOAD, Machine.AddressSize, frame.DisplayRegister(_address), _address.Displacement);
     emitter.Emit(OpCode.LOADI, size);
 }
Esempio n. 11
0
 public AssignCommand(Vname vname, Expression expression, SourcePosition position)
     : base(position)
 {
     _vname      = vname;
     _expression = expression;
 }
Esempio n. 12
0
 public VnameExpression(Vname vname, SourcePosition position)
     : base(position)
 {
     _vname = vname;
 }
Esempio n. 13
0
 public override void EncodeFetchAddress(Emitter emitter, Frame frame, Vname vname)
 {
     emitter.Emit(OpCode.LOADA, Size, frame.DisplayRegister(Address), Address.Displacement);
 }
Esempio n. 14
0
 public override void EncodeAssign(Emitter emitter, Frame frame, int size, Vname vname)
 {
     emitter.Emit(OpCode.STORE, size, frame.DisplayRegister(Address), Address.Displacement);
 }
 public abstract void EncodeFetchAddress(Emitter emitter, Frame frame, Vname vname);
 public abstract void EncodeFetch(Emitter emitter, Frame frame, int size, Vname vname);
Esempio n. 17
0
 public void EncodeFetch(Emitter emitter, Frame frame, int size, Vname vname)
 {
     emitter.Emit(OpCode.LOADL, 0, 0, _value);
     //emitter.Emit(xxxxxx, 0, 0, _value);
 }