Пример #1
0
        void fetchMember (CodeContainer& code, Literals& literals, char localType,
            const std::string& name, const std::string& id, bool global)
        {
            int index = literals.addString (name);

            opPushInt (code, index);

            index = literals.addString (id);

            opPushInt (code, index);

            switch (localType)
            {
                case 'f':

                    opFetchMemberFloat (code, global);
                    break;

                case 's':

                    opFetchMemberShort (code, global);
                    break;

                case 'l':

                    opFetchMemberLong (code, global);
                    break;

                default:

                    assert (0);
            }
        }
Пример #2
0
        void assignToMember (CodeContainer& code, Literals& literals, char localType,
            const std::string& name, const std::string& id, const CodeContainer& value,
            char valueType, bool global)
        {
            int index = literals.addString (name);

            opPushInt (code, index);

            index = literals.addString (id);

            opPushInt (code, index);

            std::copy (value.begin(), value.end(), std::back_inserter (code));

            if (localType!=valueType)
            {
                if (localType=='f' && (valueType=='l' || valueType=='s'))
                {
                    opIntToFloat (code);
                }
                else if ((localType=='l' || localType=='s') && valueType=='f')
                {
                    opFloatToInt (code);
                }
            }

            switch (localType)
            {
                case 'f':

                    opStoreMemberFloat (code, global);
                    break;

                case 's':

                    opStoreMemberShort (code, global);
                    break;

                case 'l':

                    opStoreMemberLong (code, global);
                    break;

                default:

                    assert (0);
            }
        }
Пример #3
0
        void fetchLocal (CodeContainer& code, char localType, int localIndex)
        {
            opPushInt (code, localIndex);

            switch (localType)
            {
                case 'f':

                    opFetchLocalFloat (code);
                    break;

                case 's':

                    opFetchLocalShort (code);
                    break;

                case 'l':

                    opFetchLocalLong (code);
                    break;

                default:

                    assert (0);
            }
        }
Пример #4
0
        void fetchGlobal (CodeContainer& code, Literals& literals, char localType,
            const std::string& name)
        {
            int index = literals.addString (name);

            opPushInt (code, index);

            switch (localType)
            {
                case 'f':

                    opFetchGlobalFloat (code);
                    break;

                case 's':

                    opFetchGlobalShort (code);
                    break;

                case 'l':

                    opFetchGlobalLong (code);
                    break;

                default:

                    assert (0);
            }
        }
Пример #5
0
        void report (CodeContainer& code, Literals& literals, const std::string& message)
        {
            int index = literals.addString (message);

            opPushInt (code, index);
            opReport (code);
        }
Пример #6
0
        void message (CodeContainer& code, Literals& literals, const std::string& message,
            int buttons)
        {
            assert (buttons==0);

            int index = literals.addString (message);
            
            opPushInt (code, index);
            opMessageBox (code, buttons);
        }
Пример #7
0
 void disable (CodeContainer& code, Literals& literals, const std::string& id)
 {
     if (id.empty())
     {
         opDisable (code);
     }
     else
     {
         int index = literals.addString (id);
         opPushInt (code, index);
         opDisableExplicit (code);
     }
 }
Пример #8
0
        void message (CodeContainer& code, Literals& literals, const std::string& message,
            int buttons)
        {
            assert (buttons>=0);

            if (buttons>=256)
                throw std::runtime_error ("A message box can't have more than 255 buttons");

            int index = literals.addString (message);

            opPushInt (code, index);
            opMessageBox (code, buttons);
        }
Пример #9
0
        void assignToLocal (CodeContainer& code, char localType,
            int localIndex, const CodeContainer& value, char valueType)
        {
            opPushInt (code, localIndex);

            std::copy (value.begin(), value.end(), std::back_inserter (code));

            if (localType!=valueType)
            {
                if (localType=='f' && valueType=='l')
                {
                    opIntToFloat (code);
                }
                else if ((localType=='l' || localType=='s') && valueType=='f')
                {
                    opFloatToInt (code);
                }
            }

            switch (localType)
            {
                case 'f':

                    opStoreLocalFloat (code);
                    break;

                case 's':

                    opStoreLocalShort (code);
                    break;

                case 'l':

                    opStoreLocalLong (code);
                    break;

                default:

                    assert (0);
            }
        }
Пример #10
0
 void pushString (CodeContainer& code, Literals& literals, const std::string& value)
 {
     int index = literals.addString (value);
     opPushInt (code, index);
 }
Пример #11
0
 void pushFloat (CodeContainer& code, Literals& literals, float value)
 {
     int index = literals.addFloat (value);
     opPushInt (code, index);
     opFetchFloatLiteral (code);
 }
Пример #12
0
 void pushInt (CodeContainer& code, Literals& literals, int value)
 {
     int index = literals.addInteger (value);
     opPushInt (code, index);
     opFetchIntLiteral (code);
 }