void SymVarConst::GenerateValue(AsmCode& asm_code) const { if (value.GetType() == INT_CONST) { asm_code.AddCmd(ASM_PUSH, value.GetIntValue()); } else if (value.GetType() == REAL_CONST) { stringstream s; s << value.GetName(); float f; int* p = (int*)&f; s >> f; asm_code.AddCmd(ASM_PUSH, *p); }
void SymVarGlobal::Generate(AsmCode& asmCode, unsigned) const { if (type->GetSize() > 4) { GenerateLValue(asmCode, 0); asmCode.PushMemory(type->GetSize()); } else { asmCode.AddCmd(PUSH, AsmMemory(varLabel, 0, szDWORD)); } }
void SymProc::GenerateDeclaration(AsmCode& asm_code) { if (IsDummyProc()) return; asm_code.AddLabel(label); asm_code.AddCmd(ASM_PUSH, REG_EBP); asm_code.AddCmd(ASM_MOV, REG_ESP, REG_EBP); if (sym_table->GetLocalsSize()) asm_code.AddCmd(ASM_SUB, sym_table->GetLocalsSize(), REG_ESP); body->Generate(asm_code); asm_code.AddLabel(exit_label); asm_code.AddCmd(ASM_MOV, REG_EBP, REG_ESP); asm_code.AddCmd(ASM_POP, REG_EBP); asm_code.AddCmd(ASM_RET, sym_table->GetParamsSize() - GetResultType()->GetSize()); }
void SymVarGlobal::GenerateLValue(AsmCode& asmCode, unsigned) const { asmCode.AddCmd(PUSH, AsmVarAddr(varLabel)); }
void SymConstCharacterString::Generate(AsmCode& asmCode, unsigned stmtDepth) const { asmCode.AddCmd(PUSH, AsmVarAddr(asmCode.AddData(asmCode.GenStrLabel("str"), value))); }
void SymConstFloat::Generate(AsmCode& asmCode, unsigned) const { asmCode.AddCmd(PUSH, constLabel); }
void SymConstInteger::Generate(AsmCode& asmCode, unsigned) const { asmCode.AddCmd(PUSH, value); }