@@ -60,6 +60,21 @@ static inline bool isBasicType(metac_type_kind_t typeKind)
6060 return false;
6161}
6262
63+ bool IsUnknownType (metac_sema_state_t * self ,
64+ metac_type_index_t typeIndex )
65+ {
66+ if (TYPE_INDEX_KIND (typeIndex ) == type_index_unknown )
67+ {
68+ return true;
69+ }
70+ if (TYPE_INDEX_KIND (typeIndex ) == type_index_array )
71+ {
72+ return IsUnknownType (self , self -> ArrayTypeTable .Slots [TYPE_INDEX_INDEX (typeIndex )].TypeIndex );
73+ }
74+
75+ return false;
76+ }
77+
6378sema_decl_type_t * MetaCSemantic_GetTypeNode (metac_sema_state_t * self ,
6479 metac_type_index_t typeIndex )
6580{
@@ -1121,22 +1136,6 @@ metac_type_index_t MetaCSemantic_TypeSemantic(metac_sema_state_t* self,
11211136 metac_type_aggregate_t * tmpSemaAgg = & tmpSemaAggMem ;
11221137 metac_scope_t tmpTemplateScope = {0 };
11231138
1124- if (agg -> ParameterCount != 0 )
1125- {
1126- U32 (tmpTemplateScope .ScopeFlags ) |= scope_flag_temporary ;
1127- MetaCSemantic_PushTemporaryScope (self , & tmpTemplateScope );
1128- for (decl_parameter_t * param = agg -> Parameters ;
1129- METAC_NODE (param -> Next ) != emptyNode ;
1130- param = param -> Next )
1131- {
1132- metac_expr_t placeHolder ;
1133-
1134- AllocNewSemaExpr (self , )
1135- metac_node_t unsresolvedNode = (metac_node_t ) 0x2 ;
1136- MetaCScope_RegisterIdentifier (& tmpTemplateScope , param -> Parameter -> VarIdentifier , unresolvedNode );
1137- }
1138- xprintf ("We have a template\n" );
1139- }
11401139
11411140 if (type -> Kind == decl_type_struct )
11421141 typeKind = type_struct ;
@@ -1159,16 +1158,30 @@ metac_type_index_t MetaCSemantic_TypeSemantic(metac_sema_state_t* self,
11591158 case type_struct :
11601159 {
11611160 uint32_t hash = 0 ;
1162- metac_node_t unresolvedNode = emptyNode ;
11631161 MetaCSemantic_MountScope (self , tmpSemaAgg -> Scope );
11641162
11651163 if (agg -> ParameterCount != 0 )
11661164 {
11671165 uint32_t parameterCount = agg -> ParameterCount ;
11681166 decl_parameter_t * param = agg -> Parameters ;
1167+ U32 (tmpTemplateScope .ScopeFlags ) |= scope_flag_temporary ;
1168+ MetaCSemantic_PushTemporaryScope (self , & tmpTemplateScope );
1169+ xprintf ("We have a template\n" );
1170+
11691171 for (uint32_t paramIdx = 0 ; paramIdx < parameterCount ; paramIdx ++ )
11701172 {
1171- MetaCSemantic_RegisterInScope (self , param -> Parameter -> VarIdentifier , unresolvedNode );
1173+ metac_identifier_ptr_t paramIdent = param -> Parameter -> VarIdentifier ;
1174+ metac_location_ptr_t locIdx = param -> Parameter -> LocationIdx ;
1175+ metac_expr_t placeholderExpr ;
1176+ metac_sema_expr_t * placeholder = AllocNewSemaExpr (self , & placeholderExpr );
1177+
1178+ placeholder -> Kind = expr_unknown_value ;
1179+ placeholder -> TypeIndex = MetaCSemantic_TypeSemantic (self , param -> Parameter -> VarType );
1180+ METAC_NODE (placeholder -> Expr ) = emptyNode ;
1181+
1182+
1183+ MetaCSemantic_RegisterInScope (self , paramIdent , placeholder );
1184+
11721185 param = param -> Next ;
11731186 }
11741187 }
@@ -1609,7 +1622,7 @@ bool MetaCSemantic_ComputeStructLayout(metac_sema_state_t* self,
16091622{
16101623 bool result = true;
16111624
1612- assert (self -> CurrentScope == semaAgg -> Scope );
1625+ assert (self -> CurrentScope == semaAgg -> Scope || (( self -> CurrentScope -> ScopeFlags & scope_flag_temporary ) && self -> CurrentScope -> Parent == semaAgg -> Scope ) );
16131626 // make sure the scope is mounted.
16141627 assert (semaAgg -> Fields && semaAgg -> Fields != emptyPointer );
16151628
@@ -1627,6 +1640,11 @@ bool MetaCSemantic_ComputeStructLayout(metac_sema_state_t* self,
16271640
16281641 semaField -> Type =
16291642 MetaCSemantic_doTypeSemantic (self , declField -> Field -> VarType );
1643+ if (IsUnknownType (self , semaField -> Type ))
1644+ {
1645+ xprintf ("Found unknown type \n" );
1646+ return false;
1647+ }
16301648#ifndef NO_FIBERS
16311649 while (!semaField -> Type .v )
16321650 {
@@ -1652,6 +1670,10 @@ bool MetaCSemantic_ComputeStructLayout(metac_sema_state_t* self,
16521670 // YIELD_ON(declField->Field->VarType, MetaCSemantic_doTypeSemantic);
16531671 }
16541672#endif
1673+ if (!semaField -> Type .v )
1674+ {
1675+ return false;
1676+ }
16551677 declField = declField -> Next ;
16561678 }
16571679
0 commit comments