Global object initialization
This commit is contained in:
parent
80426d974c
commit
ae2fbb6256
|
@ -973,3 +973,5 @@ void cistream::refill(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cistream cin;
|
||||||
|
costream cout;
|
||||||
|
|
|
@ -202,6 +202,8 @@ iosetfill setfill(char fill);
|
||||||
ostream & operator<<(ostream & os, const iosetfill & s);
|
ostream & operator<<(ostream & os, const iosetfill & s);
|
||||||
|
|
||||||
|
|
||||||
|
extern cistream cin;
|
||||||
|
extern costream cout;
|
||||||
|
|
||||||
#pragma compile("iostream.cpp");
|
#pragma compile("iostream.cpp");
|
||||||
|
|
||||||
|
|
|
@ -467,6 +467,11 @@ void InterCodeGenerator::InitGlobalVariable(InterCodeModule * mod, Declaration*
|
||||||
else
|
else
|
||||||
mErrors->Error(dec->mLocation, EERR_INCOMPATIBLE_TYPES, "Incompatible constant initializer");
|
mErrors->Error(dec->mLocation, EERR_INCOMPATIBLE_TYPES, "Incompatible constant initializer");
|
||||||
}
|
}
|
||||||
|
else if (dec->mValue->mType == EX_CONSTRUCT)
|
||||||
|
{
|
||||||
|
DestructStack* destack = nullptr;
|
||||||
|
TranslateExpression(nullptr, mMainInitProc, mMainInitBlock, dec->mValue, destack, BranchTarget(), BranchTarget(), nullptr);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
mErrors->Error(dec->mLocation, EERR_CONSTANT_INITIALIZER, "Non constant initializer");
|
mErrors->Error(dec->mLocation, EERR_CONSTANT_INITIALIZER, "Non constant initializer");
|
||||||
}
|
}
|
||||||
|
@ -4742,6 +4747,13 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod
|
||||||
|
|
||||||
InterCodeBasicBlock* entryBlock = new InterCodeBasicBlock(proc);
|
InterCodeBasicBlock* entryBlock = new InterCodeBasicBlock(proc);
|
||||||
|
|
||||||
|
if (!strcmp(proc->mIdent->mString, "main"))
|
||||||
|
{
|
||||||
|
mMainInitBlock = entryBlock;
|
||||||
|
mMainInitProc = proc;
|
||||||
|
entryBlock = new InterCodeBasicBlock(proc);
|
||||||
|
}
|
||||||
|
|
||||||
InterCodeBasicBlock* exitBlock = entryBlock;
|
InterCodeBasicBlock* exitBlock = entryBlock;
|
||||||
|
|
||||||
if (dec->mFlags & DTF_DEFINED)
|
if (dec->mFlags & DTF_DEFINED)
|
||||||
|
@ -4781,6 +4793,13 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod
|
||||||
TranslateExpression(dec->mBase, proc, exitBlock, exp, destack, BranchTarget(), BranchTarget(), nullptr);
|
TranslateExpression(dec->mBase, proc, exitBlock, exp, destack, BranchTarget(), BranchTarget(), nullptr);
|
||||||
|
|
||||||
UnwindDestructStack(dec->mBase, proc, exitBlock, destack, nullptr, nullptr);
|
UnwindDestructStack(dec->mBase, proc, exitBlock, destack, nullptr, nullptr);
|
||||||
|
|
||||||
|
if (!strcmp(proc->mIdent->mString, "main"))
|
||||||
|
{
|
||||||
|
InterInstruction* ins = new InterInstruction(proc->mLocation, IC_JUMP);
|
||||||
|
mMainInitBlock->Append(ins);
|
||||||
|
mMainInitBlock->Close(entryBlock, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mErrors->Error(dec->mLocation, EERR_UNDEFINED_OBJECT, "Calling undefined function", dec->mQualIdent->mString);
|
mErrors->Error(dec->mLocation, EERR_UNDEFINED_OBJECT, "Calling undefined function", dec->mQualIdent->mString);
|
||||||
|
|
|
@ -74,6 +74,9 @@ protected:
|
||||||
|
|
||||||
typedef GrowingArray<SwitchNode> SwitchNodeArray;
|
typedef GrowingArray<SwitchNode> SwitchNodeArray;
|
||||||
|
|
||||||
|
InterCodeProcedure* mMainInitProc;
|
||||||
|
InterCodeBasicBlock* mMainInitBlock;
|
||||||
|
|
||||||
void BuildSwitchTree(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock* block, ExValue v, const SwitchNodeArray& nodes, int left, int right, InterCodeBasicBlock* dblock);
|
void BuildSwitchTree(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock* block, ExValue v, const SwitchNodeArray& nodes, int left, int right, InterCodeBasicBlock* dblock);
|
||||||
|
|
||||||
ExValue ToValue(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, ExValue v);
|
ExValue ToValue(InterCodeProcedure* proc, Expression* exp, InterCodeBasicBlock*& block, ExValue v);
|
||||||
|
|
Loading…
Reference in New Issue