Remove trivial destructors and constructors from Java AST
It seems likely we can share a lot of this code with the C++
AST. Clean it up a little.
Test: unittests pass, clean build of Android passes
Change-Id: I1548a108fb4ba4d9561ed9502b0808b497343790
diff --git a/ast_java.cpp b/ast_java.cpp
index c80414c..aac691e 100644
--- a/ast_java.cpp
+++ b/ast_java.cpp
@@ -67,21 +67,6 @@
}
}
-ClassElement::ClassElement()
-{
-}
-
-ClassElement::~ClassElement()
-{
-}
-
-Field::Field()
- :ClassElement(),
- modifiers(0),
- variable(NULL)
-{
-}
-
Field::Field(int m, Variable* v)
:ClassElement(),
modifiers(m),
@@ -89,10 +74,6 @@
{
}
-Field::~Field()
-{
-}
-
void
Field::GatherTypes(set<const Type*>* types) const
{
@@ -114,19 +95,11 @@
to->Write(";\n");
}
-Expression::~Expression()
-{
-}
-
LiteralExpression::LiteralExpression(const string& v)
:value(v)
{
}
-LiteralExpression::~LiteralExpression()
-{
-}
-
void
LiteralExpression::Write(CodeWriter* to) const
{
@@ -138,23 +111,12 @@
{
}
-StringLiteralExpression::~StringLiteralExpression()
-{
-}
-
void
StringLiteralExpression::Write(CodeWriter* to) const
{
to->Write("\"%s\"", this->value.c_str());
}
-Variable::Variable()
- :type(NULL),
- name(),
- dimension(0)
-{
-}
-
Variable::Variable(const Type* t, const string& n)
:type(t),
name(n),
@@ -169,10 +131,6 @@
{
}
-Variable::~Variable()
-{
-}
-
void
Variable::GatherTypes(set<const Type*>* types) const
{
@@ -210,10 +168,6 @@
{
}
-FieldVariable::~FieldVariable()
-{
-}
-
void
FieldVariable::Write(CodeWriter* to) const
{
@@ -226,19 +180,6 @@
to->Write(".%s", name.c_str());
}
-
-Statement::~Statement()
-{
-}
-
-StatementBlock::StatementBlock()
-{
-}
-
-StatementBlock::~StatementBlock()
-{
-}
-
void
StatementBlock::Write(CodeWriter* to) const
{
@@ -267,10 +208,6 @@
{
}
-ExpressionStatement::~ExpressionStatement()
-{
-}
-
void
ExpressionStatement::Write(CodeWriter* to) const
{
@@ -292,10 +229,6 @@
{
}
-Assignment::~Assignment()
-{
-}
-
void
Assignment::Write(CodeWriter* to) const
{
@@ -308,16 +241,12 @@
}
MethodCall::MethodCall(const string& n)
- :obj(NULL),
- clazz(NULL),
- name(n)
+ : name(n)
{
}
MethodCall::MethodCall(const string& n, int argc = 0, ...)
- :obj(NULL),
- clazz(NULL),
- name(n)
+ :name(n)
{
va_list args;
va_start(args, argc);
@@ -327,21 +256,18 @@
MethodCall::MethodCall(Expression* o, const string& n)
:obj(o),
- clazz(NULL),
name(n)
{
}
MethodCall::MethodCall(const Type* t, const string& n)
- :obj(NULL),
- clazz(t),
+ :clazz(t),
name(n)
{
}
MethodCall::MethodCall(Expression* o, const string& n, int argc = 0, ...)
:obj(o),
- clazz(NULL),
name(n)
{
va_list args;
@@ -351,8 +277,7 @@
}
MethodCall::MethodCall(const Type* t, const string& n, int argc = 0, ...)
- :obj(NULL),
- clazz(t),
+ :clazz(t),
name(n)
{
va_list args;
@@ -361,10 +286,6 @@
va_end(args);
}
-MethodCall::~MethodCall()
-{
-}
-
void
MethodCall::init(int n, va_list args)
{
@@ -396,10 +317,6 @@
{
}
-Comparison::~Comparison()
-{
-}
-
void
Comparison::Write(CodeWriter* to) const
{
@@ -424,10 +341,6 @@
va_end(args);
}
-NewExpression::~NewExpression()
-{
-}
-
void
NewExpression::init(int n, va_list args)
{
@@ -451,10 +364,6 @@
{
}
-NewArrayExpression::~NewArrayExpression()
-{
-}
-
void
NewArrayExpression::Write(CodeWriter* to) const
{
@@ -463,13 +372,6 @@
to->Write("]");
}
-Ternary::Ternary()
- :condition(NULL),
- ifpart(NULL),
- elsepart(NULL)
-{
-}
-
Ternary::Ternary(Expression* a, Expression* b, Expression* c)
:condition(a),
ifpart(b),
@@ -477,10 +379,6 @@
{
}
-Ternary::~Ternary()
-{
-}
-
void
Ternary::Write(CodeWriter* to) const
{
@@ -493,22 +391,12 @@
to->Write("))");
}
-Cast::Cast()
- :type(NULL),
- expression(NULL)
-{
-}
-
Cast::Cast(const Type* t, Expression* e)
:type(t),
expression(e)
{
}
-Cast::~Cast()
-{
-}
-
void
Cast::Write(CodeWriter* to) const
{
@@ -525,13 +413,7 @@
}
VariableDeclaration::VariableDeclaration(Variable* l)
- :lvalue(l),
- cast(NULL),
- rvalue(NULL)
-{
-}
-
-VariableDeclaration::~VariableDeclaration()
+ :lvalue(l)
{
}
@@ -549,17 +431,6 @@
to->Write(";\n");
}
-IfStatement::IfStatement()
- :expression(NULL),
- statements(new StatementBlock),
- elseif(NULL)
-{
-}
-
-IfStatement::~IfStatement()
-{
-}
-
void
IfStatement::Write(CodeWriter* to) const
{
@@ -580,10 +451,6 @@
{
}
-ReturnStatement::~ReturnStatement()
-{
-}
-
void
ReturnStatement::Write(CodeWriter* to) const
{
@@ -592,15 +459,6 @@
to->Write(";\n");
}
-TryStatement::TryStatement()
- :statements(new StatementBlock)
-{
-}
-
-TryStatement::~TryStatement()
-{
-}
-
void
TryStatement::Write(CodeWriter* to) const
{
@@ -614,10 +472,6 @@
{
}
-CatchStatement::~CatchStatement()
-{
-}
-
void
CatchStatement::Write(CodeWriter* to) const
{
@@ -630,15 +484,6 @@
this->statements->Write(to);
}
-FinallyStatement::FinallyStatement()
- :statements(new StatementBlock)
-{
-}
-
-FinallyStatement::~FinallyStatement()
-{
-}
-
void
FinallyStatement::Write(CodeWriter* to) const
{
@@ -646,21 +491,11 @@
this->statements->Write(to);
}
-Case::Case()
- :statements(new StatementBlock)
-{
-}
-
Case::Case(const string& c)
- :statements(new StatementBlock)
{
cases.push_back(c);
}
-Case::~Case()
-{
-}
-
void
Case::Write(CodeWriter* to) const
{
@@ -685,10 +520,6 @@
{
}
-SwitchStatement::~SwitchStatement()
-{
-}
-
void
SwitchStatement::Write(CodeWriter* to) const
{
@@ -702,33 +533,12 @@
to->Write("}\n");
}
-Break::Break()
-{
-}
-
-Break::~Break()
-{
-}
-
void
Break::Write(CodeWriter* to) const
{
to->Write("break;\n");
}
-Method::Method()
- :ClassElement(),
- modifiers(0),
- returnType(NULL), // (NULL means constructor)
- returnTypeDimension(0),
- statements(NULL)
-{
-}
-
-Method::~Method()
-{
-}
-
void
Method::GatherTypes(set<const Type*>* types) const
{
@@ -799,18 +609,6 @@
}
}
-Class::Class()
- :modifiers(0),
- what(CLASS),
- type(NULL),
- extends(NULL)
-{
-}
-
-Class::~Class()
-{
-}
-
void
Class::GatherTypes(set<const Type*>* types) const
{
@@ -885,14 +683,6 @@
}
-Document::Document()
-{
-}
-
-Document::~Document()
-{
-}
-
static string
escape_backslashes(const string& str)
{