Changeset 3345 in CLRX


Ignore:
Timestamp:
Sep 8, 2017, 9:07:44 PM (4 months ago)
Author:
matszpk
Message:

CLRadeonExtender: Asm: Remove obsolete definition 'Assembler& asmr = *this;' in code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdasm/Assembler.cpp

    r3344 r3345  
    3232#include <CLRX/amdasm/Assembler.h>
    3333#include "AsmInternals.h"
     34
     35#define THIS_FAIL_BY_ERROR(PLACE, STRING) \
     36    { \
     37        printError(PLACE, STRING); \
     38        return false; \
     39    }
     40
     41#define THIS_NOTGOOD_BY_ERROR(PLACE, STRING) \
     42    { \
     43        printError(PLACE, STRING); \
     44        good = false; \
     45    }
    3446
    3547using namespace CLRX;
     
    662674bool Assembler::parseString(std::string& strarray, const char*& linePtr)
    663675{
    664     Assembler& asmr = *this; // for error
    665676    const char* end = line+lineSize;
    666677    const char* startPlace = linePtr;
     
    670681    {
    671682        while (linePtr != end && !isSpace(*linePtr) && *linePtr != ',') linePtr++;
    672         ASM_FAIL_BY_ERROR(startPlace, "Expected string");
     683        THIS_FAIL_BY_ERROR(startPlace, "Expected string")
    673684    }
    674685    linePtr++;
     
    681692            uint16_t value;
    682693            if (linePtr == end)
    683                 ASM_FAIL_BY_ERROR(startPlace, "Unterminated character of string")
     694                THIS_FAIL_BY_ERROR(startPlace, "Unterminated character of string")
    684695            if (*linePtr == 'x')
    685696            {   // hex
     
    687698                linePtr++;
    688699                if (linePtr == end)
    689                     ASM_FAIL_BY_ERROR(startPlace, "Unterminated character of string")
     700                    THIS_FAIL_BY_ERROR(startPlace, "Unterminated character of string")
    690701                value = 0;
    691702                if (isXDigit(*linePtr))
     
    704715                    }
    705716                else
    706                     ASM_FAIL_BY_ERROR(charPlace, "Expected hexadecimal character code")
     717                    THIS_FAIL_BY_ERROR(charPlace, "Expected hexadecimal character code")
    707718                value &= 0xff;
    708719            }
     
    717728                    value = (value<<3) + uint64_t(*linePtr-'0');
    718729                    if (value > 255)
    719                         ASM_FAIL_BY_ERROR(charPlace, "Octal code out of range")
     730                        THIS_FAIL_BY_ERROR(charPlace, "Octal code out of range")
    720731                }
    721732            }
     
    765776    }
    766777    if (linePtr == end)
    767         ASM_FAIL_BY_ERROR(startPlace, "Unterminated string")
     778        THIS_FAIL_BY_ERROR(startPlace, "Unterminated string")
    768779    linePtr++;
    769780    return true;
     
    772783bool Assembler::parseLiteral(uint64_t& value, const char*& linePtr)
    773784{
    774     Assembler& asmr = *this; // for error
    775785    const char* startPlace = linePtr;
    776786    const char* end = line+lineSize;
     
    779789        linePtr++;
    780790        if (linePtr == end)
    781             ASM_FAIL_BY_ERROR(startPlace, "Unterminated character literal")
     791            THIS_FAIL_BY_ERROR(startPlace, "Unterminated character literal")
    782792        if (*linePtr == '\'')
    783             ASM_FAIL_BY_ERROR(startPlace, "Empty character literal")
     793            THIS_FAIL_BY_ERROR(startPlace, "Empty character literal")
    784794       
    785795        if (*linePtr != '\\')
     
    787797            value = *linePtr++;
    788798            if (linePtr == end || *linePtr != '\'')
    789                 ASM_FAIL_BY_ERROR(startPlace, "Missing ''' at end of literal")
     799                THIS_FAIL_BY_ERROR(startPlace, "Missing ''' at end of literal")
    790800            linePtr++;
    791801            return true;
     
    795805            linePtr++;
    796806            if (linePtr == end)
    797                 ASM_FAIL_BY_ERROR(startPlace, "Unterminated character literal")
     807                THIS_FAIL_BY_ERROR(startPlace, "Unterminated character literal")
    798808            if (*linePtr == 'x')
    799809            {   // hex
    800810                linePtr++;
    801811                if (linePtr == end)
    802                     ASM_FAIL_BY_ERROR(startPlace, "Unterminated character literal")
     812                    THIS_FAIL_BY_ERROR(startPlace, "Unterminated character literal")
    803813                value = 0;
    804814                if (isXDigit(*linePtr))
     
    817827                    }
    818828                else
    819                     ASM_FAIL_BY_ERROR(startPlace, "Expected hexadecimal character code")
     829                    THIS_FAIL_BY_ERROR(startPlace, "Expected hexadecimal character code")
    820830                value &= 0xff;
    821831            }
     
    827837                {
    828838                    if (!isODigit(*linePtr))
    829                         ASM_FAIL_BY_ERROR(startPlace, "Expected octal character code");
     839                        THIS_FAIL_BY_ERROR(startPlace, "Expected octal character code")
    830840                    value = (value<<3) + uint64_t(*linePtr-'0');
    831841                    if (value > 255)
    832                         ASM_FAIL_BY_ERROR(startPlace, "Octal code out of range")
     842                        THIS_FAIL_BY_ERROR(startPlace, "Octal code out of range")
    833843                }
    834844            }
     
    873883            }
    874884            if (linePtr == end || *linePtr != '\'')
    875                 ASM_FAIL_BY_ERROR(startPlace, "Missing ''' at end of literal")
     885                THIS_FAIL_BY_ERROR(startPlace, "Missing ''' at end of literal")
    876886            linePtr++;
    877887            return true;
     
    960970bool Assembler::parseMacroArgValue(const char*& string, std::string& outStr)
    961971{
    962     Assembler& asmr = *this;
    963972    const char* end = line+lineSize;
    964973    bool firstNonSpace = false;
     
    10051014        }
    10061015        if (string == end) /* if unterminated string */
    1007             ASM_FAIL_BY_ERROR(string, "Unterminated quoted string")
     1016            THIS_FAIL_BY_ERROR(string, "Unterminated quoted string")
    10081017        string++;
    10091018        return true;
     
    10211030        }
    10221031        if (string == end)
    1023             ASM_FAIL_BY_ERROR(string, "Unterminated quoted string")
     1032            THIS_FAIL_BY_ERROR(string, "Unterminated quoted string")
    10241033        string++;
    10251034        return true;
     
    10541063bool Assembler::setSymbol(AsmSymbolEntry& symEntry, uint64_t value, cxuint sectionId)
    10551064{
    1056     Assembler& asmr = *this;
    10571065    symEntry.second.value = value;
    10581066    symEntry.second.expression = nullptr;
     
    11291137                    case ASMXTGT_DATA8:
    11301138                        if (sectionId != ASMSECT_ABS)
    1131                             ASM_NOTGOOD_BY_ERROR(expr->getSourcePos(),
     1139                            THIS_NOTGOOD_BY_ERROR(expr->getSourcePos(),
    11321140                                   "Relative value is illegal in data expressions")
    11331141                        else
     
    11401148                    case ASMXTGT_DATA16:
    11411149                        if (sectionId != ASMSECT_ABS)
    1142                             ASM_NOTGOOD_BY_ERROR(expr->getSourcePos(),
     1150                            THIS_NOTGOOD_BY_ERROR(expr->getSourcePos(),
    11431151                                   "Relative value is illegal in data expressions")
    11441152                        else
     
    11511159                    case ASMXTGT_DATA32:
    11521160                        if (sectionId != ASMSECT_ABS)
    1153                             ASM_NOTGOOD_BY_ERROR(expr->getSourcePos(),
     1161                            THIS_NOTGOOD_BY_ERROR(expr->getSourcePos(),
    11541162                                   "Relative value is illegal in data expressions")
    11551163                        else
     
    11621170                    case ASMXTGT_DATA64:
    11631171                        if (sectionId != ASMSECT_ABS)
    1164                             ASM_NOTGOOD_BY_ERROR(expr->getSourcePos(),
     1172                            THIS_NOTGOOD_BY_ERROR(expr->getSourcePos(),
    11651173                                   "Relative value is illegal in data expressions")
    11661174                        else
     
    11701178                    case ASMXTGT_CODEFLOW:
    11711179                        if (target.sectionId != sectionId)
    1172                             ASM_NOTGOOD_BY_ERROR(expr->getSourcePos(),
     1180                            THIS_NOTGOOD_BY_ERROR(expr->getSourcePos(),
    11731181                                            "Jump over current section!")
    11741182                        else
     
    12061214             const char* linePtr, bool reassign, bool baseExpr)
    12071215{
    1208     Assembler& asmr = *this;
    12091216    skipSpacesToEnd(linePtr, line+lineSize);
    12101217    size_t symNameLength = symbolName.size();
    12111218    if (symNameLength >= 3 && symbolName.compare(symNameLength-3, 3, "::.")==0)
    1212         ASM_FAIL_BY_ERROR(symbolPlace, "Symbol '.' can be only in global scope")
     1219        THIS_FAIL_BY_ERROR(symbolPlace, "Symbol '.' can be only in global scope")
    12131220   
    12141221    if (linePtr!=line+lineSize && *linePtr=='%')
    12151222    {
    12161223        if (symbolName == ".")
    1217             ASM_FAIL_BY_ERROR(symbolPlace, "Symbol '.' requires a resolved expression")
     1224            THIS_FAIL_BY_ERROR(symbolPlace, "Symbol '.' requires a resolved expression")
    12181225        initializeOutputFormat();
    12191226        ++linePtr;
     
    12241231        skipSpacesToEnd(linePtr, line+lineSize);
    12251232        if (linePtr != line+lineSize)
    1226             ASM_FAIL_BY_ERROR(linePtr, "Garbages at end of expression")
     1233            THIS_FAIL_BY_ERROR(linePtr, "Garbages at end of expression")
    12271234       
    12281235        std::pair<AsmSymbolEntry*, bool> res =
     
    12871294   
    12881295    if (linePtr != line+lineSize)
    1289         ASM_FAIL_BY_ERROR(linePtr, "Garbages at end of expression")
     1296        THIS_FAIL_BY_ERROR(linePtr, "Garbages at end of expression")
    12901297    if (expr->isEmpty()) // empty expression, we treat as error
    1291         ASM_FAIL_BY_ERROR(exprPlace, "Expected assignment expression")
     1298        THIS_FAIL_BY_ERROR(exprPlace, "Expected assignment expression")
    12921299   
    12931300    if (symbolName == ".")
     
    13001307            return assignOutputCounter(symbolPlace, value, sectionId);
    13011308        else
    1302             ASM_FAIL_BY_ERROR(symbolPlace, "Symbol '.' requires a resolved expression")
     1309            THIS_FAIL_BY_ERROR(symbolPlace, "Symbol '.' requires a resolved expression")
    13031310    }
    13041311   
     
    13511358            cxuint sectionId, cxbyte fillValue)
    13521359{
    1353     Assembler& asmr = *this;
    13541360    initializeOutputFormat();
    13551361    if (currentSection != sectionId && sectionId != ASMSECT_ABS)
    1356         ASM_FAIL_BY_ERROR(symbolPlace, "Illegal section change for symbol '.'")
     1362        THIS_FAIL_BY_ERROR(symbolPlace, "Illegal section change for symbol '.'")
    13571363    if (currentSection != ASMSECT_ABS && int64_t(currentOutPos) > int64_t(value))
    13581364        /* check attempt to move backwards only for section that is not absolute */
    1359         ASM_FAIL_BY_ERROR(symbolPlace, "Attempt to move backwards")
     1365        THIS_FAIL_BY_ERROR(symbolPlace, "Attempt to move backwards")
    13601366    if (!isAddressableSection())
    1361         ASM_FAIL_BY_ERROR(symbolPlace,
     1367        THIS_FAIL_BY_ERROR(symbolPlace,
    13621368                   "Change output counter inside non-addressable section is illegal")
    13631369    if (currentSection==ASMSECT_ABS && fillValue!=0)
     
    14541460               bool& included)
    14551461{
    1456     Assembler& asmr = *this;
    14571462    if (clauseType == AsmClauseType::MACRO || clauseType == AsmClauseType::IF ||
    14581463        clauseType == AsmClauseType::REPEAT)
     
    14821487            return false;
    14831488        case AsmClauseType::MACRO:
    1484             ASM_FAIL_BY_ERROR(string, clauseType == AsmClauseType::ELSEIF ?
     1489            THIS_FAIL_BY_ERROR(string, clauseType == AsmClauseType::ELSEIF ?
    14851490                        "No '.if' before '.elseif' inside macro" :
    14861491                        "No '.if' before '.else' inside macro")
    14871492        case AsmClauseType::REPEAT:
    1488             ASM_FAIL_BY_ERROR(string, clauseType == AsmClauseType::ELSEIF ?
     1493            THIS_FAIL_BY_ERROR(string, clauseType == AsmClauseType::ELSEIF ?
    14891494                        "No '.if' before '.elseif' inside repetition" :
    14901495                        "No '.if' before '.else' inside repetition")
     
    15031508bool Assembler::popClause(const char* string, AsmClauseType clauseType)
    15041509{
    1505     Assembler& asmr = *this;
    15061510    if (clauses.empty())
    15071511    {   // no clauses
     
    15211525        case AsmClauseType::ELSEIF:
    15221526            if (clauseType == AsmClauseType::MACRO)
    1523                 ASM_FAIL_BY_ERROR(string, "Ending macro across conditionals")
     1527                THIS_FAIL_BY_ERROR(string, "Ending macro across conditionals")
    15241528            if (clauseType == AsmClauseType::REPEAT)
    1525                 ASM_FAIL_BY_ERROR(string, "Ending repetition across conditionals")
     1529                THIS_FAIL_BY_ERROR(string, "Ending repetition across conditionals")
    15261530            break;
    15271531        case AsmClauseType::MACRO:
    15281532            if (clauseType == AsmClauseType::REPEAT)
    1529                 ASM_FAIL_BY_ERROR(string, "Ending repetition across macro")
     1533                THIS_FAIL_BY_ERROR(string, "Ending repetition across macro")
    15301534            if (clauseType == AsmClauseType::IF)
    1531                 ASM_FAIL_BY_ERROR(string, "Ending conditional across macro")
     1535                THIS_FAIL_BY_ERROR(string, "Ending conditional across macro")
    15321536            break;
    15331537        case AsmClauseType::REPEAT:
    15341538            if (clauseType == AsmClauseType::MACRO)
    1535                 ASM_FAIL_BY_ERROR(string, "Ending macro across repetition")
     1539                THIS_FAIL_BY_ERROR(string, "Ending macro across repetition")
    15361540            if (clauseType == AsmClauseType::IF)
    1537                 ASM_FAIL_BY_ERROR(string, "Ending conditional across repetition")
     1541                THIS_FAIL_BY_ERROR(string, "Ending conditional across repetition")
    15381542            break;
    15391543        default:
     
    19261930bool Assembler::includeFile(const char* pseudoOpPlace, const std::string& filename)
    19271931{
    1928     Assembler& asmr = *this;
    19291932    if (inclusionLevel == 500)
    1930         ASM_FAIL_BY_ERROR(pseudoOpPlace, "Inclusion level is greater than 500")
     1933        THIS_FAIL_BY_ERROR(pseudoOpPlace, "Inclusion level is greater than 500")
    19311934    std::unique_ptr<AsmInputFilter> newInputFilter(new AsmStreamInputFilter(
    19321935                getSourcePos(pseudoOpPlace), filename));
Note: See TracChangeset for help on using the changeset viewer.