Commit eb4aaa96 authored by zygzagZ's avatar zygzagZ

Fix mem leaks

parent c7ae29b0
......@@ -14,7 +14,6 @@ FunctionInfo::FunctionInfo(FuncDef *expr, ClassInfoPtr klass)
}
}
Binding::Binding(shared_ptr<Binding> parent)
: variables(parent ? &parent->variables : nullptr),
classes(parent ? &parent->classes : nullptr, &variables),
......
......@@ -31,7 +31,7 @@ public:
Block * block;
vector<VarInfoPtr> arguments;
weak_ptr<ClassInfo> klass;
shared_ptr<Binding> binding;
weak_ptr<Binding> binding;
FunctionInfo(FuncDef *expr, ClassInfoPtr klass = nullptr);
// FunctionInfo(PIdent *ident, ClassInfoPtr klass = nullptr) : VarInfo(ident), block(NULL), klass(klass) {};
};
......@@ -44,10 +44,10 @@ public:
InfoList<ClassInfo> classes;
InfoList<FunctionInfo> functions;
BindingPtr parent;
weak_ptr<Binding> parent;
Binding(BindingPtr parent = nullptr);
BindingPtr getParent() const { return parent; };
BindingPtr getParent() const { return parent.lock(); };
};
class ClassInfo : public VarInfo, public Binding
......
......@@ -53,6 +53,7 @@ int main(int argc, char ** argv)
fprintf(stderr, "Parser error, invalid syntax!\n");
return 1;
}
fclose(input);
if (!quiet) {
fprintf(stderr, "\n[Abstract Syntax]\n");
......
......@@ -606,7 +606,7 @@ void TypeCheck::checkFunction(FunctionInfoPtr f)
{
scope->currentFunction = f;
if (f->binding) throw runtime_error("Ale ten binding juz istnieje");
if (f->binding.lock()) throw runtime_error("Ale ten binding juz istnieje");
BindingPtr binding = make_shared<Binding>(getParentBinding());
f->binding = binding;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment