diff options
author | Adrian Thurston <thurston@complang.org> | 2015-06-07 15:35:02 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2015-06-07 15:35:02 -0400 |
commit | 9ed46192f42837b4c066b5e1ebf859c9f5070106 (patch) | |
tree | a6b04026c8a95a344fae7abe96058666d2a9397e /src/loadcolm.cc | |
parent | c158a685a7bad2c4d06b4c160704b6913f5e70bf (diff) | |
download | colm-9ed46192f42837b4c066b5e1ebf859c9f5070106.tar.gz |
now creating list and map el structures in the declare pass
Diffstat (limited to 'src/loadcolm.cc')
-rw-r--r-- | src/loadcolm.cc | 101 |
1 files changed, 7 insertions, 94 deletions
diff --git a/src/loadcolm.cc b/src/loadcolm.cc index 6071beea..027ffedb 100644 --- a/src/loadcolm.cc +++ b/src/loadcolm.cc @@ -826,91 +826,25 @@ struct LoadColm TypeRef *walkValueList( type_ref typeRef ) { TypeRef *valType = walkTypeRef( typeRef._type_ref() ); - - /* Create the value list element. */ - String name( 32, "vlist_el_%s", valType->stringify().c_str() ); - - if ( !genericElDefined.find( name ) ) { - genericElDefined.insert( name ); - - structHead( internal, pd->rootNamespace, name, ObjectDef::StructType ); - - /* Var def. */ - String id = "value"; - ObjectField *elValObjField = ObjectField::cons( internal, - ObjectField::StructFieldType, valType, id ); - structVarDef( internal, elValObjField ); - elValObjField->context->listEl = true; - - /* List El. */ - listElDef( "el" ); - - structStack.pop(); - namespaceStack.pop(); - } - - TypeRef *elType = TypeRef::cons( typeRef.loc(), emptyNspaceQual(), name ); + TypeRef *elType = TypeRef::cons( typeRef.loc(), TypeRef::ListEl, valType ); return TypeRef::cons( typeRef.loc(), TypeRef::List, 0, elType, valType ); } TypeRef *walkListEl( type_ref typeRef ) { TypeRef *valType = walkTypeRef( typeRef._type_ref() ); - - /* Create the value list element. */ - String name( 32, "vlist_el_%s", valType->stringify().c_str() ); - - if ( !genericElDefined.find( name ) ) { - genericElDefined.insert( name ); - - structHead( internal, pd->rootNamespace, name, ObjectDef::StructType ); - - /* Var def. */ - String id = "value"; - ObjectField *elValObjField = ObjectField::cons( internal, - ObjectField::StructFieldType, valType, id ); - structVarDef( internal, elValObjField ); - elValObjField->context->listEl = true; - - /* List El. */ - listElDef( "el" ); - - structStack.pop(); - namespaceStack.pop(); - } - - return TypeRef::cons( typeRef.loc(), emptyNspaceQual(), name ); + return TypeRef::cons( typeRef.loc(), TypeRef::ListEl, valType ); } TypeRef *walkValueMap( type_ref typeRef ) { TypeRef *keyType = walkTypeRef( typeRef.KeyType() ); TypeRef *valType = walkTypeRef( typeRef.ValType() ); + TypeRef *elType = TypeRef::cons( typeRef.loc(), + TypeRef::MapEl, 0, keyType, valType ); - String name( 32, "vmap_el_%s_%s", keyType->stringify().c_str(), - valType->stringify().c_str() ); - - if ( !genericElDefined.find( name ) ) { - genericElDefined.insert( name ); - - structHead( internal, pd->rootNamespace, name, ObjectDef::StructType ); - - /* Var def. */ - String id = "value"; - ObjectField *elValObjField = ObjectField::cons( internal, - ObjectField::StructFieldType, valType, id ); - structVarDef( internal, elValObjField ); - - /* Map El. */ - mapElDef( "el", keyType ); - - structStack.pop(); - namespaceStack.pop(); - } - - TypeRef *elType = TypeRef::cons( typeRef.loc(), emptyNspaceQual(), name ); - - return TypeRef::cons( typeRef.loc(), TypeRef::Map, 0, keyType, elType, valType ); + return TypeRef::cons( typeRef.loc(), TypeRef::Map, 0, + keyType, elType, valType ); } TypeRef *walkMapEl( type_ref typeRef ) @@ -918,28 +852,7 @@ struct LoadColm TypeRef *keyType = walkTypeRef( typeRef.KeyType() ); TypeRef *valType = walkTypeRef( typeRef.ValType() ); - String name( 32, "vmap_el_%s_%s", keyType->stringify().c_str(), - valType->stringify().c_str() ); - - if ( !genericElDefined.find( name ) ) { - genericElDefined.insert( name ); - - structHead( internal, pd->rootNamespace, name, ObjectDef::StructType ); - - /* Var def. */ - String id = "value"; - ObjectField *elValObjField = ObjectField::cons( internal, - ObjectField::StructFieldType, valType, id ); - structVarDef( internal, elValObjField ); - - /* Map El. */ - mapElDef( "el", keyType ); - - structStack.pop(); - namespaceStack.pop(); - } - - return TypeRef::cons( typeRef.loc(), emptyNspaceQual(), name ); + return TypeRef::cons( typeRef.loc(), TypeRef::MapEl, 0, keyType, valType ); } TypeRef *walkTypeRef( type_ref typeRef ) |