Refactor inter instrction operator handling

This commit is contained in:
drmortalwombat 2021-10-08 09:07:01 +02:00
parent e7231e27e0
commit 60489bb79e
10 changed files with 1004 additions and 943 deletions

View File

@ -4,16 +4,12 @@ int asum(int a, int b)
{ {
__asm __asm
{ {
ldy #a
clc clc
lda (fp), y lda a
ldy #b adc b
adc (fp), y
sta accu sta accu
ldy #a + 1 lda a + 1
lda (fp), y adc b + 1
ldy #b + 1
adc (fp), y
sta accu + 1 sta accu + 1
} }
} }
@ -24,16 +20,12 @@ int bsum(int a, int b)
__asm __asm
{ {
ldy #a
clc clc
lda (fp), y lda a
ldy #b adc b
adc (fp), y
sta accu sta accu
ldy #a + 1 lda a + 1
lda (fp), y adc b + 1
ldy #b + 1
adc (fp), y
sta accu + 1 sta accu + 1
} }
} }

View File

@ -4,9 +4,7 @@
void putchar(char c) void putchar(char c)
{ {
__asm { __asm {
ldy #2 lda c
lda (fp), y
cmp #10
bne w1 bne w1
lda #13 lda #13
w1: w1:
@ -27,14 +25,8 @@ char getchar(void)
void puts(const char * str) void puts(const char * str)
{ {
__asm { __asm {
ldy #str
lda (fp), y
sta 0x02
iny
lda (fp), y
sta 0x03
ldy #0 ldy #0
lda (0x02), y lda (str), y
beq done beq done
loop: loop:
cmp #10 cmp #10
@ -42,12 +34,12 @@ void puts(const char * str)
lda #13 lda #13
w1: w1:
jsr 0xffd2 jsr 0xffd2
inc 0x02 inc str
bne next bne next
inc 0x03 inc str + 1
next: next:
ldy #0 ldy #0
lda (0x02), y lda (str), y
bne loop bne loop
done: done:
} }
@ -56,25 +48,19 @@ void puts(const char * str)
char * gets(char * str) char * gets(char * str)
{ {
__asm { __asm {
ldy #2
lda (fp), y
sta 0x02
iny
lda (fp), y
sta 0x03
loop: loop:
jsr 0xffcf jsr 0xffcf
ldy #0 ldy #0
cmp #13 cmp #13
beq done beq done
sta (0x02), y sta (str), y
inc 0x02 inc str
bne loop bne loop
inc 0x03 inc srt + 1
bne loop bne loop
done: done:
lda #0 lda #0
sta (0x02), y sta (str), y
} }
return str; return str;

View File

@ -306,12 +306,11 @@ float atof(const char * s)
void exit(int status) void exit(int status)
{ {
__asm { __asm
ldy #status {
lda (fp), y lda status
sta accu + 0 sta accu + 0
iny lda status + 1
lda (fp), y
sta accu + 1 sta accu + 1
pla pla
pla pla

View File

@ -1,6 +1,7 @@
#include "string.h" #include "string.h"
#if 1 #if 0
/*
char * strcpy(char * dst, const char * src) char * strcpy(char * dst, const char * src)
{ {
__asm __asm
@ -33,6 +34,7 @@ char * strcpy(char * dst, const char * src)
} }
} }
*/
#else #else
char * strcpy(char * dst, const char * src) char * strcpy(char * dst, const char * src)
{ {
@ -45,7 +47,8 @@ char * strcpy(char * dst, const char * src)
} }
#endif #endif
#if 1 #if 0
/*
int strcmp(const char * ptr1, const char * ptr2) int strcmp(const char * ptr1, const char * ptr2)
{ {
__asm __asm
@ -91,6 +94,7 @@ int strcmp(const char * ptr1, const char * ptr2)
sta accu + 1 sta accu + 1
} }
} }
*/
#else #else
int strcmp(const char * ptr1, const char * ptr2) int strcmp(const char * ptr1, const char * ptr2)
{ {
@ -136,39 +140,24 @@ void * memset(void * dst, int value, int size)
{ {
__asm __asm
{ {
ldy #dst lda value
lda (fp), y
sta $1f
iny
lda (fp), y
sta $20
ldy #size ldx size + 1
lda (fp), y
sta $1b
iny
lda (fp), y
sta $1c
ldy #value
lda (fp), y
ldx $1c
beq _w1 beq _w1
ldy #0 ldy #0
_loop1: _loop1:
sta ($1f), y sta (dst), y
iny iny
bne _loop1 bne _loop1
inc $20 inc dst + 1
dex dex
bne _loop1 bne _loop1
_w1: _w1:
ldy $1b ldy size
beq _w2 beq _w2
_loop2: _loop2:
dey dey
sta ($1f), y sta (dst), y
bne _loop2 bne _loop2
_w2: _w2:
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -289,15 +289,27 @@ public:
class InterOperand class InterOperand
{ {
public: public:
int mTemp; int mTemp;
InterType mType; InterType mType;
bool mFinal; bool mFinal;
int64 mIntConst; int64 mIntConst;
double mFloatConst; double mFloatConst;
int mVarIndex, mOperandSize;
LinkerObject * mLinkerObject;
InterMemory mMemory;
InterOperand(void) InterOperand(void)
: mTemp(INVALID_TEMPORARY), mType(IT_NONE), mFinal(false), mIntConst(0), mFloatConst(0) : mTemp(INVALID_TEMPORARY), mType(IT_NONE), mFinal(false), mIntConst(0), mFloatConst(0), mVarIndex(-1), mOperandSize(0), mLinkerObject(nullptr), mMemory(IM_NONE)
{} {}
#if 0
bool Same(const InterOperand& op) const
{
if (mType != op.mType || mTemp != op.mTemp)
return false;
return true;
}
#endif
}; };
class InterInstruction class InterInstruction
@ -306,14 +318,10 @@ public:
InterCode mCode; InterCode mCode;
InterOperand mSrc[8]; InterOperand mSrc[8];
InterOperand mDst; InterOperand mDst;
InterMemory mMemory; InterOperand mConst;
InterOperator mOperator; InterOperator mOperator;
int mOperandSize, mNumOperands; int mNumOperands;
int mVarIndex;
int64 mIntValue;
double mFloatValue;
Location mLocation; Location mLocation;
LinkerObject * mLinkerObject;
bool mInUse, mInvariant, mVolatile; bool mInUse, mInvariant, mVolatile;

View File

@ -43,12 +43,12 @@ InterCodeGenerator::ExValue InterCodeGenerator::Dereference(InterCodeProcedure*
{ {
InterInstruction * ins = new InterInstruction(); InterInstruction * ins = new InterInstruction();
ins->mCode = IC_LOAD; ins->mCode = IC_LOAD;
ins->mMemory = IM_INDIRECT; ins->mSrc[0].mMemory = IM_INDIRECT;
ins->mSrc[0].mType = IT_POINTER; ins->mSrc[0].mType = IT_POINTER;
ins->mSrc[0].mTemp = v.mTemp; ins->mSrc[0].mTemp = v.mTemp;
ins->mDst.mType = v.mReference == 1 ? InterTypeOf(v.mType) : IT_POINTER; ins->mDst.mType = v.mReference == 1 ? InterTypeOf(v.mType) : IT_POINTER;
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType); ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
ins->mOperandSize = v.mReference == 1 ? v.mType->mSize : 2; ins->mSrc[0].mOperandSize = v.mReference == 1 ? v.mType->mSize : 2;
if (v.mType->mFlags & DTF_VOLATILE) if (v.mType->mFlags & DTF_VOLATILE)
ins->mVolatile = true; ins->mVolatile = true;
block->Append(ins); block->Append(ins);
@ -575,13 +575,13 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
{ {
if (dec->mInteger < -128 || dec->mInteger > 127) if (dec->mInteger < -128 || dec->mInteger > 127)
mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Integer constant truncated"); mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Integer constant truncated");
ins->mIntValue = int8(dec->mInteger); ins->mConst.mIntConst = int8(dec->mInteger);
} }
else else
{ {
if (dec->mInteger < 0 || dec->mInteger > 255) if (dec->mInteger < 0 || dec->mInteger > 255)
mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Unsigned integer constant truncated"); mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Unsigned integer constant truncated");
ins->mIntValue = uint8(dec->mInteger); ins->mConst.mIntConst = uint8(dec->mInteger);
} }
} }
else if (ins->mDst.mType == IT_INT16) else if (ins->mDst.mType == IT_INT16)
@ -590,13 +590,13 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
{ {
if (dec->mInteger < -32768 || dec->mInteger > 32767) if (dec->mInteger < -32768 || dec->mInteger > 32767)
mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Integer constant truncated"); mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Integer constant truncated");
ins->mIntValue = int16(dec->mInteger); ins->mConst.mIntConst = int16(dec->mInteger);
} }
else else
{ {
if (dec->mInteger < 0 || dec->mInteger > 65535) if (dec->mInteger < 0 || dec->mInteger > 65535)
mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Unsigned integer constant truncated"); mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Unsigned integer constant truncated");
ins->mIntValue = uint16(dec->mInteger); ins->mConst.mIntConst = uint16(dec->mInteger);
} }
} }
else if (ins->mDst.mType == IT_INT32) else if (ins->mDst.mType == IT_INT32)
@ -605,18 +605,18 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
{ {
if (dec->mInteger < -2147483648LL || dec->mInteger > 2147483647LL) if (dec->mInteger < -2147483648LL || dec->mInteger > 2147483647LL)
mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Integer constant truncated"); mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Integer constant truncated");
ins->mIntValue = int32(dec->mInteger); ins->mConst.mIntConst = int32(dec->mInteger);
} }
else else
{ {
if (dec->mInteger < 0 || dec->mInteger > 4294967296LL) if (dec->mInteger < 0 || dec->mInteger > 4294967296LL)
mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Unsigned integer constant truncated"); mErrors->Error(dec->mLocation, EWARN_CONSTANT_TRUNCATED, "Unsigned integer constant truncated");
ins->mIntValue = uint32(dec->mInteger); ins->mConst.mIntConst = uint32(dec->mInteger);
} }
} }
else else
{ {
ins->mIntValue = dec->mInteger; ins->mConst.mIntConst = dec->mInteger;
} }
block->Append(ins); block->Append(ins);
return ExValue(dec->mBase, ins->mDst.mTemp); return ExValue(dec->mBase, ins->mDst.mTemp);
@ -629,7 +629,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ins->mCode = IC_CONSTANT; ins->mCode = IC_CONSTANT;
ins->mDst.mType = InterTypeOf(dec->mBase); ins->mDst.mType = InterTypeOf(dec->mBase);
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType); ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
ins->mFloatValue = dec->mNumber; ins->mConst.mFloatConst = dec->mNumber;
block->Append(ins); block->Append(ins);
return ExValue(dec->mBase, ins->mDst.mTemp); return ExValue(dec->mBase, ins->mDst.mTemp);
@ -641,8 +641,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ins->mCode = IC_CONSTANT; ins->mCode = IC_CONSTANT;
ins->mDst.mType = IT_POINTER; ins->mDst.mType = IT_POINTER;
ins->mDst.mTemp = proc->AddTemporary(IT_POINTER); ins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
ins->mIntValue = dec->mInteger; ins->mConst.mIntConst = dec->mInteger;
ins->mMemory = IM_ABSOLUTE; ins->mConst.mMemory = IM_ABSOLUTE;
block->Append(ins); block->Append(ins);
return ExValue(dec->mBase, ins->mDst.mTemp); return ExValue(dec->mBase, ins->mDst.mTemp);
@ -659,10 +659,10 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ins->mCode = IC_CONSTANT; ins->mCode = IC_CONSTANT;
ins->mDst.mType = InterTypeOf(dec->mBase); ins->mDst.mType = InterTypeOf(dec->mBase);
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType); ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
ins->mVarIndex = dec->mVarIndex; ins->mConst.mVarIndex = dec->mVarIndex;
ins->mLinkerObject = dec->mLinkerObject; ins->mConst.mLinkerObject = dec->mLinkerObject;
ins->mMemory = IM_PROCEDURE; ins->mConst.mMemory = IM_PROCEDURE;
ins->mIntValue = 0; ins->mConst.mIntConst = 0;
block->Append(ins); block->Append(ins);
return ExValue(dec->mBase, ins->mDst.mTemp); return ExValue(dec->mBase, ins->mDst.mTemp);
@ -693,10 +693,10 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ins->mCode = IC_CONSTANT; ins->mCode = IC_CONSTANT;
ins->mDst.mType = IT_POINTER; ins->mDst.mType = IT_POINTER;
ins->mDst.mTemp = proc->AddTemporary(IT_POINTER); ins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
ins->mIntValue = 0; ins->mConst.mIntConst = 0;
ins->mVarIndex = dec->mVarIndex; ins->mConst.mVarIndex = dec->mVarIndex;
ins->mLinkerObject = dec->mLinkerObject; ins->mConst.mLinkerObject = dec->mLinkerObject;
ins->mMemory = IM_GLOBAL; ins->mConst.mMemory = IM_GLOBAL;
block->Append(ins); block->Append(ins);
return ExValue(dec->mBase, ins->mDst.mTemp, 1); return ExValue(dec->mBase, ins->mDst.mTemp, 1);
} }
@ -724,10 +724,10 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ins->mCode = IC_CONSTANT; ins->mCode = IC_CONSTANT;
ins->mDst.mType = IT_POINTER; ins->mDst.mType = IT_POINTER;
ins->mDst.mTemp = proc->AddTemporary(IT_POINTER); ins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
ins->mIntValue = 0; ins->mConst.mIntConst = 0;
ins->mVarIndex = dec->mVarIndex; ins->mConst.mVarIndex = dec->mVarIndex;
ins->mLinkerObject = dec->mLinkerObject; ins->mConst.mLinkerObject = dec->mLinkerObject;
ins->mMemory = IM_GLOBAL; ins->mConst.mMemory = IM_GLOBAL;
block->Append(ins); block->Append(ins);
return ExValue(dec->mBase, ins->mDst.mTemp, 1); return ExValue(dec->mBase, ins->mDst.mTemp, 1);
} }
@ -746,41 +746,41 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ins->mCode = IC_CONSTANT; ins->mCode = IC_CONSTANT;
ins->mDst.mType = IT_POINTER; ins->mDst.mType = IT_POINTER;
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType); ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
ins->mOperandSize = dec->mSize; ins->mConst.mOperandSize = dec->mSize;
ins->mIntValue = dec->mOffset; ins->mConst.mIntConst = dec->mOffset;
ins->mVarIndex = dec->mVarIndex; ins->mConst.mVarIndex = dec->mVarIndex;
int ref = 1; int ref = 1;
if (dec->mType == DT_ARGUMENT) if (dec->mType == DT_ARGUMENT)
{ {
if (inlineMapper) if (inlineMapper)
{ {
ins->mMemory = IM_LOCAL; ins->mConst.mMemory = IM_LOCAL;
ins->mVarIndex = inlineMapper->mParams[ins->mVarIndex]; ins->mConst.mVarIndex = inlineMapper->mParams[dec->mOffset];
} }
else if (procType->mFlags & DTF_FASTCALL) else if (procType->mFlags & DTF_FASTCALL)
ins->mMemory = IM_FPARAM; ins->mConst.mMemory = IM_FPARAM;
else else
ins->mMemory = IM_PARAM; ins->mConst.mMemory = IM_PARAM;
if (dec->mBase->mType == DT_TYPE_ARRAY) if (dec->mBase->mType == DT_TYPE_ARRAY)
{ {
ref = 2; ref = 2;
ins->mOperandSize = 2; ins->mConst.mOperandSize = 2;
} }
} }
else if (dec->mFlags & DTF_GLOBAL) else if (dec->mFlags & DTF_GLOBAL)
{ {
InitGlobalVariable(proc->mModule, dec); InitGlobalVariable(proc->mModule, dec);
ins->mMemory = IM_GLOBAL; ins->mConst.mMemory = IM_GLOBAL;
ins->mLinkerObject = dec->mLinkerObject; ins->mConst.mLinkerObject = dec->mLinkerObject;
ins->mVarIndex = dec->mVarIndex; ins->mConst.mVarIndex = dec->mVarIndex;
} }
else else
{ {
if (inlineMapper) if (inlineMapper)
ins->mVarIndex += inlineMapper->mVarIndex; ins->mConst.mVarIndex += inlineMapper->mVarIndex;
ins->mMemory = IM_LOCAL; ins->mConst.mMemory = IM_LOCAL;
} }
block->Append(ins); block->Append(ins);
@ -819,12 +819,12 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
InterInstruction * ins = new InterInstruction(); InterInstruction * ins = new InterInstruction();
ins->mCode = IC_COPY; ins->mCode = IC_COPY;
ins->mMemory = IM_INDIRECT; ins->mConst.mMemory = IM_INDIRECT;
ins->mSrc[0].mType = IT_POINTER; ins->mSrc[0].mType = IT_POINTER;
ins->mSrc[0].mTemp = vr.mTemp; ins->mSrc[0].mTemp = vr.mTemp;
ins->mSrc[1].mType = IT_POINTER; ins->mSrc[1].mType = IT_POINTER;
ins->mSrc[1].mTemp = vl.mTemp; ins->mSrc[1].mTemp = vl.mTemp;
ins->mOperandSize = vl.mType->mSize; ins->mConst.mOperandSize = vl.mType->mSize;
block->Append(ins); block->Append(ins);
} }
else else
@ -852,11 +852,11 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
if (exp->mToken == TK_ASSIGN_ADD) if (exp->mToken == TK_ASSIGN_ADD)
{ {
cins->mIntValue = vl.mType->mBase->mSize; cins->mConst.mIntConst = vl.mType->mBase->mSize;
} }
else if (exp->mToken == TK_ASSIGN_SUB) else if (exp->mToken == TK_ASSIGN_SUB)
{ {
cins->mIntValue = -vl.mType->mBase->mSize; cins->mConst.mIntConst = -vl.mType->mBase->mSize;
} }
else else
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Invalid pointer assignment"); mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Invalid pointer assignment");
@ -883,7 +883,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
InterInstruction * ains = new InterInstruction(); InterInstruction * ains = new InterInstruction();
ains->mCode = IC_LEA; ains->mCode = IC_LEA;
ains->mMemory = IM_INDIRECT; ains->mSrc[1].mMemory = IM_INDIRECT;
ains->mSrc[0].mType = IT_INT16; ains->mSrc[0].mType = IT_INT16;
ains->mSrc[0].mTemp = mins->mDst.mTemp; ains->mSrc[0].mTemp = mins->mDst.mTemp;
ains->mSrc[1].mType = IT_POINTER; ains->mSrc[1].mType = IT_POINTER;
@ -968,12 +968,12 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
} }
ins->mCode = IC_STORE; ins->mCode = IC_STORE;
ins->mMemory = IM_INDIRECT; ins->mSrc[1].mMemory = IM_INDIRECT;
ins->mSrc[0].mType = InterTypeOf(vr.mType); ins->mSrc[0].mType = InterTypeOf(vr.mType);
ins->mSrc[0].mTemp = vr.mTemp; ins->mSrc[0].mTemp = vr.mTemp;
ins->mSrc[1].mType = IT_POINTER; ins->mSrc[1].mType = IT_POINTER;
ins->mSrc[1].mTemp = vl.mTemp; ins->mSrc[1].mTemp = vl.mTemp;
ins->mOperandSize = vl.mType->mSize; ins->mSrc[1].mOperandSize = vl.mType->mSize;
block->Append(ins); block->Append(ins);
} }
} }
@ -998,7 +998,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
InterInstruction * cins = new InterInstruction(); InterInstruction * cins = new InterInstruction();
cins->mCode = IC_CONSTANT; cins->mCode = IC_CONSTANT;
cins->mIntValue = vl.mType->mBase->mSize; cins->mConst.mIntConst = vl.mType->mBase->mSize;
cins->mDst.mType = IT_INT16; cins->mDst.mType = IT_INT16;
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType); cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
block->Append(cins); block->Append(cins);
@ -1016,7 +1016,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
InterInstruction * ains = new InterInstruction(); InterInstruction * ains = new InterInstruction();
ains->mCode = IC_LEA; ains->mCode = IC_LEA;
ains->mMemory = IM_INDIRECT; ains->mSrc[1].mMemory = IM_INDIRECT;
ains->mSrc[0].mType = IT_INT16; ains->mSrc[0].mType = IT_INT16;
ains->mSrc[0].mTemp = mins->mDst.mTemp; ains->mSrc[0].mTemp = mins->mDst.mTemp;
ains->mSrc[1].mType = IT_POINTER; ains->mSrc[1].mType = IT_POINTER;
@ -1038,14 +1038,14 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
InterInstruction * cins = new InterInstruction(); InterInstruction * cins = new InterInstruction();
cins->mCode = IC_CONSTANT; cins->mCode = IC_CONSTANT;
cins->mIntValue = exp->mDecValue->mOffset; cins->mConst.mIntConst = exp->mDecValue->mOffset;
cins->mDst.mType = IT_INT16; cins->mDst.mType = IT_INT16;
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType); cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
block->Append(cins); block->Append(cins);
InterInstruction * ains = new InterInstruction(); InterInstruction * ains = new InterInstruction();
ains->mCode = IC_LEA; ains->mCode = IC_LEA;
ains->mMemory = IM_INDIRECT; ains->mSrc[1].mMemory = IM_INDIRECT;
ains->mSrc[0].mType = IT_INT16; ains->mSrc[0].mType = IT_INT16;
ains->mSrc[0].mTemp = cins->mDst.mTemp; ains->mSrc[0].mTemp = cins->mDst.mTemp;
ains->mSrc[1].mType = IT_POINTER; ains->mSrc[1].mType = IT_POINTER;
@ -1086,11 +1086,11 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
if (exp->mToken == TK_ADD) if (exp->mToken == TK_ADD)
{ {
cins->mIntValue = vl.mType->mBase->mSize; cins->mConst.mIntConst = vl.mType->mBase->mSize;
} }
else if (exp->mToken == TK_SUB) else if (exp->mToken == TK_SUB)
{ {
cins->mIntValue = -vl.mType->mBase->mSize; cins->mConst.mIntConst = -vl.mType->mBase->mSize;
} }
else else
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Invalid pointer operation"); mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Invalid pointer operation");
@ -1113,7 +1113,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
block->Append(mins); block->Append(mins);
ins->mCode = IC_LEA; ins->mCode = IC_LEA;
ins->mMemory = IM_INDIRECT; ins->mSrc[1].mMemory = IM_INDIRECT;
ins->mSrc[0].mType = IT_INT16; ins->mSrc[0].mType = IT_INT16;
ins->mSrc[0].mTemp = mins->mDst.mTemp; ins->mSrc[0].mTemp = mins->mDst.mTemp;
ins->mSrc[1].mType = IT_POINTER; ins->mSrc[1].mType = IT_POINTER;
@ -1143,7 +1143,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
InterInstruction * cins = new InterInstruction(); InterInstruction * cins = new InterInstruction();
cins->mCode = IC_CONSTANT; cins->mCode = IC_CONSTANT;
cins->mIntValue = vl.mType->mBase->mSize; cins->mConst.mIntConst = vl.mType->mBase->mSize;
cins->mDst.mType = IT_INT16; cins->mDst.mType = IT_INT16;
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType); cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
block->Append(cins); block->Append(cins);
@ -1290,9 +1290,9 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
cins->mDst.mType = ftype ? IT_FLOAT : IT_INT16; cins->mDst.mType = ftype ? IT_FLOAT : IT_INT16;
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType); cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
if (vdl.mType->mType == DT_TYPE_POINTER) if (vdl.mType->mType == DT_TYPE_POINTER)
cins->mIntValue = exp->mToken == TK_INC ? vdl.mType->mBase->mSize : -(vdl.mType->mBase->mSize); cins->mConst.mIntConst = exp->mToken == TK_INC ? vdl.mType->mBase->mSize : -(vdl.mType->mBase->mSize);
else if (vdl.mType->IsNumericType()) else if (vdl.mType->IsNumericType())
cins->mIntValue = exp->mToken == TK_INC ? 1 : -1; cins->mConst.mIntConst = exp->mToken == TK_INC ? 1 : -1;
else else
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Not a numeric value or pointer"); mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Not a numeric value or pointer");
@ -1309,12 +1309,12 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
block->Append(ains); block->Append(ains);
sins->mCode = IC_STORE; sins->mCode = IC_STORE;
sins->mMemory = IM_INDIRECT; sins->mSrc[1].mMemory = IM_INDIRECT;
sins->mSrc[0].mType = ains->mDst.mType; sins->mSrc[0].mType = ains->mDst.mType;
sins->mSrc[0].mTemp = ains->mDst.mTemp; sins->mSrc[0].mTemp = ains->mDst.mTemp;
sins->mSrc[1].mType = IT_POINTER; sins->mSrc[1].mType = IT_POINTER;
sins->mSrc[1].mTemp = vl.mTemp; sins->mSrc[1].mTemp = vl.mTemp;
sins->mOperandSize = vl.mType->mSize; sins->mSrc[1].mOperandSize = vl.mType->mSize;
block->Append(sins); block->Append(sins);
return ExValue(vdl.mType, ains->mDst.mTemp); return ExValue(vdl.mType, ains->mDst.mTemp);
@ -1342,9 +1342,9 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
cins->mDst.mType = ftype ? IT_FLOAT : IT_INT16; cins->mDst.mType = ftype ? IT_FLOAT : IT_INT16;
cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType); cins->mDst.mTemp = proc->AddTemporary(cins->mDst.mType);
if (vdl.mType->mType == DT_TYPE_POINTER) if (vdl.mType->mType == DT_TYPE_POINTER)
cins->mIntValue = exp->mToken == TK_INC ? vdl.mType->mBase->mSize : -(vdl.mType->mBase->mSize); cins->mConst.mIntConst = exp->mToken == TK_INC ? vdl.mType->mBase->mSize : -(vdl.mType->mBase->mSize);
else if (vdl.mType->IsNumericType()) else if (vdl.mType->IsNumericType())
cins->mIntValue = exp->mToken == TK_INC ? 1 : -1; cins->mConst.mIntConst = exp->mToken == TK_INC ? 1 : -1;
else else
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Not a numeric value or pointer"); mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Not a numeric value or pointer");
block->Append(cins); block->Append(cins);
@ -1360,12 +1360,12 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
block->Append(ains); block->Append(ains);
sins->mCode = IC_STORE; sins->mCode = IC_STORE;
sins->mMemory = IM_INDIRECT; sins->mSrc[1].mMemory = IM_INDIRECT;
sins->mSrc[0].mType = ains->mDst.mType; sins->mSrc[0].mType = ains->mDst.mType;
sins->mSrc[0].mTemp = ains->mDst.mTemp; sins->mSrc[0].mTemp = ains->mDst.mTemp;
sins->mSrc[1].mType = IT_POINTER; sins->mSrc[1].mType = IT_POINTER;
sins->mSrc[1].mTemp = vl.mTemp; sins->mSrc[1].mTemp = vl.mTemp;
sins->mOperandSize = vl.mType->mSize; sins->mSrc[1].mOperandSize = vl.mType->mSize;
block->Append(sins); block->Append(sins);
return ExValue(vdl.mType, vdl.mTemp); return ExValue(vdl.mType, vdl.mTemp);
@ -1613,8 +1613,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ains->mCode = IC_CONSTANT; ains->mCode = IC_CONSTANT;
ains->mDst.mType = IT_POINTER; ains->mDst.mType = IT_POINTER;
ains->mDst.mTemp = proc->AddTemporary(ains->mDst.mType); ains->mDst.mTemp = proc->AddTemporary(ains->mDst.mType);
ains->mMemory = IM_LOCAL; ains->mConst.mMemory = IM_LOCAL;
ains->mVarIndex = nindex; ains->mConst.mVarIndex = nindex;
if (pdec) if (pdec)
{ {
@ -1623,10 +1623,10 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
vdec->mVarIndex = nindex; vdec->mVarIndex = nindex;
vdec->mBase = pdec->mBase; vdec->mBase = pdec->mBase;
if (pdec->mBase->mType == DT_TYPE_ARRAY) if (pdec->mBase->mType == DT_TYPE_ARRAY)
ains->mOperandSize = 2; ains->mConst.mOperandSize = 2;
else else
ains->mOperandSize = pdec->mSize; ains->mConst.mOperandSize = pdec->mSize;
vdec->mSize = ains->mOperandSize; vdec->mSize = ains->mConst.mOperandSize;
vdec->mIdent = pdec->mIdent; vdec->mIdent = pdec->mIdent;
} }
else else
@ -1670,7 +1670,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
InterInstruction* wins = new InterInstruction(); InterInstruction* wins = new InterInstruction();
wins->mCode = IC_STORE; wins->mCode = IC_STORE;
wins->mMemory = IM_INDIRECT; wins->mSrc[1].mMemory = IM_INDIRECT;
wins->mSrc[0].mType = InterTypeOf(vr.mType);; wins->mSrc[0].mType = InterTypeOf(vr.mType);;
wins->mSrc[0].mTemp = vr.mTemp; wins->mSrc[0].mTemp = vr.mTemp;
wins->mSrc[1].mType = IT_POINTER; wins->mSrc[1].mType = IT_POINTER;
@ -1678,14 +1678,14 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
if (pdec) if (pdec)
{ {
if (pdec->mBase->mType == DT_TYPE_ARRAY) if (pdec->mBase->mType == DT_TYPE_ARRAY)
wins->mOperandSize = 2; wins->mSrc[1].mOperandSize = 2;
else else
wins->mOperandSize = pdec->mSize; wins->mSrc[1].mOperandSize = pdec->mSize;
} }
else if (vr.mType->mSize > 2 && vr.mType->mType != DT_TYPE_ARRAY) else if (vr.mType->mSize > 2 && vr.mType->mType != DT_TYPE_ARRAY)
wins->mOperandSize = vr.mType->mSize; wins->mSrc[1].mOperandSize = vr.mType->mSize;
else else
wins->mOperandSize = 2; wins->mSrc[1].mOperandSize = 2;
block->Append(wins); block->Append(wins);
if (pdec) if (pdec)
@ -1722,10 +1722,10 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ins->mCode = IC_CONSTANT; ins->mCode = IC_CONSTANT;
ins->mDst.mType = IT_POINTER; ins->mDst.mType = IT_POINTER;
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType); ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
ins->mOperandSize = rdec->mSize; ins->mConst.mOperandSize = rdec->mSize;
ins->mIntValue = rdec->mOffset; ins->mConst.mIntConst = rdec->mOffset;
ins->mVarIndex = rdec->mVarIndex; ins->mConst.mVarIndex = rdec->mVarIndex;
ins->mMemory = IM_LOCAL; ins->mConst.mMemory = IM_LOCAL;
block->Append(ins); block->Append(ins);
@ -1757,7 +1757,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
{ {
fins = new InterInstruction(); fins = new InterInstruction();
fins->mCode = IC_PUSH_FRAME; fins->mCode = IC_PUSH_FRAME;
fins->mIntValue = atotal; fins->mConst.mIntConst = atotal;
block->Append(fins); block->Append(fins);
} }
@ -1776,18 +1776,18 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ains->mDst.mTemp = proc->AddTemporary(ains->mDst.mType); ains->mDst.mTemp = proc->AddTemporary(ains->mDst.mType);
if (pdec) if (pdec)
{ {
ains->mVarIndex = pdec->mVarIndex; ains->mConst.mVarIndex = pdec->mVarIndex;
ains->mIntValue = pdec->mOffset; ains->mConst.mIntConst = pdec->mOffset;
if (pdec->mBase->mType == DT_TYPE_ARRAY) if (pdec->mBase->mType == DT_TYPE_ARRAY)
ains->mOperandSize = 2; ains->mConst.mOperandSize = 2;
else else
ains->mOperandSize = pdec->mSize; ains->mConst.mOperandSize = pdec->mSize;
} }
else if (ftype->mFlags & DTF_VARIADIC) else if (ftype->mFlags & DTF_VARIADIC)
{ {
ains->mVarIndex = atotal; ains->mConst.mVarIndex = atotal;
ains->mIntValue = 0; ains->mConst.mIntConst = 0;
ains->mOperandSize = 2; ains->mConst.mOperandSize = 2;
} }
else else
{ {
@ -1796,11 +1796,11 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
if (ftype->mFlags & DTF_FASTCALL) if (ftype->mFlags & DTF_FASTCALL)
{ {
ains->mMemory = IM_FPARAM; ains->mConst.mMemory = IM_FPARAM;
ains->mIntValue = 0; ains->mConst.mIntConst = 0;
} }
else else
ains->mMemory = IM_FRAME; ains->mConst.mMemory = IM_FRAME;
block->Append(ains); block->Append(ains);
@ -1831,15 +1831,15 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
InterInstruction* cins = new InterInstruction(); InterInstruction* cins = new InterInstruction();
cins->mCode = IC_COPY; cins->mCode = IC_COPY;
cins->mMemory = IM_INDIRECT; cins->mConst.mMemory = IM_INDIRECT;
cins->mSrc[0].mType = IT_POINTER; cins->mSrc[0].mType = IT_POINTER;
cins->mSrc[0].mTemp = vr.mTemp; cins->mSrc[0].mTemp = vr.mTemp;
cins->mSrc[1].mType = IT_POINTER; cins->mSrc[1].mType = IT_POINTER;
cins->mSrc[1].mTemp = ains->mDst.mTemp; cins->mSrc[1].mTemp = ains->mDst.mTemp;
cins->mOperandSize = vr.mType->mSize; cins->mConst.mOperandSize = vr.mType->mSize;
block->Append(cins); block->Append(cins);
atotal += cins->mOperandSize; atotal += cins->mConst.mOperandSize;
} }
else else
{ {
@ -1862,7 +1862,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
InterInstruction* wins = new InterInstruction(); InterInstruction* wins = new InterInstruction();
wins->mCode = IC_STORE; wins->mCode = IC_STORE;
wins->mMemory = IM_INDIRECT; wins->mSrc[1].mMemory = IM_INDIRECT;
wins->mSrc[0].mType = InterTypeOf(vr.mType);; wins->mSrc[0].mType = InterTypeOf(vr.mType);;
wins->mSrc[0].mTemp = vr.mTemp; wins->mSrc[0].mTemp = vr.mTemp;
wins->mSrc[1].mType = IT_POINTER; wins->mSrc[1].mType = IT_POINTER;
@ -1870,18 +1870,18 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
if (pdec) if (pdec)
{ {
if (pdec->mBase->mType == DT_TYPE_ARRAY) if (pdec->mBase->mType == DT_TYPE_ARRAY)
wins->mOperandSize = 2; wins->mSrc[1].mOperandSize = 2;
else else
wins->mOperandSize = pdec->mSize; wins->mSrc[1].mOperandSize = pdec->mSize;
} }
else if (vr.mType->mSize > 2 && vr.mType->mType != DT_TYPE_ARRAY) else if (vr.mType->mSize > 2 && vr.mType->mType != DT_TYPE_ARRAY)
wins->mOperandSize = vr.mType->mSize; wins->mSrc[1].mOperandSize = vr.mType->mSize;
else else
wins->mOperandSize = 2; wins->mSrc[1].mOperandSize = 2;
block->Append(wins); block->Append(wins);
atotal += wins->mOperandSize; atotal += wins->mSrc[1].mOperandSize;
} }
if (pdec) if (pdec)
@ -1913,11 +1913,11 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
} }
else else
{ {
fins->mIntValue = atotal; fins->mConst.mIntConst = atotal;
InterInstruction* xins = new InterInstruction(); InterInstruction* xins = new InterInstruction();
xins->mCode = IC_POP_FRAME; xins->mCode = IC_POP_FRAME;
xins->mIntValue = atotal; xins->mConst.mIntConst = atotal;
block->Append(xins); block->Append(xins);
} }
@ -1942,11 +1942,11 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ins->mCode = IC_CONSTANT; ins->mCode = IC_CONSTANT;
ins->mDst.mType = IT_POINTER; ins->mDst.mType = IT_POINTER;
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType); ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
ins->mOperandSize = dec->mSize; ins->mConst.mOperandSize = dec->mSize;
ins->mIntValue = 0; ins->mConst.mIntConst = 0;
ins->mMemory = IM_GLOBAL; ins->mConst.mMemory = IM_GLOBAL;
ins->mLinkerObject = dec->mLinkerObject; ins->mConst.mLinkerObject = dec->mLinkerObject;
ins->mVarIndex = dec->mVarIndex; ins->mConst.mVarIndex = dec->mVarIndex;
block->Append(ins); block->Append(ins);
InterInstruction * jins = new InterInstruction(); InterInstruction * jins = new InterInstruction();
@ -1966,24 +1966,24 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
if (vdec->mType == DT_ARGUMENT) if (vdec->mType == DT_ARGUMENT)
{ {
if (procType->mFlags & DTF_FASTCALL) if (procType->mFlags & DTF_FASTCALL)
vins->mMemory = IM_FPARAM; vins->mConst.mMemory = IM_FPARAM;
else else
vins->mMemory = IM_PARAM; vins->mConst.mMemory = IM_PARAM;
vins->mOperandSize = vdec->mSize; vins->mConst.mOperandSize = vdec->mSize;
vins->mIntValue = vdec->mOffset; vins->mConst.mIntConst = vdec->mOffset;
vins->mVarIndex = vdec->mVarIndex; vins->mConst.mVarIndex = vdec->mVarIndex;
} }
block->Append(vins); block->Append(vins);
InterInstruction* lins = new InterInstruction(); InterInstruction* lins = new InterInstruction();
lins->mCode = IC_LOAD; lins->mCode = IC_LOAD;
lins->mMemory = IM_INDIRECT; lins->mSrc[0].mMemory = IM_INDIRECT;
lins->mSrc[0].mType = IT_POINTER; lins->mSrc[0].mType = IT_POINTER;
lins->mSrc[0].mTemp = vins->mDst.mTemp; lins->mSrc[0].mTemp = vins->mDst.mTemp;
lins->mDst.mType = InterTypeOf(vdec->mBase); lins->mDst.mType = InterTypeOf(vdec->mBase);
lins->mDst.mTemp = proc->AddTemporary(lins->mDst.mType); lins->mDst.mTemp = proc->AddTemporary(lins->mDst.mType);
lins->mOperandSize = vdec->mSize; lins->mSrc[0].mOperandSize = vdec->mSize;
block->Append(lins); block->Append(lins);
jins->mSrc[jins->mNumOperands].mType = InterTypeOf(vdec->mBase); jins->mSrc[jins->mNumOperands].mType = InterTypeOf(vdec->mBase);
@ -2021,17 +2021,17 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ains->mCode = IC_CONSTANT; ains->mCode = IC_CONSTANT;
ains->mDst.mType = IT_POINTER; ains->mDst.mType = IT_POINTER;
ains->mDst.mTemp = proc->AddTemporary(ins->mDst.mType); ains->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
ains->mOperandSize = procType->mBase->mSize; ains->mConst.mOperandSize = procType->mBase->mSize;
ains->mIntValue = 0; ains->mConst.mIntConst = 0;
ains->mVarIndex = inlineMapper->mResult;; ains->mConst.mVarIndex = inlineMapper->mResult;;
ains->mMemory = IM_LOCAL; ains->mConst.mMemory = IM_LOCAL;
block->Append(ains); block->Append(ains);
ins->mSrc[1].mType = ains->mDst.mType; ins->mSrc[1].mType = ains->mDst.mType;
ins->mSrc[1].mTemp = ains->mDst.mTemp; ins->mSrc[1].mTemp = ains->mDst.mTemp;
ins->mMemory = IM_INDIRECT; ins->mSrc[1].mMemory = IM_INDIRECT;
ins->mCode = IC_STORE; ins->mCode = IC_STORE;
ins->mOperandSize = ains->mOperandSize; ins->mSrc[1].mOperandSize = ains->mConst.mOperandSize;
} }
else else
ins->mCode = IC_RETURN_VALUE; ins->mCode = IC_RETURN_VALUE;
@ -2110,7 +2110,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
zins->mCode = IC_CONSTANT; zins->mCode = IC_CONSTANT;
zins->mDst.mType = InterTypeOf(vl.mType); zins->mDst.mType = InterTypeOf(vl.mType);
zins->mDst.mTemp = proc->AddTemporary(zins->mDst.mType); zins->mDst.mTemp = proc->AddTemporary(zins->mDst.mType);
zins->mIntValue = 0; zins->mConst.mIntConst = 0;
block->Append(zins); block->Append(zins);
InterInstruction * ins = new InterInstruction(); InterInstruction * ins = new InterInstruction();
@ -2289,14 +2289,14 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
InterInstruction* tins = new InterInstruction(); InterInstruction* tins = new InterInstruction();
tins->mCode = IC_CONSTANT; tins->mCode = IC_CONSTANT;
tins->mIntValue = 1; tins->mConst.mIntConst = 1;
tins->mDst.mType = IT_BOOL; tins->mDst.mType = IT_BOOL;
tins->mDst.mTemp = ttemp; tins->mDst.mTemp = ttemp;
tblock->Append(tins); tblock->Append(tins);
InterInstruction* fins = new InterInstruction(); InterInstruction* fins = new InterInstruction();
fins->mCode = IC_CONSTANT; fins->mCode = IC_CONSTANT;
fins->mIntValue = 0; fins->mConst.mIntConst = 0;
fins->mDst.mType = IT_BOOL; fins->mDst.mType = IT_BOOL;
fins->mDst.mTemp = ttemp; fins->mDst.mTemp = ttemp;
fblock->Append(fins); fblock->Append(fins);

