diff options
author | Adrian Thurston <thurston@complang.org> | 2011-07-10 21:28:29 +0000 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2011-07-10 21:28:29 +0000 |
commit | 1aa15a519c1e588a34702767875d2ec3825b67e1 (patch) | |
tree | 6de5948d1a30c8d5ca245e7a46055e511932693a | |
parent | d35b9f61d48cea3277108ad8faa69e3539bd40a5 (diff) | |
download | colm-1aa15a519c1e588a34702767875d2ec3825b67e1.tar.gz |
Use a list typeref for argv. Means argv_list is no longer an implicitly created
type.
-rw-r--r-- | colm/bytecode.c | 2 | ||||
-rw-r--r-- | colm/compile.cc | 5 | ||||
-rw-r--r-- | colm/lmparse.kl | 16 | ||||
-rw-r--r-- | colm/parsedata.cc | 2 | ||||
-rw-r--r-- | colm/parsedata.h | 2 | ||||
-rw-r--r-- | colm/pdabuild.cc | 2 | ||||
-rw-r--r-- | colm/pdacodegen.cc | 1 | ||||
-rw-r--r-- | colm/pdarun.h | 2 | ||||
-rw-r--r-- | colm/resolve.cc | 3 | ||||
-rw-r--r-- | test/accum3.lm | 2 | ||||
-rw-r--r-- | test/argv1.exp | 4 | ||||
-rw-r--r-- | test/argv2.lm | 2 |
12 files changed, 23 insertions, 20 deletions
diff --git a/colm/bytecode.c b/colm/bytecode.c index 5a52b36e..8824d0f3 100644 --- a/colm/bytecode.c +++ b/colm/bytecode.c @@ -491,7 +491,7 @@ void userIterDestroy( Tree ***psp, UserIter *uiter ) Tree *constructArgv( Program *prg, int argc, char **argv ) { - Tree *list = createGeneric( prg, 1 ); + Tree *list = createGeneric( prg, prg->rtd->argvGenericId ); treeUpref( list ); int i; for ( i = 0; i < argc; i++ ) { diff --git a/colm/compile.cc b/colm/compile.cc index 4373b61c..371185e2 100644 --- a/colm/compile.cc +++ b/colm/compile.cc @@ -3080,11 +3080,8 @@ void ParseData::addStderr() void ParseData::addArgv() { - /* Make the type ref. */ - TypeRef *typeRef = new TypeRef( InputLoc(), findUniqueType( TYPE_TREE, argvList->langEl ) ); - /* Create the field and insert it into the map. */ - ObjField *el = new ObjField( InputLoc(), typeRef, "argv" ); + ObjField *el = new ObjField( InputLoc(), argvTypeRef, "argv" ); el->isArgv = true; el->isConst = true; globalObjectDef->insertField( el->name, el ); diff --git a/colm/lmparse.kl b/colm/lmparse.kl index 733701ae..b5cfd77a 100644 --- a/colm/lmparse.kl +++ b/colm/lmparse.kl @@ -2420,17 +2420,15 @@ void Parser::addArgvList() /* Get the language element. */ Namespace *nspace = namespaceStack.top(); - NamespaceQual *nspaceQual = new NamespaceQual( namespaceStack.top(), regionStack.top() ); - TypeRef *typeRef = new TypeRef( InputLoc(), nspaceQual, "str" ); - GenericType *generic = new GenericType( "argv_list", GEN_LIST, - pd->nextGenericId++, 0/*langEl*/, typeRef ); + NamespaceQual *nspaceQual1 = new NamespaceQual( + namespaceStack.top(), regionStack.top() ); + TypeRef *typeRef = new TypeRef( InputLoc(), nspaceQual1, "str" ); - nspace->genericList.append( generic ); + NamespaceQual *nspaceQual2 = new NamespaceQual( + namespaceStack.top(), regionStack.top() ); - pd->argvList = generic; - - /* Assume this in the VM. */ - assert( generic->id == 1 ); + pd->argvTypeRef = new TypeRef( TypeRef::List, InputLoc(), + nspaceQual2, typeRef, 0 ); } int Parser::parseLangEl( int type, const Token *token ) diff --git a/colm/parsedata.cc b/colm/parsedata.cc index 70692092..14c2743e 100644 --- a/colm/parsedata.cc +++ b/colm/parsedata.cc @@ -438,7 +438,7 @@ ParseData::ParseData( const String &fileName, const String §ionName, revertOn(true), predValue(0), nextMatchEndNum(0), - argvList(0), + argvTypeRef(0), context(0) { } diff --git a/colm/parsedata.h b/colm/parsedata.h index d5bdb781..3cca587c 100644 --- a/colm/parsedata.h +++ b/colm/parsedata.h @@ -985,7 +985,7 @@ struct ParseData long predValue; long nextMatchEndNum; - GenericType *argvList; + TypeRef *argvTypeRef; Context *context; }; diff --git a/colm/pdabuild.cc b/colm/pdabuild.cc index 92a2aff9..6fb6d787 100644 --- a/colm/pdabuild.cc +++ b/colm/pdabuild.cc @@ -1429,6 +1429,8 @@ void ParseData::makeRuntimeData() } } + runtimeData->argvGenericId = argvTypeRef->generic->id; + /* * Literals */ diff --git a/colm/pdacodegen.cc b/colm/pdacodegen.cc index 8561e76b..b72a83c4 100644 --- a/colm/pdacodegen.cc +++ b/colm/pdacodegen.cc @@ -425,6 +425,7 @@ void PdaCodeGen::writeRuntimeData( RuntimeData *runtimeData, PdaTables *pdaTable "\n" " " << genericInfo() << ",\n" " " << runtimeData->numGenerics << ",\n" + " " << runtimeData->argvGenericId << ",\n" "\n" " " << litdata() << ",\n" " " << litlen() << ",\n" diff --git a/colm/pdarun.h b/colm/pdarun.h index 211402bf..73b94c20 100644 --- a/colm/pdarun.h +++ b/colm/pdarun.h @@ -346,6 +346,8 @@ typedef struct _RuntimeData GenericInfo *genericInfo; long numGenerics; + long argvGenericId; + const char **litdata; long *litlen; Head **literals; diff --git a/colm/resolve.cc b/colm/resolve.cc index 56ebb06f..9b2d215d 100644 --- a/colm/resolve.cc +++ b/colm/resolve.cc @@ -693,6 +693,7 @@ void ParseData::resolveGenericTypes() } } + void ParseData::typeResolve() { /* @@ -715,4 +716,6 @@ void ParseData::typeResolve() makeTerminalWrappers(); makeEofElements(); resolveGenericTypes(); + + argvTypeRef->lookupType( this ); } diff --git a/test/accum3.lm b/test/accum3.lm index 81003b0d..3c1b194b 100644 --- a/test/accum3.lm +++ b/test/accum3.lm @@ -23,7 +23,7 @@ def args cons ArgParser: parser<args> [] -ArgV: argv_list ArgV = argv +ArgV: list<str> ArgV = argv for A: str in ArgV ArgParser << [A '\0'] diff --git a/test/argv1.exp b/test/argv1.exp index 568eda10..ea189a35 100644 --- a/test/argv1.exp +++ b/test/argv1.exp @@ -1,4 +1,4 @@ -<argv_list> +<__list0> <str>./argv1.bin</str> <str>a</str> <str>b</str> @@ -6,4 +6,4 @@ <str>1</str> <str>2</str> <str>3</str> -</argv_list> +</__list0> diff --git a/test/argv2.lm b/test/argv2.lm index 67b38d91..4c652c0e 100644 --- a/test/argv2.lm +++ b/test/argv2.lm @@ -41,7 +41,7 @@ def args cons ArgParser: parser<args>[] # Parse the args and extract the result into Args. -ArgV: argv_list = argv +ArgV: list<str> = argv for A: str in ArgV ArgParser << [A '\0'] Args: args = ArgParser.finish() |