This commit is contained in:
rginda%netscape.com 2000-10-17 08:02:16 +00:00
Родитель 3dfb0c94c2
Коммит ab377fd783
4 изменённых файлов: 66 добавлений и 46 удалений

Просмотреть файл

@ -609,31 +609,39 @@ namespace ICodeASM {
string *str;
begin = ParseAlpha (tl.begin, end, &str);
if (cmp_nocase(*string, keyword_offset, keyword_offset +
strlen(keyword_offset) + 1) == 0) {
/* label expressed as "Offset +/-N" */
/* got the "Offset" keyword, treat next thing as a jump offset
* expressed as "Offset +/-N" */
tl = SeekTokenStart (begin, end);
if ((tl.estimate != teNumeric) && (tl.estimate != teMinus) &&
(tl.estimate != tePlus))
throw new ICodeParseException ("Expected numeric value after Offset keyword.");
begin = ParseInt32 (tl.begin, end, &(o->asInt32));
return begin;
int32 ofs;
begin = ParseInt32 (tl.begin, end, &ofs);
Label *l = new VM::Label(0);
l->mOffset = mStatementNodes.size() + ofs - 1;
mUnnamedLabels.push_back (l);
o->asLabel = l;
} else {
/* label expressed as "label_name" */
LabelMap::const_iterator l = mLabels.find(str->c_string());
if (l == mLabels.end())
{
/* if we can't find the label, mark it as a fixup for later */
o->asString = str;
mFixupNodes.push_back (mStatementNodes.back());
return begin;
}
/* XXX continue here... */
/* label expressed as "label_name", look for it in the
* namedlabels map */
LabelMap::const_iterator l = mLabels.find(str->c_str());
if (l != mLabels.end()) {
/* found the label, use it */
o->asLabel = *l;
} else {
/* havn't seen the label definition yet, put a placeholder
* in the namedlabels map */
VM::Label *new_label = new VM::Label(0);
new_label->mOffset = VM::NotALabel;
o->asLabel = new_label;
mNamedLabels[str] = new_label;
}
}
return begin;
}
iter

Просмотреть файл

@ -87,12 +87,13 @@ namespace ICodeASM {
double asDouble;
uint32 asUInt32;
int32 asInt32;
VM::Register asRegister;
bool asBoolean;
VM::ArgumentList *asArgumentList;
string *asString;
VM::Register asRegister;
VM::Label *asLabel;
VM::ArgumentList *asArgumentList;
};
struct StatementNode {
iter pos;
uint icodeID;
@ -104,14 +105,15 @@ namespace ICodeASM {
private:
uint mMaxRegister;
std::vector<StatementNode *> mStatementNodes;
std::vector<StatementNode *> mFixupNodes;
typedef std::map<const char *, StatementNode **> LabelMap;
LabelMap mLabels;
VM::LabelList mUnnamedLabels;
typedef std::map<const char *, VM::Label*> LabelMap;
LabelMap mNamedLabels;
public:
void ParseSourceFromString (const string source);
/* locate the beginning of the next token, and guess what it might be */
/* locate the beginning of the next token and take a guess at what it
* might be */
TokenLocation SeekTokenStart (iter begin, iter end);
/* general purpose parse functions; |begin| is expected to point

Просмотреть файл

@ -609,31 +609,39 @@ namespace ICodeASM {
string *str;
begin = ParseAlpha (tl.begin, end, &str);
if (cmp_nocase(*string, keyword_offset, keyword_offset +
strlen(keyword_offset) + 1) == 0) {
/* label expressed as "Offset +/-N" */
/* got the "Offset" keyword, treat next thing as a jump offset
* expressed as "Offset +/-N" */
tl = SeekTokenStart (begin, end);
if ((tl.estimate != teNumeric) && (tl.estimate != teMinus) &&
(tl.estimate != tePlus))
throw new ICodeParseException ("Expected numeric value after Offset keyword.");
begin = ParseInt32 (tl.begin, end, &(o->asInt32));
return begin;
int32 ofs;
begin = ParseInt32 (tl.begin, end, &ofs);
Label *l = new VM::Label(0);
l->mOffset = mStatementNodes.size() + ofs - 1;
mUnnamedLabels.push_back (l);
o->asLabel = l;
} else {
/* label expressed as "label_name" */
LabelMap::const_iterator l = mLabels.find(str->c_string());
if (l == mLabels.end())
{
/* if we can't find the label, mark it as a fixup for later */
o->asString = str;
mFixupNodes.push_back (mStatementNodes.back());
return begin;
}
/* XXX continue here... */
/* label expressed as "label_name", look for it in the
* namedlabels map */
LabelMap::const_iterator l = mLabels.find(str->c_str());
if (l != mLabels.end()) {
/* found the label, use it */
o->asLabel = *l;
} else {
/* havn't seen the label definition yet, put a placeholder
* in the namedlabels map */
VM::Label *new_label = new VM::Label(0);
new_label->mOffset = VM::NotALabel;
o->asLabel = new_label;
mNamedLabels[str] = new_label;
}
}
return begin;
}
iter

Просмотреть файл

@ -87,12 +87,13 @@ namespace ICodeASM {
double asDouble;
uint32 asUInt32;
int32 asInt32;
VM::Register asRegister;
bool asBoolean;
VM::ArgumentList *asArgumentList;
string *asString;
VM::Register asRegister;
VM::Label *asLabel;
VM::ArgumentList *asArgumentList;
};
struct StatementNode {
iter pos;
uint icodeID;
@ -104,14 +105,15 @@ namespace ICodeASM {
private:
uint mMaxRegister;
std::vector<StatementNode *> mStatementNodes;
std::vector<StatementNode *> mFixupNodes;
typedef std::map<const char *, StatementNode **> LabelMap;
LabelMap mLabels;
VM::LabelList mUnnamedLabels;
typedef std::map<const char *, VM::Label*> LabelMap;
LabelMap mNamedLabels;
public:
void ParseSourceFromString (const string source);
/* locate the beginning of the next token, and guess what it might be */
/* locate the beginning of the next token and take a guess at what it
* might be */
TokenLocation SeekTokenStart (iter begin, iter end);
/* general purpose parse functions; |begin| is expected to point