File diff suppressed because it is too large Load Diff

View File

@ -689,29 +689,30 @@ Declaration* Parser::ParseDeclaration(bool variable)
mScanner->NextToken(); mScanner->NextToken();
} }
else else
if (mScanner->mToken == TK_STATIC)
{ {
storageFlags |= DTF_STATIC; if (mScanner->mToken == TK_STATIC)
mScanner->NextToken(); {
} storageFlags |= DTF_STATIC;
mScanner->NextToken();
}
if (mScanner->mToken == TK_EXTERN) if (mScanner->mToken == TK_EXTERN)
{ {
storageFlags |= DTF_EXTERN; storageFlags |= DTF_EXTERN;
mScanner->NextToken(); mScanner->NextToken();
} }
if (mScanner->mToken == TK_INLINE) if (mScanner->mToken == TK_INLINE)
{ {
storageFlags |= DTF_INLINE; storageFlags |= DTF_INLINE;
mScanner->NextToken(); mScanner->NextToken();
} }
if (mScanner->mToken == TK_FASTCALL) if (mScanner->mToken == TK_FASTCALL)
{ {
typeFlags |= DTF_FASTCALL; typeFlags |= DTF_FASTCALL;
mScanner->NextToken(); mScanner->NextToken();
}
} }
Declaration* bdec = ParseBaseTypeDeclaration(0); Declaration* bdec = ParseBaseTypeDeclaration(0);
@ -1980,7 +1981,7 @@ Expression* Parser::ParseAssemblerAddOperand(void)
nexp->mLeft = exp; nexp->mLeft = exp;
mScanner->NextToken(); mScanner->NextToken();
nexp->mRight = ParseAssemblerMulOperand(); nexp->mRight = ParseAssemblerMulOperand();
if (nexp->mLeft->mDecValue->mType == DT_VARIABLE) if (nexp->mLeft->mDecValue->mType == DT_VARIABLE || nexp->mLeft->mDecValue->mType == DT_ARGUMENT)
{ {
if (nexp->mRight->mDecValue->mType == DT_CONST_INTEGER) if (nexp->mRight->mDecValue->mType == DT_CONST_INTEGER)
{ {