diff options
author | Adrian Thurston <thurston@colm.net> | 2018-05-04 20:16:45 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2018-05-04 20:17:09 -0400 |
commit | 4cd76a8dbe465ef293c2c96ba586720c1ab65c08 (patch) | |
tree | 9dd0137adde7505cb25ebfb5c0c7bd7cf332aee3 | |
parent | a6436943ef56e70e1b18ce72a3f6aa5bf88cff7b (diff) | |
download | colm-4cd76a8dbe465ef293c2c96ba586720c1ab65c08.tar.gz |
replacing the void LEL with a keyword and TYPE_VOID (non-tree)
Using LEL was a hack to make it work quickly, usig a non-tree type is the
proper solution.
-rw-r--r-- | src/bytecode.h | 5 | ||||
-rw-r--r-- | src/colm.lm | 2 | ||||
-rw-r--r-- | src/compiler.h | 1 | ||||
-rw-r--r-- | src/declare.cc | 3 | ||||
-rw-r--r-- | src/loadcolm.cc | 4 | ||||
-rw-r--r-- | src/parsetree.cc | 1 | ||||
-rw-r--r-- | src/pdabuild.cc | 20 | ||||
-rw-r--r-- | src/synthesis.cc | 8 | ||||
-rw-r--r-- | src/tree.c | 8 | ||||
-rw-r--r-- | src/type.h | 3 |
10 files changed, 26 insertions, 29 deletions
diff --git a/src/bytecode.h b/src/bytecode.h index cb5d1a06..ab6bc60b 100644 --- a/src/bytecode.h +++ b/src/bytecode.h @@ -447,9 +447,8 @@ enum GEN { /* Known language element ids. */ enum LEL_ID { LEL_ID_PTR = 1, - LEL_ID_VOID = 2, - LEL_ID_STR = 3, - LEL_ID_IGNORE = 4 + LEL_ID_STR = 2, + LEL_ID_IGNORE = 3 }; /* diff --git a/src/colm.lm b/src/colm.lm index 99112316..3f719686 100644 --- a/src/colm.lm +++ b/src/colm.lm @@ -55,6 +55,7 @@ lex token DEFAULT / 'default' / token INT / 'int' / token BOOL / 'bool' / + token VOID / 'void' / token MAKE_TOKEN / 'make_token' / token MAKE_TREE / 'make_tree' / @@ -643,6 +644,7 @@ def type_ref [region_qual id opt_repeat] :Id | [INT] :Int | [BOOL] :Bool +| [VOID] :Void | [PARSER LT type_ref GT] :Parser | [LIST LT type_ref GT] :List | [MAP LT KeyType: type_ref COMMA ValType: type_ref GT] :Map diff --git a/src/compiler.h b/src/compiler.h index 085fdd1d..a9fe2558 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -894,7 +894,6 @@ struct Compiler GenericType *anyVector; LangEl *ptrLangEl; - LangEl *voidLangEl; LangEl *strLangEl; LangEl *anyLangEl; LangEl *rootLangEl; diff --git a/src/declare.cc b/src/declare.cc index 6ff781ac..281c4940 100644 --- a/src/declare.cc +++ b/src/declare.cc @@ -30,7 +30,7 @@ void Compiler::initUniqueTypes( ) { uniqueTypeNil = new UniqueType( TYPE_NIL ); - uniqueTypeVoid = new UniqueType( TYPE_TREE, voidLangEl ); + uniqueTypeVoid = new UniqueType( TYPE_VOID ); uniqueTypePtr = new UniqueType( TYPE_TREE, ptrLangEl ); uniqueTypeBool = new UniqueType( TYPE_BOOL ); uniqueTypeInt = new UniqueType( TYPE_INT ); @@ -337,7 +337,6 @@ void Compiler::declareBaseLangEls() noTokenLangEl->isIgnore = true; ptrLangEl = declareLangEl( this, rootNamespace, "ptr", LangEl::Term ); - voidLangEl = declareLangEl( this, rootNamespace, "void", LangEl::Term ); strLangEl = declareLangEl( this, rootNamespace, "str", LangEl::Term ); ignoreLangEl = declareLangEl( this, rootNamespace, "il", LangEl::Term ); diff --git a/src/loadcolm.cc b/src/loadcolm.cc index d5a57385..9f47789f 100644 --- a/src/loadcolm.cc +++ b/src/loadcolm.cc @@ -898,6 +898,10 @@ struct LoadColm tr = TypeRef::cons( internal, pd->uniqueTypeBool ); break; } + case type_ref::Void: { + tr = TypeRef::cons( internal, pd->uniqueTypeVoid ); + break; + } case type_ref::Parser: { TypeRef *type = walkTypeRef( typeRef._type_ref() ); tr = TypeRef::cons( typeRef.loc(), TypeRef::Parser, 0, type, 0 ); diff --git a/src/parsetree.cc b/src/parsetree.cc index 1fa26de8..0b1cdbeb 100644 --- a/src/parsetree.cc +++ b/src/parsetree.cc @@ -122,6 +122,7 @@ int CmpUniqueType::compare( const UniqueType &ut1, const UniqueType &ut2 ) case TYPE_BOOL: case TYPE_LIST_PTRS: case TYPE_MAP_PTRS: + case TYPE_VOID: break; case TYPE_STRUCT: diff --git a/src/pdabuild.cc b/src/pdabuild.cc index 2ce1cecb..62baa06d 100644 --- a/src/pdabuild.cc +++ b/src/pdabuild.cc @@ -268,14 +268,14 @@ void Compiler::refNameSpace( LangEl *lel, Namespace *nspace ) void Compiler::makeLangElNames() { for ( LelList::Iter lel = langEls; lel.lte(); lel++ ) { - if ( lel->id == LEL_ID_VOID ) { - lel->fullName = "_void"; - lel->fullLit = "_void"; - lel->refName = "_void"; - lel->declName = "_void"; - lel->xmlTag = "void"; - - } +// if ( lel->id == LEL_ID_VOID ) { +// lel->fullName = "_void"; +// lel->fullLit = "_void"; +// lel->refName = "_void"; +// lel->declName = "_void"; +// lel->xmlTag = "void"; +// +// } // else if ( lel->id == LEL_ID_INT ) { // lel->fullName = "_int"; // lel->fullLit = "_int"; @@ -290,13 +290,13 @@ void Compiler::makeLangElNames() // lel->declName = "_bool"; // lel->xmlTag = "bool"; // } - else { +// else { lel->fullName = lel->name; lel->fullLit = lel->lit; lel->refName = lel->lit; lel->declName = lel->lit; lel->xmlTag = lel->name; - } +// } /* If there is also a namespace next to the type, we add a prefix to * the type. It's not convenient to name C++ classes the same as a diff --git a/src/synthesis.cc b/src/synthesis.cc index b7b50515..d1b8fbbc 100644 --- a/src/synthesis.cc +++ b/src/synthesis.cc @@ -1572,7 +1572,7 @@ UniqueType *LangTerm::evaluateParse( Compiler *pd, CodeVect &code, case ConsItem::ExprType: { UniqueType *ut = item->expr->evaluate( pd, code ); - if ( ut->typeId == TYPE_TREE && ut->langEl == pd->voidLangEl ) { + if ( ut->typeId == TYPE_VOID ) { /* Clear it away if return type is void. */ code.append( IN_POP_VAL ); continue; @@ -1687,7 +1687,7 @@ void ConsItemList::evaluateSendStream( Compiler *pd, CodeVect &code ) } case ConsItem::ExprType: UniqueType *ut = item->expr->evaluate( pd, code ); - if ( ut->typeId == TYPE_TREE && ut->langEl == pd->voidLangEl ) { + if ( ut->typeId == TYPE_VOID ) { /* Clear it away if the the return type is void. */ code.append( IN_POP_VAL ); code.append( IN_POP_VAL ); @@ -1755,7 +1755,7 @@ void LangTerm::evaluateSendParser( Compiler *pd, CodeVect &code, bool strings ) } case ConsItem::ExprType: UniqueType *ut = item->expr->evaluate( pd, code ); - if ( ut->typeId == TYPE_TREE && ut->langEl == pd->voidLangEl ) { + if ( ut->typeId == TYPE_VOID ) { /* Clear it away if return type is void. */ code.append( IN_POP_VAL ); continue; @@ -2648,7 +2648,7 @@ void LangStmt::compile( Compiler *pd, CodeVect &code ) const case ExprType: { /* Evaluate the exrepssion, then pop it immediately. */ UniqueType *exprUt = expr->evaluate( pd, code ); - if ( exprUt->tree() && exprUt->langEl != pd->voidLangEl ) + if ( exprUt->tree() ) code.append( IN_POP_TREE ); else code.append( IN_POP_VAL ); @@ -890,17 +890,9 @@ tree_t *split_tree( program_t *prg, tree_t *tree ) void tree_free_rec( program_t *prg, tree_t **sp, tree_t *tree ) { tree_t **top = vm_ptop(); -// struct lang_el_info *lelInfo; -// long genericId; free_tree: -// lelInfo = prg->rtd->lelInfo; -// genericId = lelInfo[tree->id].genericId; -// assert( genericId == 0 ); - switch ( tree->id ) { -// case LEL_ID_BOOL: -// case LEL_ID_INT: case LEL_ID_PTR: tree_free( prg, tree ); break; @@ -35,7 +35,8 @@ enum TYPE TYPE_INT = 0x07, TYPE_BOOL = 0x08, TYPE_LIST_PTRS = 0x09, - TYPE_MAP_PTRS = 0x0a + TYPE_MAP_PTRS = 0x0a, + TYPE_VOID = 0x0b }; #endif /* _COLM_TYPE_H */ |