@@ -706,8 +706,6 @@ void MetaCSemantic_ComputeEnumValues(metac_sema_state_t* self,
706706 decl_type_enum_t * enum_ ,
707707 metac_type_enum_t * semaEnum )
708708{
709- uint32_t lastUnresolvedMembers = 0 ;
710- uint32_t unresolvedMembers = 0 ;
711709 decl_enum_member_t * member = enum_ -> Members ;
712710 int64_t nextValue = 0 ;
713711 const uint32_t memberCount = enum_ -> MemberCount ;
@@ -770,10 +768,13 @@ void MetaCSemantic_ComputeEnumValues(metac_sema_state_t* self,
770768 // Since we are inserting members
771769 self -> CurrentScope -> ScopeTable .AllowOverride = true;
772770 {
771+ uint32_t lastUnresolvedMembers = 0 ;
772+ uint32_t unresolvedMembers = 0 ;
773+
773774 const char * eName = IdentifierPtrToCharPtr (self -> ParserIdentifierTable , enum_ -> Identifier );
774- MetaCSemantic_PushOnResolveFail (self , OnResolveFail_ReturnNull );
775775 do
776776 {
777+ MetaCSemantic_PushOnResolveFail (self , OnResolveFail_ReturnNull );
777778 lastUnresolvedMembers = unresolvedMembers ;
778779
779780 member = enum_ -> Members ;
@@ -803,16 +804,12 @@ void MetaCSemantic_ComputeEnumValues(metac_sema_state_t* self,
803804 }
804805 }
805806 assert (METAC_NODE (member ) == emptyNode );
807+ MetaCSemantic_PopOnResolveFail (self );
806808
807- if (!unresolvedMembers )
808- {
809- MetaCSemantic_PopOnResolveFail (self );
810- }
811- else if (unresolvedMembers == lastUnresolvedMembers )
809+ if (unresolvedMembers == lastUnresolvedMembers )
812810 {
813811 // we have a the same number of unresolved members as last round
814812 // which indicates a lack of local progress.
815- MetaCSemantic_PopOnResolveFail (self );
816813 YIELD ("Yielding because we are waiting for more enum members to become resolvable" );
817814 }
818815 } while (unresolvedMembers );
@@ -1155,53 +1152,46 @@ metac_type_index_t MetaCSemantic_TypeSemantic(metac_sema_state_t* self,
11551152 tmpSemaAgg -> FieldCount = agg -> FieldCount ;
11561153
11571154 PopulateTemporaryAggregateScope (self , tmpSemaAgg , agg );
1155+ MetaCSemantic_MountScope (self , tmpSemaAgg -> Scope );
11581156
1159- switch ( typeKind )
1157+ if ( agg -> ParameterCount != 0 )
11601158 {
1161- case type_struct :
1159+ uint32_t parameterCount = agg -> ParameterCount ;
1160+ decl_parameter_t * param = agg -> Parameters ;
1161+ U32 (tmpTemplateScope .ScopeFlags ) |= scope_flag_temporary ;
1162+ MetaCSemantic_PushTemporaryScope (self , & tmpTemplateScope );
1163+
1164+ for (uint32_t paramIdx = 0 ; paramIdx < parameterCount ; paramIdx ++ )
11621165 {
1163- uint32_t hash = 0 ;
1164- MetaCSemantic_MountScope (self , tmpSemaAgg -> Scope );
1166+ metac_identifier_ptr_t paramIdent = param -> Parameter -> VarIdentifier ;
1167+ metac_location_ptr_t locIdx = param -> Parameter -> LocationIdx ;
1168+ metac_expr_t placeholderExpr ;
1169+ metac_sema_expr_t * placeholder = AllocNewSemaExpr (self , & placeholderExpr );
11651170
1166- if (agg -> ParameterCount != 0 )
1167- {
1168- uint32_t parameterCount = agg -> ParameterCount ;
1169- decl_parameter_t * param = agg -> Parameters ;
1170- U32 (tmpTemplateScope .ScopeFlags ) |= scope_flag_temporary ;
1171- MetaCSemantic_PushTemporaryScope (self , & tmpTemplateScope );
1172- xprintf ("We have a template\n" );
1173-
1174- for (uint32_t paramIdx = 0 ; paramIdx < parameterCount ; paramIdx ++ )
1175- {
1176- metac_identifier_ptr_t paramIdent = param -> Parameter -> VarIdentifier ;
1177- metac_location_ptr_t locIdx = param -> Parameter -> LocationIdx ;
1178- metac_expr_t placeholderExpr ;
1179- metac_sema_expr_t * placeholder = AllocNewSemaExpr (self , & placeholderExpr );
1171+ placeholder -> Kind = expr_unknown_value ;
1172+ placeholder -> TypeIndex = MetaCSemantic_TypeSemantic (self , param -> Parameter -> VarType );
1173+ METAC_NODE (placeholder -> Expr ) = emptyNode ;
1174+ placeholder -> LocationIdx = locIdx ;
11801175
1181- placeholder -> Kind = expr_unknown_value ;
1182- placeholder -> TypeIndex = MetaCSemantic_TypeSemantic (self , param -> Parameter -> VarType );
1183- METAC_NODE (placeholder -> Expr ) = emptyNode ;
1184- placeholder -> LocationIdx = locIdx ;
11851176
1177+ MetaCSemantic_RegisterInScope (self , paramIdent , METAC_NODE (placeholder ));
11861178
1187- MetaCSemantic_RegisterInScope (self , paramIdent , METAC_NODE (placeholder ));
1188-
1189- param = param -> Next ;
1190- }
1191- }
1179+ param = param -> Next ;
1180+ }
1181+ }
11921182
1183+ switch (typeKind )
1184+ {
1185+ case type_struct :
1186+ {
1187+ uint32_t hash ;
11931188 MetaCSemantic_ComputeStructLayout (self , agg , tmpSemaAgg );
11941189
11951190 if (agg -> ParameterCount != 0 )
11961191 {
11971192 MetaCSemantic_PopTemporaryScope (self );
11981193 }
1199-
1200- MetaCSemantic_UnmountScope (self );
1201-
1202- hash = AggregateHash (tmpSemaAgg );
1203-
1204- tmpSemaAgg -> Header .Hash = hash ;
1194+ tmpSemaAgg -> Header .Hash = AggregateHash (tmpSemaAgg );
12051195
12061196 result =
12071197 MetaCTypeTable_GetOrEmptyStructType (& self -> StructTypeTable , tmpSemaAgg );
@@ -1230,6 +1220,8 @@ metac_type_index_t MetaCSemantic_TypeSemantic(metac_sema_state_t* self,
12301220 default : assert (0 );
12311221
12321222 }
1223+
1224+ MetaCSemantic_UnmountScope (self );
12331225 }
12341226 else if (IsPointerType (type -> Kind ))
12351227 {
0 commit comments