From e9a6e75710c42ab1a80c3cf54c5131e2bc4329e1 Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Thu, 25 Dec 2014 16:02:14 -0500 Subject: converted the global object to a struct --- src/parser.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/parser.cc') diff --git a/src/parser.cc b/src/parser.cc index b7892480..1aeb3787 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -18,13 +18,17 @@ using std::endl; void BaseParser::init() { /* Set up the root namespace. */ - Namespace *rootNamespace = createRootNamespace(); - pd->rootNamespace = rootNamespace; + pd->rootNamespace = createRootNamespace(); /* Set up the global object. */ String global = "global"; pd->globalObjectDef = ObjectDef::cons( ObjectDef::UserType, global, pd->nextObjectId++ ); + + Context *context = new Context( internal, 0 ); + pd->global = new StructDef( global, context ); + pd->rootNamespace->structDefList.append( pd->global ); + context->objectDef = pd->globalObjectDef; /* Initialize the dictionary of graphs. This is our symbol table. The * initialization needs to be done on construction which happens at the @@ -894,7 +898,7 @@ void BaseParser::structHead( const InputLoc &loc, const String &data, Context *context = new Context( loc, 0 ); contextStack.push( context ); - StructDef *structDef = new StructDef( data, context, nspace ); + StructDef *structDef = new StructDef( data, context ); nspace->structDefList.append( structDef ); context->objectDef = ObjectDef::cons( objectType, -- cgit v1.2.1