struct Specifier * CopySpecifier(struct Specifier * spec) { if(spec) switch(spec->type) { case 0: return MkSpecifier(spec->specifier); case 2: { struct Identifier * id = CopyIdentifier(spec->id); struct __ecereNameSpace__ecere__sys__OldList * list = MkList(); struct Enumerator * enumerator; if(spec->list) { for(enumerator = (*spec->list).first; enumerator; enumerator = enumerator->next) ListAdd(list, CopyEnumerator(enumerator)); } return MkEnum(id, list); } case 3: case 4: { struct Identifier * id = CopyIdentifier(spec->id); struct __ecereNameSpace__ecere__sys__OldList * list = (((void *)0)); struct ClassDef * def; struct Specifier * s; if(spec->definitions) { list = MkList(); if(spec->list) { for(def = (*spec->list).first; def; def = def->next) ListAdd(list, CopyClassDef(def)); } } s = MkStructOrUnion(spec->type, id, list); s->extDeclStruct = CopyExtDecl(spec->extDeclStruct); return s; } case 1: { struct Specifier * copy = (copy = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Specifier), copy->type = 1, copy->name = __ecereNameSpace__ecere__sys__CopyString(spec->name), copy->symbol = spec->symbol, copy->templateArgs = (((void *)0)), copy); return copy; } case 7: return MkSpecifierSubClass(CopySpecifier(spec->_class)); case 8: return __extension__ ({ struct Specifier * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Specifier); __ecereInstance1->loc = spec->loc, __ecereInstance1->type = 8, __ecereInstance1->templateParameter = spec->templateParameter, __ecereInstance1; }); case 5: return MkSpecifierExtended(CopyExtDecl(spec->extDecl)); }
struct Declaration * QMkDeclarationBase(int base, struct InitDeclarator * initDecl) { struct __ecereNameSpace__ecere__sys__OldList * specs = MkList(), * initDecls = (((void *)0)); ListAdd(specs, MkSpecifier(base)); if(initDecl) { initDecls = MkList(); ListAdd(initDecls, initDecl); } return MkDeclaration(specs, initDecls); }
struct Expression * QMkExpCond(struct Expression * cond, struct Expression * exp, struct Expression * elseExp) { struct __ecereNameSpace__ecere__sys__OldList * expList = MkList(); ListAdd(expList, exp); return MkExpCondition(cond, expList, elseExp); }
struct Expression * QBrackets(struct Expression * exp) { struct __ecereNameSpace__ecere__sys__OldList * expList = MkList(); ListAdd(expList, exp); return MkExpBrackets(expList); }
struct TypeName * QMkClass(char * spec, struct Declarator * decl) { struct __ecereNameSpace__ecere__sys__OldList * specs = MkList(); ListAdd(specs, MkSpecifierName(spec)); return MkTypeName(specs, decl); }
static struct Instantiation * CopyInstantiation(struct Instantiation * inst) { struct Instantiation * copy; struct __ecereNameSpace__ecere__sys__OldList * list = MkList(); struct MembersInit * member; if(inst->members) { for(member = (*inst->members).first; member; member = member->next) ListAdd(list, CopyMembersInit(member)); } copy = MkInstantiation(CopySpecifier(inst->_class), CopyExpression(inst->exp), list); copy->data = inst->data; if(inst->data) { struct Symbol * classSym = FindClass(inst->_class->name); struct __ecereNameSpace__ecere__com__Class * _class = classSym ? classSym->registered : (((void *)0)); if(_class) { if(_class->type == 0) ((struct __ecereNameSpace__ecere__com__Instance *)(char *)((struct __ecereNameSpace__ecere__com__Instance *)copy->data))->_refCount++; } } copy->loc = inst->loc; copy->isConstant = inst->isConstant; return copy; }
static struct Pointer * CopyPointer(struct Pointer * ptr) { if(ptr) { struct __ecereNameSpace__ecere__sys__OldList * list = MkList(); struct Specifier * spec; if(ptr->qualifiers) { for(spec = (*ptr->qualifiers).first; spec; spec = spec->next) ListAdd(list, CopySpecifier(spec)); } return MkPointer(list, CopyPointer(ptr->pointer)); } return (((void *)0)); }
static struct MembersInit * CopyMembersInit(struct MembersInit * members) { struct __ecereNameSpace__ecere__sys__OldList * list = (((void *)0)); switch(members->type) { case 0: { if(members) { struct MemberInit * member; list = MkList(); for(member = (*members->dataMembers).first; member; member = member->next) ListAdd(list, CopyMemberInit(member)); } } } return MkMembersInitList(list); }
struct Expression * CopyExpression(struct Expression * exp) { struct Expression * result = (((void *)0)); if(exp) switch(exp->type) { case 16: result = MkExpDummy(); break; case 0: result = MkExpIdentifier(CopyIdentifier(exp->identifier)); break; case 1: result = MkExpInstance(CopyInstantiation(exp->instance)); break; case 2: result = MkExpConstant(exp->string); break; case 3: result = MkExpString(exp->string); break; case 4: result = MkExpOp(CopyExpression(exp->op.exp1), exp->op.op, CopyExpression(exp->op.exp2)); break; case 5: { struct __ecereNameSpace__ecere__sys__OldList * list = MkList(); struct Expression * e; for(e = (*exp->list).first; e; e = e->next) ListAdd(list, CopyExpression(e)); result = MkExpBrackets(list); break; } case 6: { struct __ecereNameSpace__ecere__sys__OldList * list = MkList(); struct Expression * e; for(e = (*exp->index.index).first; e; e = e->next) ListAdd(list, CopyExpression(e)); result = MkExpIndex(CopyExpression(exp->index.exp), list); break; } case 7: { struct __ecereNameSpace__ecere__sys__OldList * list = MkList(); struct Expression * arg; if(exp->call.arguments) { for(arg = (*exp->call.arguments).first; arg; arg = arg->next) ListAdd(list, CopyExpression(arg)); } result = MkExpCall(CopyExpression(exp->call.exp), list); break; } case 8: result = MkExpMember(CopyExpression(exp->member.exp), CopyIdentifier(exp->member.member)); result->member.memberType = exp->member.memberType; result->member.thisPtr = exp->member.thisPtr; break; case 9: result = MkExpPointer(CopyExpression(exp->member.exp), CopyIdentifier(exp->member.member)); break; case 10: result = MkExpTypeSize(CopyTypeName(exp->typeName)); break; case 38: result = MkExpTypeAlign(CopyTypeName(exp->typeName)); break; case 11: result = MkExpCast(CopyTypeName(exp->cast.typeName), CopyExpression(exp->cast.exp)); break; case 12: { struct __ecereNameSpace__ecere__sys__OldList * list = MkList(); struct Expression * e; for(e = (*exp->cond.exp).first; e; e = e->next) ListAdd(list, CopyExpression(e)); result = MkExpCondition(CopyExpression(exp->cond.cond), list, CopyExpression(exp->cond.elseExp)); break; } case 36: result = MkExpVaArg(CopyExpression(exp->vaArg.exp), CopyTypeName(exp->vaArg.typeName)); break; case 25: result = MkExpExtensionCompound(CopyStatement(exp->compound)); break; } if(result) { result->expType = exp->expType; if(exp->expType) exp->expType->refCount++; result->destType = exp->destType; if(exp->destType) exp->destType->refCount++; result->loc = exp->loc; result->isConstant = exp->isConstant; result->byReference = exp->byReference; } return result; }