diff options
Diffstat (limited to 'compiler_and_linker/FrontEnd/C/CScope.c')
-rw-r--r-- | compiler_and_linker/FrontEnd/C/CScope.c | 413 |
1 files changed, 209 insertions, 204 deletions
diff --git a/compiler_and_linker/FrontEnd/C/CScope.c b/compiler_and_linker/FrontEnd/C/CScope.c index f15787c..a59a8a7 100644 --- a/compiler_and_linker/FrontEnd/C/CScope.c +++ b/compiler_and_linker/FrontEnd/C/CScope.c @@ -1,17 +1,29 @@ -#include "compiler.h" +#include "compiler/CScope.h" +#include "compiler/CClass.h" +#include "compiler/CDecl.h" #include "compiler/CError.h" #include "compiler/CMangler.h" #include "compiler/CParser.h" #include "compiler/CPrep.h" -#include "compiler/CScope.h" +#include "compiler/CPrepTokenizer.h" +#include "compiler/CTemplateClass.h" +#include "compiler/CTemplateNew.h" +#include "compiler/CTemplateTools.h" +#include "compiler/CompilerTools.h" #include "compiler/enode.h" #include "compiler/objects.h" #include "compiler/scopes.h" #include "compiler/templates.h" #include "compiler/types.h" +typedef enum ELookupType { + Lookup_0, + Lookup_1, + Lookup_2 +} ELookupType; + static Boolean cscope_isambig; -static UInt8 cscope_lookuptype; +static ELookupType cscope_lookuptype; static SInt32 cscope_foundclassoffset; static TemplClass *cscope_foundtemplate; static TypeClass *cscope_foundclass; @@ -23,14 +35,14 @@ TypeClass *cscope_currentclass; NameSpace *cscope_current; NameSpace *cscope_root; -void CScope_Setup() { +void CScope_Setup(void) { cscope_current = cscope_root = CScope_NewHashNameSpace(0); cscope_currentclass = NULL; cscope_currentfunc = NULL; cscope_is_member_func = 0; } -void CScope_Cleanup() { +void CScope_Cleanup(void) { } void CScope_GetScope(CScopeSave *save) { @@ -113,16 +125,15 @@ void CScope_RestoreScope(CScopeSave *saved) { } static Boolean CScope_ObjectIsFunction(Object *obj) { - return obj->otype == OT_OBJECT && obj->type->type == TYPEFUNC; + return obj->otype == OT_OBJECT && IS_TYPE_FUNC(obj->type); } -Boolean CScope_IsEmptySymTable() { +Boolean CScope_IsEmptySymTable(void) { NameSpaceObjectList *scan; NameSpaceName *nsname; int i; -#line 232 - CError_ASSERT(cscope_root->is_hash); + CError_ASSERT(232, cscope_root->is_hash); i = 0; do { @@ -157,9 +168,9 @@ static void CScope_AppendNameSpaceName(NameSpaceName *nsn) { static void CScope_AmbigNameError(NameSpace *nspace1, NameSpace *nspace2, HashNameNode *name) { if (name && nspace1 != nspace2) { - CError_Error(319, CError_GetNameString(nspace1, name), CError_GetNameString(nspace2, name)); + CError_Error(CErrorStr319, CError_GetNameString(nspace1, name), CError_GetNameString(nspace2, name)); } else { - CError_Error(188, nspace2); + CError_Error(CErrorStr188, nspace2); } } @@ -248,8 +259,7 @@ NameSpaceObjectList *CScope_InsertName(NameSpace *nspace, HashNameNode *name) { static NameSpaceObjectList *CScope_AppendName(NameSpace *nspace, HashNameNode *name) { NameSpaceName *nsname; NameSpaceName *scan; -#line 387 - CError_ASSERT(!nspace->is_hash); + CError_ASSERT(387, !nspace->is_hash); if (nspace->is_global) nsname = galloc(sizeof(NameSpaceName)); @@ -327,14 +337,13 @@ restart: case TYPEMEMBERPOINTER: list = CScope_BuildTypeAssociatedNameSpaceList(list, TYPE_MEMBER_POINTER(type)->ty1); type = TYPE_MEMBER_POINTER(type)->ty2; - if (type->type != TYPECLASS) + if (!IS_TYPE_CLASS(type)) break; case TYPECLASS: list = CScope_AddNameSpaceToList(list, TYPE_CLASS(type)->nspace); break; default: -#line 494 - CError_FATAL(); + CError_FATAL(494); } return list; @@ -366,7 +375,7 @@ NameSpaceObjectList *CScope_ArgumentDependentNameLookup(NameSpaceObjectList *lis for (iscan = CScope_FindQualName(scan->nspace, name); iscan; iscan = iscan->next) { if (iscan->object->otype != OT_OBJECT) continue; - if (OBJECT(iscan->object)->type->type != TYPEFUNC) + if (!IS_TYPE_FUNC(OBJECT(iscan->object)->type)) continue; if (flag && (TYPE_FUNC(OBJECT(iscan->object)->type)->flags & FUNC_FLAGS_METHOD)) continue; @@ -441,16 +450,14 @@ Boolean CScope_IsStdNameSpace(NameSpace *nspace) { } Boolean CScope_IsEmptyNameSpace(NameSpace *nspace) { -#line 664 - CError_ASSERT(!nspace->is_hash); + CError_ASSERT(664, !nspace->is_hash); return !nspace->data.list; } void CScope_MergeNameSpace(NameSpace *dst, NameSpace *src) { NameSpaceName *nsname; -#line 678 - CError_ASSERT(!dst->is_hash && !src->is_hash); + CError_ASSERT(678, !dst->is_hash && !src->is_hash); if ((nsname = dst->data.list)) { while (nsname->next) @@ -473,19 +480,19 @@ void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj) { newlist = lalloc(sizeof(NameSpaceObjectList)); if (obj->otype == OT_NAMESPACE || objlist->object->otype == OT_NAMESPACE) { - CError_Error(322/*, objlist->object*/); + CError_Error(CErrorStr322/*, objlist->object*/); return; } if (obj->otype == OT_TYPETAG) { do { if (objlist->object->otype == OT_TYPETAG) { - CError_Error(322/*, objlist->object*/); + CError_Error(CErrorStr322/*, objlist->object*/); return; } if (copts.cplusplus && objlist->object->otype == OT_TYPE && !is_typesame(OBJ_TYPE_TAG(obj)->type, OBJ_TYPE(objlist->object)->type)) { - CError_Error(332); + CError_Error(CErrorStr332); return; } @@ -501,12 +508,11 @@ void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj) { if (objlist->object->otype == OT_TYPETAG) { if (copts.cplusplus && obj->otype == OT_TYPE && !is_typesame(OBJ_TYPE(obj)->type, OBJ_TYPE_TAG(objlist->object)->type)) { - CError_Error(332); + CError_Error(CErrorStr332); return; } -#line 739 - CError_ASSERT(!objlist->next); + CError_ASSERT(739, !objlist->next); newlist->object = objlist->object; newlist->next = NULL; @@ -516,7 +522,7 @@ void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj) { } if (!copts.cplusplus || !CScope_ObjectIsFunction(OBJECT(obj))) { - CError_Error(322); + CError_Error(CErrorStr322); return; } @@ -530,7 +536,7 @@ void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj) { } if (!CScope_ObjectIsFunction(OBJECT(objlist->object))) { - CError_Error(322); + CError_Error(CErrorStr322); return; } @@ -597,8 +603,7 @@ NameSpaceLookupList *CScope_BuildNameSpaceLookupList(NameSpace *nspace) { goto foundIt; } } -#line 853 - CError_FATAL(); + CError_FATAL(853); foundIt: for (current2 = currentL->namespaces; current2; current2 = current2->next) { if (current2->nspace == current->nspace) @@ -718,8 +723,7 @@ restart: case OT_NAMESPACE: return OBJ_NAMESPACE(list->object)->nspace; default: -#line 1052 - CError_FATAL(); + CError_FATAL(1052); break; case OT_ENUMCONST: case OT_MEMBERVAR: @@ -728,10 +732,10 @@ restart: goto restart; } - if (type->type != TYPECLASS) { - if (type->type == TYPETEMPLATE) + if (!IS_TYPE_CLASS(type)) { + if (IS_TYPE_TEMPLATE(type)) return NULL; - CError_Error(320); + CError_Error(CErrorStr320); if (fail) *fail = 1; return NULL; @@ -741,13 +745,13 @@ restart: } static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClass *tclass, SInt32 offset) { - // does not match, r24 and r23 are swapped at the end x.x Boolean fail; NameSpace *nspace; NameSpaceObjectList *list; - ClassList *base; TypeClass *bestClass; - BClassList *bestBase, *n; + BClassList *bestBase; + ClassList *base; + BClassList *n; BClassList *candidate; SInt32 thisoffset; BClassList *newlist; @@ -761,7 +765,7 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas } switch (cscope_lookuptype) { - case 2: + case Lookup_2: fail = 0; if ((nspace = CScope_ExtractNameSpace(list, &fail))) { if (cscope_foundclass) { @@ -780,20 +784,20 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas newlist = lalloc(sizeof(BClassList)); newlist->next = NULL; - newlist->type = (Type *) tclass; + newlist->type = TYPE(tclass); return newlist; } if (fail) return NULL; break; - case 0: + case Lookup_0: if (cscope_foundclass) { if ( list->object->otype == OT_TYPETAG && result->nsol_14->object->otype == OT_TYPETAG - && OBJ_TYPE_TAG(list->object)->type->type == TYPECLASS - && OBJ_TYPE_TAG(result->nsol_14->object)->type->type == TYPECLASS + && IS_TYPE_CLASS(OBJ_TYPE_TAG(list->object)->type) + && IS_TYPE_CLASS(OBJ_TYPE_TAG(result->nsol_14->object)->type) && (TYPE_CLASS(OBJ_TYPE_TAG(list->object)->type)->flags & CLASS_FLAGS_800) && (TYPE_CLASS(OBJ_TYPE_TAG(result->nsol_14->object)->type)->flags & CLASS_FLAGS_800) && TEMPL_CLASS_INST(OBJ_TYPE_TAG(list->object)->type)->templ == TEMPL_CLASS_INST(OBJ_TYPE_TAG(result->nsol_14->object)->type)->templ @@ -816,9 +820,9 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas result->nsol_14 = list; newlist = lalloc(sizeof(BClassList)); newlist->next = NULL; - newlist->type = (Type *) tclass; + newlist->type = TYPE(tclass); return newlist; - case 1: + case Lookup_1: for (; list; list = list->next) { if (list->object->otype == OT_TYPETAG) { if (cscope_foundclass) { @@ -836,14 +840,13 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas result->x8 = OBJ_TYPE_TAG(list->object)->type; newlist = lalloc(sizeof(BClassList)); newlist->next = NULL; - newlist->type = (Type *) tclass; + newlist->type = TYPE(tclass); return newlist; } } break; default: -#line 1202 - CError_FATAL(); + CError_FATAL(1202); } } @@ -852,7 +855,7 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas if ((candidate = CScope_RecFindClassMember(result, base->base, thisoffset))) { n = lalloc(sizeof(BClassList)); n->next = candidate; - n->type = (Type *) tclass; + n->type = TYPE(tclass); if (bestBase && bestClass == cscope_foundclass) { if (CClass_IsMoreAccessiblePath(n, bestBase)) bestBase = n; @@ -866,7 +869,7 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas return bestBase; } -static Boolean CScope_FindClassMember(CScopeParseResult *result, NameSpace *nspace, HashNameNode *name, UInt8 lookupType) { +static Boolean CScope_FindClassMember(CScopeParseResult *result, NameSpace *nspace, HashNameNode *name, ELookupType lookupType) { BClassList *bcl; BClassList *scan; @@ -907,11 +910,11 @@ static BClassList *CScope_GetAccessPathRec(TypeClass *src, TypeClass *dest, SInt if (src == dest) { if (cscope_foundclass && cscope_foundclassoffset != offset) - CError_Error(188); + CError_Error(CErrorStr188); list = lalloc(sizeof(BClassList)); list->next = NULL; - list->type = (Type *) src; + list->type = TYPE(src); cscope_foundclass = src; cscope_foundclassoffset = offset; return list; @@ -925,7 +928,7 @@ static BClassList *CScope_GetAccessPathRec(TypeClass *src, TypeClass *dest, SInt if (best) { list = lalloc(sizeof(BClassList)); list->next = best; - list->type = (Type *) src; + list->type = TYPE(src); return list; } @@ -946,7 +949,7 @@ static NameSpace *CScope_FindLookupNameSpace(CScopeNSIterator *iterator, NameSpa Boolean fail = 0; if (lookup->nspace->theclass) { - if (CScope_FindClassMember(iterator->result, lookup->nspace, name, 2)) { + if (CScope_FindClassMember(iterator->result, lookup->nspace, name, Lookup_2)) { retnspace = iterator->result->nspace_0; iterator->result->nspace_0 = NULL; return retnspace; @@ -1106,7 +1109,7 @@ static NameSpaceObjectList *CScope_NSIteratorFind(CScopeNSIterator *iterator, Ha if (iterator->lookup->namespaces) return CScope_FindLookupName(iterator->lookup, name, NULL); if (iterator->lookup->nspace->theclass) { - if (CScope_FindClassMember(iterator->result, iterator->lookup->nspace, name, 0)) { + if (CScope_FindClassMember(iterator->result, iterator->lookup->nspace, name, Lookup_0)) { list = iterator->result->nsol_14; iterator->result->nsol_14 = NULL; return list; @@ -1119,7 +1122,7 @@ static NameSpaceObjectList *CScope_NSIteratorFind(CScopeNSIterator *iterator, Ha return list; } else { if (iterator->nspace->theclass) { - if (CScope_FindClassMember(iterator->result, iterator->nspace, name, 0)) { + if (CScope_FindClassMember(iterator->result, iterator->nspace, name, Lookup_0)) { list = iterator->result->nsol_14; iterator->result->nsol_14 = NULL; return list; @@ -1163,7 +1166,7 @@ static NameSpace *CScope_NSIteratorFindNameSpace(CScopeNSIterator *iterator, Has if (iterator->lookup->namespaces) return CScope_FindLookupNameSpace(iterator, iterator->lookup, name); if (iterator->lookup->nspace->theclass) { - if (CScope_FindClassMember(iterator->result, iterator->lookup->nspace, name, 2)) { + if (CScope_FindClassMember(iterator->result, iterator->lookup->nspace, name, Lookup_2)) { nspace = iterator->result->nspace_0; iterator->result->nspace_0 = NULL; return nspace; @@ -1176,7 +1179,7 @@ static NameSpace *CScope_NSIteratorFindNameSpace(CScopeNSIterator *iterator, Has return CScope_ExtractNameSpace(list, NULL); } else { if (iterator->nspace->theclass) { - if (CScope_FindClassMember(iterator->result, iterator->nspace, name, 2)) { + if (CScope_FindClassMember(iterator->result, iterator->nspace, name, Lookup_2)) { nspace = iterator->result->nspace_0; iterator->result->nspace_0 = NULL; return nspace; @@ -1196,7 +1199,7 @@ static Boolean CScope_SetupParseNameResult(CScopeParseResult *result, NameSpaceO if (!list->next || list->next->object->otype == OT_TYPETAG) { switch (list->object->otype) { case OT_NAMESPACE: - CError_Error(321); + CError_Error(CErrorStr321); return 0; case OT_TYPE: result->x8 = OBJ_TYPE(list->object)->type; @@ -1207,7 +1210,7 @@ static Boolean CScope_SetupParseNameResult(CScopeParseResult *result, NameSpaceO break; case OT_TYPETAG: result->x8 = OBJ_TYPE_TAG(list->object)->type; - result->xC = NULL; + result->xC = 0; result->obj_10 = list->object; result->name_4 = name; result->x20 = 1; @@ -1226,18 +1229,17 @@ Boolean CScope_FindQualifiedClassMember(CScopeParseResult *result, TypeClass *tc NameSpaceObjectList *list; memclrw(result, sizeof(CScopeParseResult)); - CDecl_CompleteType((Type *) tclass); + CDecl_CompleteType(TYPE(tclass)); - if (CScope_FindClassMember(result, tclass->nspace, name, 0)) { + if (CScope_FindClassMember(result, tclass->nspace, name, Lookup_0)) { list = result->nsol_14; -#line 1780 - CError_ASSERT(list); + CError_ASSERT(1780, list); result->nsol_14 = NULL; if (CScope_SetupParseNameResult(result, list, name) && !result->x8) return 1; else - CError_Error(340, name->name); + CError_Error(CErrorStr340, name->name); } return 0; @@ -1252,7 +1254,7 @@ static NameSpace *CScope_FindQualifiedNameSpace(CScopeParseResult *result, NameS Boolean fail = 0; if (nspace->theclass) { - if (CScope_FindClassMember(result, nspace, name, 2)) { + if (CScope_FindClassMember(result, nspace, name, Lookup_2)) { nspace = result->nspace_0; result->nspace_0 = NULL; return nspace; @@ -1291,8 +1293,8 @@ static NameSpaceObjectList *CScope_FindQualifiedName(CScopeParseResult *result, NameSpaceLookupList *lookup; if (nspace->theclass) { - CDecl_CompleteType((Type *) nspace->theclass); - if (CScope_FindClassMember(result, nspace, name, 0)) { + CDecl_CompleteType(TYPE(nspace->theclass)); + if (CScope_FindClassMember(result, nspace, name, Lookup_0)) { list = result->nsol_14; result->nsol_14 = NULL; return list; @@ -1324,8 +1326,8 @@ static Boolean CScope_FindQualifiedTag(CScopeParseResult *result, NameSpace *nsp NameSpaceList *scan; if (nspace->theclass) { - CDecl_CompleteType((Type *) nspace->theclass); - return CScope_FindClassMember(result, nspace, name, 1) != 0; + CDecl_CompleteType(TYPE(nspace->theclass)); + return CScope_FindClassMember(result, nspace, name, Lookup_1) != 0; } if ((list = CScope_FindQualName(nspace, name))) { @@ -1439,46 +1441,46 @@ Type *CScope_GetTagType(NameSpace *nspace, HashNameNode *name) { } static Boolean CScope_DependentTemplateMember(CScopeParseResult *result, TypeTemplDep *ttempldep, Boolean flag1, Boolean flag2) { - // does not match, sign extension/caching mishap SInt32 streamstate; short token; - short token2; TypeTemplDep *newtype; TypeTemplDep *newtype2; CPrep_TokenStreamGetState(&streamstate); -#line 2026 - CError_ASSERT(lex() == TK_COLON_COLON); + token = lex(); + CError_ASSERT(2026, token == TK_COLON_COLON); - do { + while (1) { token = lex(); if (token == TK_OPERATOR && flag1) { if (!CParser_ParseOperatorName(NULL, 1, 1)) return 0; - newtype = CDecl_NewTemplDepType(TEMPLDEP_QUALNAME); + newtype = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALNAME)); newtype->u.qual.type = ttempldep; newtype->u.qual.name = tkidentifier; CPrep_TokenStreamSetState(&streamstate); lex(); tk = lex(); - result->x8 = (Type *) newtype; + result->x8 = TYPE(newtype); return 1; - } else if (token == TK_TEMPLATE) { + } + + if (token == TK_TEMPLATE) { if (lex() != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } CPrep_TokenStreamGetState(&streamstate); - newtype = CDecl_NewTemplDepType(TEMPLDEP_QUALNAME); + newtype = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALNAME)); newtype->u.qual.type = ttempldep; newtype->u.qual.name = tkidentifier; - if ((token2 = lex()) != '<') { - CError_Error(230); + if ((token = lex()) != '<') { + CError_Error(CErrorStr230); return 0; } - tk = token2; - newtype2 = CDecl_NewTemplDepType(TEMPLDEP_QUALTEMPL); + tk = token; + newtype2 = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALTEMPL)); newtype2->u.qualtempl.type = newtype; newtype2->u.qualtempl.args = CTempl_ParseUncheckTemplArgs(NULL, 1); CPrep_TokenStreamGetState(&streamstate); @@ -1487,27 +1489,29 @@ static Boolean CScope_DependentTemplateMember(CScopeParseResult *result, TypeTem continue; } else { CPrep_TokenStreamSetState(&streamstate); - result->x8 = (Type *) newtype2; + result->x8 = TYPE(newtype2); return 1; } - } else if (token == TK_IDENTIFIER) { - newtype = CDecl_NewTemplDepType(TEMPLDEP_QUALNAME); + } + + if (token == TK_IDENTIFIER) { + newtype = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALNAME)); newtype->u.qual.type = ttempldep; newtype->u.qual.name = tkidentifier; tk = token; CPrep_TokenStreamGetState(&streamstate); - token2 = lex(); + token = lex(); tkidentifier = newtype->u.qual.name; - if (token2 == TK_COLON_COLON) { + if (token == TK_COLON_COLON) { ttempldep = newtype; continue; } - if ((token2 == '<') && !flag2) { - tk = token2; + if ((token == '<') && !flag2) { + tk = token; newtype2 = newtype; - newtype = CDecl_NewTemplDepType(TEMPLDEP_QUALTEMPL); + newtype = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALTEMPL)); newtype->u.qualtempl.type = newtype2; newtype->u.qualtempl.args = CTempl_ParseUncheckTemplArgs(NULL, 1); @@ -1519,35 +1523,40 @@ static Boolean CScope_DependentTemplateMember(CScopeParseResult *result, TypeTem } CPrep_TokenStreamSetState(&streamstate); - result->x8 = (Type *) newtype; - return 1; - } else { - CPrep_TokenStreamSetState(&streamstate); - result->x8 = (Type *) ttempldep; + result->x8 = TYPE(newtype); return 1; } - } while (1); + + CPrep_TokenStreamSetState(&streamstate); + result->x8 = TYPE(ttempldep); + return 1; + } } static Boolean CScope_CheckDtorName(TypeClass *tclass, Boolean *flag) { if ((tk = lex()) != TK_IDENTIFIER) - CError_Error(107); + CError_Error(CErrorStr107); if (tclass) { *flag = 0; - if ((tclass->classname == tkidentifier) || (CScope_GetType(tclass->nspace, tkidentifier, NULL) == (Type *) tclass) || (CScope_GetType(cscope_current, tkidentifier, NULL) == (Type *) tclass)) { + if ( + (tclass->classname == tkidentifier) || + (CScope_GetType(tclass->nspace, tkidentifier, NULL) == TYPE(tclass)) || + (CScope_GetType(cscope_current, tkidentifier, NULL) == TYPE(tclass)) + ) + { if (!CClass_Destructor(tclass)) *flag = 1; if ((tclass->flags & CLASS_FLAGS_800) && (lookahead() == '<')) { tk = lex(); if (!CTemplTool_EqualArgs(TEMPL_CLASS_INST(tclass)->inst_args, CTempl_ParseUncheckTemplArgs(NULL, 0))) - CError_Error(374); + CError_Error(CErrorStr374); } return 1; } } - CError_Error(141); + CError_Error(CErrorStr141); return 0; } @@ -1561,7 +1570,7 @@ static Boolean CScope_ParseQualifiedName(CScopeParseResult *result, NameSpace *n switch (tk) { case TK_TEMPLATE: if ((tk = lex()) != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } case TK_IDENTIFIER: @@ -1589,7 +1598,7 @@ static Boolean CScope_ParseQualifiedName(CScopeParseResult *result, NameSpace *n flag = 1; break; default: - CError_Error(107); + CError_Error(CErrorStr107); return 0; } @@ -1599,13 +1608,13 @@ static Boolean CScope_ParseQualifiedName(CScopeParseResult *result, NameSpace *n return 1; } if (nspace->theclass && !(nspace->theclass->flags & CLASS_FLAGS_2)) - CError_Error(136, nspace->theclass, 0); + CError_Error(CErrorStr136, nspace->theclass, 0); else - CError_Error(140, saveidentifier->name); + CError_Error(CErrorStr140, saveidentifier->name); return 0; } - if (result->x8 && (result->x8->type == TYPECLASS) && (lookahead() == '<')) { + if (result->x8 && IS_TYPE_CLASS(result->x8) && (lookahead() == '<')) { tclass = TYPE_CLASS(result->x8); if (tclass->flags & CLASS_FLAGS_800) tclass = TYPE_CLASS(TEMPL_CLASS_INST(tclass)->templ); @@ -1613,8 +1622,8 @@ static Boolean CScope_ParseQualifiedName(CScopeParseResult *result, NameSpace *n return 1; tk = lex(); - result->x8 = CTempl_ClassGetType(tclass); - if ((result->x8->type == TYPECLASS) && (lookahead() == TK_COLON_COLON)) { + result->x8 = CTempl_ClassGetType(TEMPL_CLASS(tclass)); + if (IS_TYPE_CLASS(result->x8) && (lookahead() == TK_COLON_COLON)) { lex(); tk = lex(); result->x1D = 1; @@ -1638,7 +1647,7 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) { if (!copts.cplusplus) { memclrw(result, sizeof(CScopeParseResult)); if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } @@ -1658,8 +1667,7 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) { if ((tk == TK_COLON_COLON || tk == TK_IDENTIFIER) && CScope_ParseQualifiedNameSpace(result, 1, 1)) { if (result->x8) return 1; -#line 2313 - CError_ASSERT(result->nspace_0); + CError_ASSERT(2313, result->nspace_0); } else { memclrw(result, sizeof(CScopeParseResult)); result->nspace_0 = cscope_current; @@ -1668,10 +1676,10 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) { switch (tk) { case TK_TEMPLATE: if (!result->x1D) - CError_Error(373); + CError_Error(CErrorStr373); if ((tk = lex()) != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } case TK_IDENTIFIER: @@ -1693,13 +1701,13 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) { name = destructor_name_node; break; default: - CError_Error(107); + CError_Error(CErrorStr107); return 0; } if (result->x1D) { if (!(list = CScope_FindQualifiedName(result, result->nspace_0, name, &result->nspace_0))) { - CError_Error(140, CError_GetNameString(result->nspace_0, name)); + CError_Error(CErrorStr140, CError_GetNameString(result->nspace_0, name)); return 0; } else { return CScope_SetupParseNameResult(result, list, name); @@ -1715,7 +1723,7 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) { } while (CScope_NSIteratorNext(&iterator)); if (result->x1D) { - CError_Error(140, name->name); + CError_Error(CErrorStr140, name->name); return 0; } else { result->nspace_0 = cscope_current; @@ -1737,7 +1745,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) { if (!copts.cplusplus) { non_cpp_mode: if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } memclrw(result, sizeof(CScopeParseResult)); @@ -1756,7 +1764,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) { return 0; } else { if ((tk != TK_COLON_COLON) && (tk != TK_IDENTIFIER)) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } @@ -1767,8 +1775,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) { return 1; nspace = result->nspace_0; -#line 2435 - CError_ASSERT(nspace); + CError_ASSERT(2435, nspace); switch (tk) { case TK_OPERATOR: @@ -1779,7 +1786,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) { } CScope_RestoreScope(&save); if (op) - CError_Error(121); + CError_Error(CErrorStr121); result->x21 = 1; return 1; case TK_IDENTIFIER: @@ -1789,26 +1796,26 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) { break; case '~': if (!nspace->theclass) { - CError_Error(121); + CError_Error(CErrorStr121); return 0; } tk = lex(); if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } if (nspace->theclass->classname != tkidentifier) - CError_Error(121); + CError_Error(CErrorStr121); name = destructor_name_node; break; default: - CError_Error(107); + CError_Error(CErrorStr107); return 0; } if (result->x1D) { if (!(list = CScope_FindQualifiedName(result, result->nspace_0, name, &result->nspace_0))) { - CError_Error(140, name->name); + CError_Error(CErrorStr140, name->name); return 0; } else { return CScope_SetupParseNameResult(result, list, name); @@ -1823,7 +1830,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) { } } while (CScope_NSIteratorNext(&iterator)); - CError_Error(140, name->name); + CError_Error(CErrorStr140, name->name); return 0; } } @@ -1851,9 +1858,9 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, if (tk != TK_TEMPLATE) return nspace != NULL; if (!result->x1D) - CError_Error(373); + CError_Error(CErrorStr373); if ((tk = lex()) != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } } @@ -1871,12 +1878,11 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, // list = r21 for (list = CScope_NSIteratorFind(&iterator, name); list; list = list->next) { if (list->object->otype == OT_NAMESPACE) { -#line 2565 - CError_ASSERT(!nspace || !nspace->theclass); + CError_ASSERT(2565, !nspace || !nspace->theclass); result->nspace_0 = nspace = OBJ_NAMESPACE(list->object)->nspace; if ((tk = lex()) != TK_COLON_COLON) { - CError_Error(321); + CError_Error(CErrorStr321); return 0; } @@ -1891,24 +1897,23 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, result->x8 = type; return 1; } else { - CError_Error(121); + CError_Error(CErrorStr121); return 0; } } parse_thing: if (t == '<') { if (TYPE_CLASS(type)->flags & CLASS_FLAGS_800) { - type = (Type *) TEMPL_CLASS_INST(type)->templ; + type = TYPE(TEMPL_CLASS_INST(type)->templ); } else if (!(TYPE_CLASS(type)->flags & CLASS_FLAGS_100)) { result->x8 = type; return 1; } } if ((tk = lex()) == '<') { -#line 2609 - CError_ASSERT(TYPE_CLASS(type)->flags & CLASS_FLAGS_100); - type2 = CTempl_ClassGetType(TYPE_CLASS(type)); - if (type2->type == TYPETEMPLATE) { + CError_ASSERT(2609, TYPE_CLASS(type)->flags & CLASS_FLAGS_100); + type2 = CTempl_ClassGetType(TEMPL_CLASS(type)); + if (IS_TYPE_TEMPLATE(type2)) { if (lookahead() != TK_COLON_COLON) { result->x8 = type2; return 1; @@ -1926,8 +1931,7 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, tk = lex(); CDecl_CompleteType(type2); } else { -#line 2632 - CError_ASSERT(tk == TK_COLON_COLON); + CError_ASSERT(2632, tk == TK_COLON_COLON); if (!(TYPE_CLASS(type)->flags & CLASS_FLAGS_100) || CParser_CheckTemplateClassUsage(TEMPL_CLASS(type), 1)) result->nspace_0 = nspace = TYPE_CLASS(type)->nspace; CDecl_CompleteType(type); @@ -1939,10 +1943,10 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, } if (list->object->otype == OT_TYPE) { type2 = OBJ_TYPE(list->object)->type; - if (type2->type != TYPECLASS) { - if (type2->type == TYPETEMPLATE) { + if (!IS_TYPE_CLASS(type2)) { + if (IS_TYPE_TEMPLATE(type2)) { if (TYPE_TEMPLATE(type2)->dtype == TEMPLDEP_ARGUMENT && TYPE_TEMPLATE(type2)->u.pid.type == TPT_TEMPLATE) { - type2 = CTempl_ParseTemplTemplParam(type2); + type2 = CTempl_ParseTemplTemplParam(TYPE_TEMPLATE(type2)); if ((type2->type != TYPETEMPLATE) || ((t = lookahead()) != TK_COLON_COLON)) { result->x8 = type2; return 1; @@ -1955,7 +1959,7 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, result->x8 = type2; return 1; } else { - CError_Error(121); + CError_Error(CErrorStr121); return 0; } } else { @@ -1967,8 +1971,7 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, result->x8 = type2; return 1; } -#line 2686 - CError_ASSERT(tk == TK_COLON_COLON); + CError_ASSERT(2686, tk == TK_COLON_COLON); if (!type2->size) CDecl_CompleteType(type2); result->nspace_0 = nspace = TYPE_CLASS(type2)->nspace; @@ -1982,7 +1985,7 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, } } while (CScope_NSIteratorNext(&iterator)); - CError_Error(140, name->name); + CError_Error(CErrorStr140, name->name); return 0; } @@ -1995,7 +1998,7 @@ Boolean CScope_ParseElaborateName(CScopeParseResult *result) { if (!copts.cplusplus) { memclrw(result, sizeof(CScopeParseResult)); if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } @@ -2014,32 +2017,31 @@ Boolean CScope_ParseElaborateName(CScopeParseResult *result) { return 1; } else { if ((tk != TK_COLON_COLON) && (tk != TK_IDENTIFIER)) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } if (!CScope_ParseQualifiedNameSpace(result, 0, 0)) { result->nspace_0 = cscope_current; if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } name = tkidentifier; } else { if (result->x8) return 1; -#line 2760 - CError_ASSERT(result->nspace_0); + CError_ASSERT(2760, result->nspace_0); if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } name = tkidentifier; if (result->x1D) { if (result->nspace_0->theclass) - return CScope_FindClassMember(result, result->nspace_0, name, 1) != 0; + return CScope_FindClassMember(result, result->nspace_0, name, Lookup_1) != 0; else return CScope_FindQualifiedTag(result, result->nspace_0, name); } @@ -2145,7 +2147,7 @@ Boolean CScope_FindClassMemberObject(TypeClass *tclass, CScopeParseResult *resul memclrw(result, sizeof(CScopeParseResult)); - if (CScope_FindClassMember(result, tclass->nspace, name, 0)) { + if (CScope_FindClassMember(result, tclass->nspace, name, Lookup_0)) { list = result->nsol_14; result->nsol_14 = NULL; if (list && list->object->otype == OT_OBJECT) @@ -2285,7 +2287,7 @@ NameSpaceObjectList *CScope_GetLocalObject(NameSpace *nspace, HashNameNode *name case OT_OBJECT: return CScope_GetLocalObjects(list); default: - CError_Error(122, name->name); + CError_Error(CErrorStr122, name->name); return NULL; case OT_TYPETAG: break; @@ -2323,7 +2325,7 @@ BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass) { list = CScope_GetBaseAccessPathEnd(list); for (scan = list; scan; scan = scan->next) { - if (scan->type == (Type *) tclass) + if (scan->type == TYPE(tclass)) return scan; } @@ -2334,8 +2336,7 @@ BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass) { return list2; } } -#line 3217 - CError_FATAL(); + CError_FATAL(3217); } return NULL; @@ -2344,9 +2345,9 @@ BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass) { static Boolean CScope_FixMemberResult(TypeClass *tclass, CScopeParseResult *result) { if (!(result->bcl_18 = CScope_GetClassAccessPath(result->bcl_18, tclass))) { if (result->name_4) - CError_Error(150, result->name_4->name); + CError_Error(CErrorStr150, result->name_4->name); else - CError_Error(328); + CError_Error(CErrorStr328); return 0; } else { return 1; @@ -2364,10 +2365,10 @@ Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boo if (!CScope_ParseExprName(result)) return 0; - if (result->x8 && result->x8->type == TYPETEMPLATE && TYPE_TEMPLATE(result->x8)->dtype == TEMPLDEP_QUALNAME) { + if (result->x8 && IS_TYPE_TEMPLATE(result->x8) && TYPE_TEMPLATE(result->x8)->dtype == TEMPLDEP_QUALNAME) { if (flag) return 1; - CError_Error(340, TYPE_TEMPLATE(result->x8)->u.qual.name->name); + CError_Error(CErrorStr340, TYPE_TEMPLATE(result->x8)->u.qual.name->name); result->x8 = NULL; return 0; } @@ -2385,7 +2386,7 @@ Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boo switch (t) { case TK_COLON_COLON: memclrw(result, sizeof(CScopeParseResult)); - if (!CScope_FindClassMember(result, tclass->nspace, name, 2)) + if (!CScope_FindClassMember(result, tclass->nspace, name, Lookup_2)) goto restart; break; case '<': @@ -2402,7 +2403,7 @@ Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boo } if (!(list = CScope_FindQualifiedName(result, tclass->nspace, destructor_name_node, &result->nspace_0))) { - CError_Error(140, CError_GetNameString(result->nspace_0, destructor_name_node)); + CError_Error(CErrorStr140, CError_GetNameString(result->nspace_0, destructor_name_node)); return 0; } else { return CScope_SetupParseNameResult(result, list, destructor_name_node); @@ -2424,7 +2425,7 @@ static void CScope_AddUsingObject(BClassList *bcl, NameSpace *nspace, ObjBase *o if (bcl) { if (!nspace->theclass) - CError_Error(200); + CError_Error(CErrorStr200); else CClass_CheckPathAccess(bcl, NULL, obj->access); } @@ -2461,15 +2462,15 @@ static void CScope_AddUsingObject(BClassList *bcl, NameSpace *nspace, ObjBase *o *OBJ_MEMBER_VAR(copy) = *OBJ_MEMBER_VAR(obj); copy->access = access; pathcopy = CScope_GetClassAccessPath(CClass_GetPathCopy(bcl, 1), nspace->theclass); - if (pathcopy && pathcopy->type == (Type *) nspace->theclass) { + if (pathcopy && pathcopy->type == TYPE(nspace->theclass)) { OBJ_MEMBER_VAR_PATH(copy)->has_path = 1; OBJ_MEMBER_VAR_PATH(copy)->path = pathcopy; } else { - CError_Error(221); + CError_Error(CErrorStr221); } CScope_AddObject(nspace, OBJ_MEMBER_VAR(copy)->name, copy); } else { - CError_Error(221); + CError_Error(CErrorStr221); } } else if (obj->otype == OT_OBJECT) { if (!nspace->theclass) { @@ -2492,17 +2493,17 @@ static void CScope_AddUsingObject(BClassList *bcl, NameSpace *nspace, ObjBase *o OBJECT(copy)->u.alias.member = NULL; OBJECT(copy)->u.alias.offset = 0; - if (OBJECT(copy)->type->type == TYPEFUNC && (TYPE_FUNC(OBJECT(copy)->type)->flags & FUNC_FLAGS_METHOD) && !TYPE_METHOD(OBJECT(copy)->type)->x26) { + if (IS_TYPE_NONSTATIC_METHOD(OBJECT(copy)->type)) { if (!(tclass = nspace->theclass) || !(OBJECT(copy)->u.alias.member = CScope_GetClassAccessPath( - CClass_GetPathCopy(bcl, 1), tclass)) || (OBJECT(copy)->u.alias.member->type != (Type *) nspace->theclass)) { - CError_Error(221); + CClass_GetPathCopy(bcl, 1), tclass)) || (OBJECT(copy)->u.alias.member->type != TYPE(nspace->theclass))) { + CError_Error(CErrorStr221); OBJECT(copy)->u.alias.member = NULL; } } CScope_AddObject(nspace, OBJECT(copy)->name, copy); } else { - CError_Error(200); + CError_Error(CErrorStr200); } } @@ -2511,8 +2512,8 @@ void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, Hash NameSpaceObjectList *scan; memclrw(&result, sizeof(CScopeParseResult)); - if (!CScope_FindClassMember(&result, tclass2->nspace, name, 0) || !CScope_FixMemberResult(tclass, &result)) { - CError_Error(340, name->name); + if (!CScope_FindClassMember(&result, tclass2->nspace, name, Lookup_0) || !CScope_FixMemberResult(tclass, &result)) { + CError_Error(CErrorStr340, name->name); return; } @@ -2530,32 +2531,34 @@ void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, Hash if (result.obj_10) CScope_AddUsingObject(result.bcl_18, tclass->nspace, result.obj_10, result.name_4, access); else - CError_Error(340, name->name); + CError_Error(CErrorStr340, name->name); } } -void CScope_ParseUsingDeclaration(NameSpace *nspace, short access, Boolean flag) { - // almost matches, slight bit of register weirdness +void CScope_ParseUsingDeclaration(NameSpace *nspace, AccessType access, Boolean flag) { + NameSpace *saveNSpace; + Boolean flag_r27; + Boolean flag_r26; + NameSpaceObjectList *scan; CScopeParseResult result; if (nspace->theclass) { - Boolean flag_r27 = (TYPE_CLASS(nspace->theclass)->flags & CLASS_FLAGS_100) ? 1 : 0; - Boolean flag_r26 = 0; + flag_r27 = (TYPE_CLASS(nspace->theclass)->flags & CLASS_FLAGS_100) ? 1 : 0; + flag_r26 = 0; if (tk == TK_TYPENAME) { if (!flag_r27) - CError_Error(200); + CError_Error(CErrorStr200); flag_r26 = 1; tk = lex(); } if (!CScope_ParseMemberName(nspace->theclass, &result, flag_r27)) { - CError_Error(200); + CError_Error(CErrorStr200); return; } - if (result.x8 && result.x8->type == TYPETEMPLATE && TYPE_TEMPLATE(result.x8)->dtype == TEMPLDEP_QUALNAME) { -#line 3578 - CError_ASSERT(flag_r27); + if (result.x8 && IS_TYPE_TEMPLATE(result.x8) && TYPE_TEMPLATE(result.x8)->dtype == TEMPLDEP_QUALNAME) { + CError_ASSERT(3578, flag_r27); if (flag_r26) { ObjType *objtype = galloc(sizeof(ObjType)); @@ -2565,32 +2568,34 @@ void CScope_ParseUsingDeclaration(NameSpace *nspace, short access, Boolean flag) objtype->type = result.x8; CScope_AddObject(nspace, TYPE_TEMPLATE(result.x8)->u.qual.name, OBJ_BASE(objtype)); } else { - CTemplClass_RegisterUsingDecl(TEMPL_CLASS(nspace->theclass), result.x8, access); + CTemplClass_RegisterUsingDecl( + TEMPL_CLASS(nspace->theclass), + TYPE_TEMPLATE(result.x8), + access); } if ((tk = lex()) != ';') - CError_Error(123); + CError_Error(CErrorStr123); return; } if (!result.x1D) { - CError_Error(200); + CError_Error(CErrorStr200); return; } } else { - NameSpace *savenspace = cscope_current; + saveNSpace = cscope_current; cscope_current = nspace; if (!CScope_ParseExprName(&result) || !result.x1D) { - cscope_current = savenspace; - CError_Error(200); + cscope_current = saveNSpace; + CError_Error(CErrorStr200); return; } else { - cscope_current = savenspace; + cscope_current = saveNSpace; } } if (result.nsol_14) { - NameSpaceObjectList *scan; for (scan = result.nsol_14; scan; scan = scan->next) { if (scan->object->otype == OT_OBJECT) CScope_AddUsingObject(result.bcl_18, nspace, scan->object, result.name_4, access); @@ -2599,11 +2604,11 @@ void CScope_ParseUsingDeclaration(NameSpace *nspace, short access, Boolean flag) if (result.obj_10) CScope_AddUsingObject(result.bcl_18, nspace, result.obj_10, result.name_4, access); else - CError_Error(200); + CError_Error(CErrorStr200); } if ((tk = lex()) != ';') - CError_Error(123); + CError_Error(CErrorStr123); } static NameSpace *CScope_ParseQualifiedNamespaceSpecifier(NameSpace *nspace) { @@ -2620,7 +2625,7 @@ static NameSpace *CScope_ParseQualifiedNamespaceSpecifier(NameSpace *nspace) { do { if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); break; } @@ -2631,7 +2636,7 @@ static NameSpace *CScope_ParseQualifiedNamespaceSpecifier(NameSpace *nspace) { goto some_goto; } } while (CScope_NSIteratorNext(&iterator)); - CError_Error(140, tkidentifier->name); + CError_Error(CErrorStr140, tkidentifier->name); some_goto: if ((tk = lex()) != TK_COLON_COLON) break; @@ -2656,17 +2661,17 @@ void CScope_ParseNameSpaceAlias(HashNameNode *name) { objns->nspace = CScope_ParseQualifiedNamespaceSpecifier(cscope_current); CScope_AddObject(cscope_current, name, OBJ_BASE(objns)); } else if (list->object->otype != OT_NAMESPACE) { - CError_Error(320); + CError_Error(CErrorStr320); tk = lex(); CScope_ParseQualifiedNamespaceSpecifier(cscope_current); } else { tk = lex(); if (CScope_ParseQualifiedNamespaceSpecifier(cscope_current) != OBJ_NAMESPACE(list->object)->nspace) - CError_Error(122, name->name); + CError_Error(CErrorStr122, name->name); } if (tk != ';') - CError_Error(123); + CError_Error(CErrorStr123); } void CScope_ParseUsingDirective(NameSpace *nspace) { @@ -2686,9 +2691,9 @@ void CScope_ParseUsingDirective(NameSpace *nspace) { nspace->usings = list; } } else { - CError_Error(321); + CError_Error(CErrorStr321); } if (tk != ';') - CError_Error(123); + CError_Error(CErrorStr123); } |