if(list != null)
{
Item item;
- while(item = list.first)
+ while((item = list.first))
{
list.Remove(item);
FreeFunction(item);
{
case enumType:
{
- NamedLink member, next;
- if(type.enumName)
- delete type.enumName;
+ NamedLink64 member, next;
+ delete type.enumName;
for(member = type.members.first; member; member = next)
{
next = member.next;
FreeType(symbol.type);
- while(link = symbol.templatedClasses.first)
+ while((link = symbol.templatedClasses.first))
symbol.templatedClasses.Delete(link);
delete symbol.string;
{
Symbol symbol;
- while(symbol = excludedSymbols.first)
+ while((symbol = excludedSymbols.first))
{
excludedSymbols.Remove(symbol);
FreeSymbol(symbol);
if(context == curContext)
curContext = globalContext;
- while(symbol = (Symbol)context.types.root)
+ while((symbol = (Symbol)context.types.root))
{
context.types.Remove((BTNode)symbol);
FreeSymbol(symbol);
}
- while(symbol = (Symbol)context.classes.root)
+ while((symbol = (Symbol)context.classes.root))
{
context.classes.Remove((BTNode)symbol);
FreeSymbol(symbol);
}
- while(symbol = (Symbol)context.symbols.root)
+ while((symbol = (Symbol)context.symbols.root))
{
context.symbols.Remove((BTNode)symbol);
FreeSymbol(symbol);
}
- while(symbol = (Symbol)context.structSymbols.root)
+ while((symbol = (Symbol)context.structSymbols.root))
{
context.structSymbols.Remove((BTNode)symbol);
FreeSymbol(symbol);
}
- while(symbol = (Symbol)context.templateTypes.root)
+ while((symbol = (Symbol)context.templateTypes.root))
{
context.templateTypes.Remove((BTNode)symbol);
FreeTemplateType((TemplatedType)symbol);
{
if(spec)
{
- switch(spec.type)
- {
- case nameSpecifier:
- //case classSpecifier:
- delete spec.name;
- if(spec.templateArgs)
- FreeList(spec.templateArgs, FreeTemplateArgument);
- break;
- case extendedSpecifier:
- if(spec.extDecl)
- FreeExtDecl(spec.extDecl);
- break;
- case enumSpecifier:
- if(spec.id)
- FreeIdentifier(spec.id);
- if(spec.list)
- FreeList(spec.list, FreeEnumerator);
- if(spec.definitions)
- FreeList(spec.definitions, FreeClassDef);
- break;
- case structSpecifier:
- case unionSpecifier:
- if(spec.id)
- FreeIdentifier(spec.id);
- if(spec.definitions)
- FreeList(spec.definitions, FreeClassDef);
- if(spec.baseSpecs)
- FreeList(spec.baseSpecs, FreeSpecifier);
- if(spec.ctx)
- {
- FreeContext(spec.ctx);
- delete spec.ctx;
- }
- break;
- case subClassSpecifier:
- if(spec._class)
- FreeSpecifier(spec._class);
- break;
- }
+ FreeSpecifierContents(spec);
delete spec;
}
}
+void FreeSpecifierContents(Specifier spec)
+{
+ switch(spec.type)
+ {
+ case nameSpecifier:
+ //case classSpecifier:
+ delete spec.name;
+ if(spec.templateArgs)
+ {
+ FreeList(spec.templateArgs, FreeTemplateArgument);
+ spec.templateArgs = null;
+ }
+ if(spec.nsSpec)
+ {
+ FreeSpecifier(spec.nsSpec);
+ spec.nsSpec = null;
+ }
+ break;
+ case extendedSpecifier:
+ if(spec.extDecl)
+ {
+ FreeExtDecl(spec.extDecl);
+ spec.extDecl = null;
+ }
+ break;
+ case enumSpecifier:
+ if(spec.baseSpecs)
+ {
+ FreeList(spec.baseSpecs, FreeSpecifier);
+ spec.baseSpecs = null;
+ }
+ if(spec.id)
+ {
+ FreeIdentifier(spec.id);
+ spec.id = null;
+ }
+ if(spec.list)
+ {
+ FreeList(spec.list, FreeEnumerator);
+ spec.list = null;
+ }
+ if(spec.definitions)
+ {
+ FreeList(spec.definitions, FreeClassDef);
+ spec.definitions = null;
+ }
+ break;
+ case structSpecifier:
+ case unionSpecifier:
+ if(spec.id)
+ {
+ FreeIdentifier(spec.id);
+ spec.id = null;
+ }
+ if(spec.definitions)
+ {
+ FreeList(spec.definitions, FreeClassDef);
+ spec.definitions = null;
+ }
+ if(spec.baseSpecs)
+ {
+ FreeList(spec.baseSpecs, FreeSpecifier);
+ spec.baseSpecs = null;
+ }
+ if(spec.extDeclStruct)
+ {
+ FreeExtDecl(spec.extDeclStruct);
+ spec.extDeclStruct = null;
+ }
+ if(spec.ctx)
+ {
+ FreeContext(spec.ctx);
+ delete spec.ctx;
+ }
+ break;
+ case subClassSpecifier:
+ if(spec._class)
+ {
+ FreeSpecifier(spec._class);
+ spec._class = null;
+ }
+ break;
+ }
+}
+
public void FreeIdentifier(Identifier id)
{
if(id.badID)
break;
case instanceExp:
if(exp.instance)
+ {
FreeInstance(exp.instance);
+ exp.instance = null;
+ }
break;
case stringExp:
delete exp.string;
{
if(exp.index.exp)
FreeExpression(exp.index.exp);
- if(exp.index.index)
+ if(exp.index.index)
FreeList(exp.index.index, FreeExpression);
break;
}
case callExp:
{
- FreeExpression(exp.call.exp);
+ if(exp.call.exp)
+ FreeExpression(exp.call.exp);
if(exp.call.arguments)
FreeList(exp.call.arguments, FreeExpression);
break;
if(exp.classData.id)
FreeIdentifier(exp.classData.id);
break;
+ case symbolErrorExp:
+ if(exp.identifier)
+ FreeIdentifier(exp.identifier);
+ break;
+ case memoryErrorExp:
+ delete exp.constant;
+ break;
+ case memberPropertyErrorExp:
+ case memberSymbolErrorExp:
+ if(exp.member.exp)
+ FreeExpression(exp.member.exp);
+ if(exp.member.member)
+ FreeIdentifier(exp.member.member);
+ break;
+ case functionCallErrorExp:
+ if(exp.call.exp)
+ FreeExpression(exp.call.exp);
+ if(exp.call.arguments)
+ FreeList(exp.call.arguments, FreeExpression);
+ break;
+ case dereferenceErrorExp:
+ case unknownErrorExp:
+ case noDebuggerErrorExp:
+ break;
}
if(freePointer)
{
delete watcher;
}
+void FreeAsmField(AsmField field)
+{
+ if(field.expression)
+ FreeExpression(field.expression);
+ if(field.symbolic)
+ FreeIdentifier(field.symbolic);
+ delete field.command;
+ delete field;
+}
+
void FreeStatement(Statement stmt)
{
switch(stmt.type)
{
+ case asmStmt:
+ {
+ if(stmt.asmStmt.spec)
+ FreeSpecifier(stmt.asmStmt.spec);
+ if(stmt.asmStmt.inputFields)
+ FreeList(stmt.asmStmt.inputFields, FreeAsmField);
+ if(stmt.asmStmt.outputFields)
+ FreeList(stmt.asmStmt.outputFields, FreeAsmField);
+ if(stmt.asmStmt.clobberedFields)
+ FreeList(stmt.asmStmt.clobberedFields, FreeAsmField);
+ delete stmt.asmStmt.statements;
+ break;
+ }
case labeledStmt:
if(stmt.labeled.stmt)
FreeStatement(stmt.labeled.stmt);
FreeStatement(stmt.caseStmt.stmt);
break;
case badDeclarationStmt:
- FreeDeclaration(stmt.decl);
+ if(stmt.decl)
+ FreeDeclaration(stmt.decl);
break;
case compoundStmt:
{
{
if(stmt.forStmt.init)
FreeStatement(stmt.forStmt.init);
-
+
if(stmt.forStmt.check)
FreeStatement(stmt.forStmt.check);
-
+
if(stmt.forStmt.increment)
FreeList(stmt.forStmt.increment, FreeExpression);
if(stmt.forStmt.stmt)
if(stmt._watch.object)
FreeExpression(stmt._watch.object);
if(stmt._watch.watches)
- FreeList(stmt._watch.watches, (stmt.type == watchStmt) ? FreePropertyWatch : FreeIdentifier);
+ FreeList(stmt._watch.watches, (stmt.type == watchStmt) ? (void *)FreePropertyWatch : (void *)FreeIdentifier);
break;
}
}
switch(initializer.type)
{
case listInitializer:
- {
FreeList(initializer.list, FreeInitializer);
break;
- }
case expInitializer:
if(initializer.exp)
FreeExpression(initializer.exp);
break;
}
+ if(initializer.id)
+ FreeIdentifier(initializer.id);
delete initializer;
}
delete init;
}
-void FreeInstance(Instantiation inst)
+public void FreeInstance(Instantiation inst)
{
if(inst.members)
{
if(inst._class)
FreeSpecifier(inst._class);
-
+
// Free symbol?
// Free data;
FreeStatement(def.issetStmt);
if(def.category)
FreeExpression(def.category);
-
+
/*
if(def.getFunction)
FreeFunction(def.getFunction);
void FreeExternal(External external)
{
+ TopoEdge e;
+ while((e = external.incoming.first))
+ {
+ e.from.outgoing.Remove((IteratorPointer)e);
+ external.incoming.Remove((IteratorPointer)e);
+ delete e;
+ }
+ while((e = external.outgoing.first))
+ {
+ e.to.incoming.Remove((IteratorPointer)e);
+ external.outgoing.Remove((IteratorPointer)e);
+ if(!e.breakable)
+ e.to.nonBreakableIncoming--;
+ delete e;
+ }
switch(external.type)
{
- case functionExternal:
+ case functionExternal:
if(external.function)
FreeFunction(external.function);
break;
- case declarationExternal:
+ case declarationExternal:
if(external.declaration)
FreeDeclaration(external.declaration);
break;
- case classExternal:
+ case classExternal:
if(external._class)
FreeClass(external._class);
break;
if(ast != null)
{
External external;
- while(external = ast.first)
+ while((external = ast.first))
{
ast.Remove(external);
FreeExternal(external);
}
}
+static void FreeClassProperties(ClassProperty classProp)
+{
+ if(classProp.left) FreeClassProperties(classProp.left);
+ if(classProp.right) FreeClassProperties(classProp.right);
+ if(classProp.dataType)
+ {
+ FreeType(classProp.dataType);
+ classProp.dataType = null;
+ }
+}
+
void FreeModuleData(Module module)
{
Class _class;
GlobalFunction function;
-
+
// Unload classes
for(_class = module.classes.first; _class; _class = _class.next)
{
DataMember dataMember;
Method method;
ClassTemplateParameter param;
- ClassProperty classProp;
if(_class.dataType)
{
prop.dataType = null;
}
}
+ if(_class.classProperties.first)
+ FreeClassProperties((ClassProperty)_class.classProperties.first);
for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
{
if(method.dataType)
}
}
}
-
+
for(function = module.functions.first; function; function = function.next)
{
- if(function.dataType)
+ if(function.dataType)
FreeType(function.dataType);
- if(function.symbol)
+ if(function.symbol)
FreeSymbol(function.symbol);
}
list.Remove(list.GetFirst());
loadedModules.Remove(mapIt.pointer);
delete list;
- eModule_Unload(__thisModule, mod);
+ eModule_Unload(__thisModule.application, mod);
}
break;
}