コード例 #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(Identifier identifier, Frame frame)
        {
            AddressableEntity baseObject = identifier.Declaration.Entity as AddressableEntity;

            // If indexed = true, code will have been generated to load an index
            // value.
            baseObject.EncodeFetchAddress(emitter, frame, identifier);
        }
コード例 #2
0
        // REGISTERS

        // 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 EncodeAssign(Identifier identifier, Frame frame, int valSize)
        {
            AddressableEntity baseObject = identifier.Declaration.Entity as AddressableEntity;

            // If indexed = true, code will have been generated to load an index
            // value.
            if (valSize > 255)
            {
                errorReporter.ReportMessage("can't store values larger than 255 words");
                valSize = 255; // to allow code generation to continue
            }
            baseObject.EncodeAssign(emitter, frame, valSize, identifier);
        }