summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler.h4
-rw-r--r--src/declare.cc4
-rw-r--r--src/parser.cc15
-rw-r--r--src/parsetree.h68
4 files changed, 32 insertions, 59 deletions
diff --git a/src/compiler.h b/src/compiler.h
index e0c75a7b..600552f8 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -875,13 +875,13 @@ struct Compiler
ConsList replList;
ParserTextList parserTextList;
- StructDef *global;
+ Context *global;
StructEl *globalSel;
ObjectDef *globalObjectDef;
ObjectField *argv0;
ObjectField *argvList;
- StructDef *stream;
+ Context *stream;
StructEl *streamSel;
VectorTypeIdMap vectorTypeIdMap;
diff --git a/src/declare.cc b/src/declare.cc
index 48d77134..28e57f5f 100644
--- a/src/declare.cc
+++ b/src/declare.cc
@@ -374,7 +374,7 @@ void Namespace::declare( Compiler *pd )
for ( StructDefList::Iter s = structDefList; s.lte(); s++ ) {
if ( s != pd->stream ) {
- StructEl *sel = declareStruct( pd, this, s->name, s->context );
+ StructEl *sel = declareStruct( pd, this, s->name, s );
/* If the token has the same name as the region it is in, then also
* insert it into the symbol map for the parent region. */
@@ -388,8 +388,6 @@ void Namespace::declare( Compiler *pd )
if ( s == pd->global )
pd->globalSel = sel;
- if ( s == pd->stream )
- pd->streamSel = sel;
}
}
diff --git a/src/parser.cc b/src/parser.cc
index 5c316aa6..c1fd9ad1 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -25,8 +25,7 @@ void BaseParser::init()
pd->globalObjectDef = ObjectDef::cons( ObjectDef::UserType,
global, pd->nextObjectId++ );
- Context *context = new Context( internal, pd->globalObjectDef );
- pd->global = new StructDef( global, context );
+ pd->global = new Context( internal, global, pd->globalObjectDef );
pd->rootNamespace->structDefList.append( pd->global );
/* Setup the stream object. */
@@ -34,12 +33,10 @@ void BaseParser::init()
ObjectDef *objectDef = ObjectDef::cons( ObjectDef::BuiltinType,
global, pd->nextObjectId++ );
- context = new Context( internal, objectDef );
- pd->stream = new StructDef( global, context );
+ pd->stream = new Context( internal, global, objectDef );
StructEl *sel = declareStruct( pd, pd->rootNamespace,
- pd->stream->name, pd->stream->context );
- sel->context = pd->stream->context;
+ pd->stream->name, pd->stream );
/* Insert the name into the top of the region stack after popping the
* region just created. We need it in the parent. */
@@ -901,12 +898,10 @@ void BaseParser::structHead( const InputLoc &loc, const String &data,
ObjectDef *objectDef = ObjectDef::cons( objectType,
data, pd->nextObjectId++ );
- Context *context = new Context( loc, objectDef );
+ Context *context = new Context( loc, data, objectDef );
contextStack.push( context );
- StructDef *structDef = new StructDef( data, context );
- nspace->structDefList.append( structDef );
-
+ nspace->structDefList.append( context );
}
StmtList *BaseParser::appendStatement( StmtList *stmtList, LangStmt *stmt )
diff --git a/src/parsetree.h b/src/parsetree.h
index 8289f0e0..eeefc533 100644
--- a/src/parsetree.h
+++ b/src/parsetree.h
@@ -330,37 +330,6 @@ struct ReCapture
ObjectField *objField;
};
-struct ContextStack
- : public Vector<Context*>
-{
- Context *top()
- { return length() > 0 ? Vector<Context*>::top() : 0; }
-};
-
-struct Context
-{
- Context( const InputLoc &loc, ObjectDef *objectDef )
- :
- loc(loc),
- objectDef(objectDef)
- {}
-
- InputLoc loc;
- ObjectDef *objectDef;
-};
-
-struct Struct
-{
- Struct( const InputLoc &loc, ObjectDef *objectDef )
- :
- loc(loc),
- objectDef(objectDef)
- {}
-
- InputLoc loc;
- ObjectDef *objectDef;
-};
-
typedef Vector<ReCapture> ReCaptureVect;
@@ -553,6 +522,29 @@ struct TokenInstanceListReg : DListMel<TokenInstance, TokenInstancePtr> {};
struct TokenDefListReg : DListMel<TokenDef, TokenDefPtr1> {};
struct TokenDefListNs : DListMel<TokenDef, TokenDefPtr2> {};
+struct ContextStack
+ : public Vector<Context*>
+{
+ Context *top()
+ { return length() > 0 ? Vector<Context*>::top() : 0; }
+};
+
+struct Context
+{
+ Context( const InputLoc &loc, const String &name, ObjectDef *objectDef )
+ :
+ loc(loc),
+ name(name),
+ objectDef(objectDef)
+ {}
+
+ InputLoc loc;
+ String name;
+ ObjectDef *objectDef;
+
+ Context *prev, *next;
+};
+
struct StructEl
{
StructEl( Namespace *nspace, const String &name )
@@ -567,19 +559,7 @@ struct StructEl
};
typedef DList<StructEl> StructElList;
-
-struct StructDef
-{
- StructDef( const String &name, Context *context )
- : name(name), context(context) {}
-
- String name;
- Context *context;
-
- StructDef *prev, *next;
-};
-
-struct StructDefList : DList<StructDef> {};
+struct StructDefList : DList<Context> {};
struct TypeMapEl
: public AvlTreeEl<TypeMapEl>