8000 Minor code cleanups after compiling with Clang · cpp-tutor/pseudocode-compiler@225e3fd · GitHub
[go: up one dir, main page]

Skip to content

Commit 225e3fd

Browse files
committed
Minor code cleanups after compiling with Clang
1 parent 081a3fc commit 225e3fd

File tree

5 files changed

+8
-22
lines changed

5 files changed

+8
-22
lines changed

Expression.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Expression : public Tree {
2929
virtual bool isConstant() = 0;
3030
virtual ExpI type() = 0;
3131
virtual ExpT apply() = 0;
32+
virtual ~Expression() {}
3233
protected:
3334
template<typename T>
3435
inline static const std::unordered_map<Operator,std::function<BoolT(T,T)>> Rel_ops{
@@ -42,22 +43,22 @@ class Expression : public Tree {
4243
inline static const std::unordered_map<Operator,std::function<BoolT(BoolT,BoolT)>> BoolT_ops{
4344
{ Operator::OR, [](IntT a, IntT b){ return a | b; } },
4445
{ Operator::AND, [](IntT a, IntT b){ return a & b; } },
45-
{ Operator::NOT, [](IntT a, IntT b){ return ~a; } }
46+
{ Operator::NOT, [](IntT a, [[maybe_unused]] IntT b){ return ~a; } }
4647
};
4748
inline static const std::unordered_map<Operator,std::function<IntT(IntT,IntT)>> IntT_ops{
4849
{ Operator::plus, [](IntT a, IntT b){ return a + b; } },
4950
{ Operator::minus, [](IntT a, IntT b){ return a - b; } },
5051
{ Operator::multiply, [](IntT a, IntT b){ return a * b; } },
5152
{ Operator::DIV, [](IntT a, IntT b){ return a / b; } },
5253
{ Operator::MOD, [](IntT a, IntT b){ return a % b; } },
53-
{ Operator::negative, [](IntT a, IntT b){ return -a; } }
54+
{ Operator::negative, [](IntT a, [[maybe_unused]] IntT b){ return -a; } }
5455
};
5556
inline static const std::unordered_map<Operator,std::function<RealT(RealT,RealT)>> RealT_ops{
5657
{ Operator::plus, [](RealT a, RealT b){ return a + b; } },
5758
{ Operator::minus, [](RealT a, RealT b){ return a - b; } },
5859
{ Operator::multiply, [](RealT a, RealT b){ return a * b; } },
5960
{ Operator::divide, [](RealT a, RealT b){ return a / b; } },
60-
{ Operator::negative, [](RealT a, RealT b){ return -a; } }
61+
{ Operator::negative, [](RealT a, [[maybe_unused]] RealT b){ return -a; } }
6162
};
6263
inline static const std::unordered_map<Operator,std::function<StringT(StringT,StringT)>> StringT_ops{
6364
{ Operator::plus, [](StringT a, StringT b){ return static_cast<StringT>(a.append(b)); } }
@@ -179,7 +180,7 @@ class Variable : public Expression {
179180
ExpI tp;
180181
public:
181182
Variable(ExpI t, std::string_view l)
182-
: tp{ t }, label{ l } {}
183+
: label{ l }, tp{ t } {}
183184
virtual bool isConstant() override {
184185
return false;
185186
}

For.hpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ class For : public Tree {
3535
right->emit();
3636
}
3737
}
38-
virtual ~For() {
39-
delete from;
40-
delete to;
41-
delete step;
42-
}
38+
4339
};
4440

4541
class ForIn : public Tree {
@@ -63,9 +59,6 @@ class ForIn : public Tree {
6359
right->emit();
6460
}
6561
}
66-
virtual ~ForIn() {
67-
delete exp;
68-
}
6962
};
7063

7164
#endif // FOR_HPP

Lexer.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
namespace yy {
77

88
class Lexer : public yyFlexLexer {
9-
size_t location_x{ 1 }, location_y{ 1 };
109
public:
1110
Lexer(std::istream& arg_yyin, std::ostream& arg_yyout)
1211
: yyFlexLexer(arg_yyin, arg_yyout) {}

Utility.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ class StringPos : public Expression {
5252
virtual ExpI type() override {
5353
return ExpI::IntT;
5454
}
55-
virtual ~StringPos() {
56-
delete sub;
57-
}
5855
};
5956

6057
class StringSub : public Expression {
@@ -86,10 +83,6 @@ class StringSub : public Expression {
8683
virtual ExpI type() override {
8784
return ExpI::StringT;
8885
}
89-
virtual ~StringSub() {
90-
delete from;
91-
delete to;
92-
}
9386
};
9487

9588
class StringToInt : public Expression {

main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const std::vector<std::pair<std::string_view,std::string_view>> Options{
3434
#endif
3535
};
3636

37-
const auto support_nodejs_code = 1 + R"(
38-
const readline_sync = require('readline-sync');
37+
const auto support_nodejs_code =
38+
R"(const readline_sync = require('readline-sync');
3939
function readline() {
4040
return readline_sync.question('');
4141
}

0 commit comments

Comments
 (0)
0