fix memory
This commit is contained in:
parent
5a453c6799
commit
dc9a8194c2
@ -1954,7 +1954,7 @@ void compiler::process_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt
|
|||||||
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
||||||
{
|
{
|
||||||
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
||||||
auto current_case = gsc::stmt_ptr(std::make_unique<gsc::node>());
|
auto current_case = gsc::stmt_ptr(nullptr);
|
||||||
|
|
||||||
auto num = stmt->stmt->stmts.size();
|
auto num = stmt->stmt->stmts.size();
|
||||||
|
|
||||||
@ -1964,7 +1964,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
|
|
||||||
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
@ -1974,7 +1974,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
||||||
{
|
{
|
||||||
@ -1989,12 +1989,12 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gsc::comp_error(entry.as_node->loc, "missing case statement");
|
throw gsc::comp_error(entry.as_node->loc, "missing case statement");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
|
@ -1954,7 +1954,7 @@ void compiler::process_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt
|
|||||||
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
||||||
{
|
{
|
||||||
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
||||||
auto current_case = gsc::stmt_ptr(std::make_unique<gsc::node>());
|
auto current_case = gsc::stmt_ptr(nullptr);
|
||||||
|
|
||||||
auto num = stmt->stmt->stmts.size();
|
auto num = stmt->stmt->stmts.size();
|
||||||
|
|
||||||
@ -1964,7 +1964,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
|
|
||||||
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
@ -1974,7 +1974,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
||||||
{
|
{
|
||||||
@ -1989,12 +1989,12 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gsc::comp_error(entry.as_node->loc, "missing case statement");
|
throw gsc::comp_error(entry.as_node->loc, "missing case statement");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
|
@ -1948,7 +1948,7 @@ void compiler::process_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt
|
|||||||
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
||||||
{
|
{
|
||||||
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
||||||
auto current_case = gsc::stmt_ptr(std::make_unique<gsc::node>());
|
auto current_case = gsc::stmt_ptr(nullptr);
|
||||||
|
|
||||||
auto num = stmt->stmt->stmts.size();
|
auto num = stmt->stmt->stmts.size();
|
||||||
|
|
||||||
@ -1958,7 +1958,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
|
|
||||||
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
@ -1968,7 +1968,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
||||||
{
|
{
|
||||||
@ -1983,12 +1983,12 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gsc::comp_error(entry.as_node->loc, "missing case statement");
|
throw gsc::comp_error(entry.as_node->loc, "missing case statement");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
|
@ -1948,7 +1948,7 @@ void compiler::process_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt
|
|||||||
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
||||||
{
|
{
|
||||||
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
||||||
auto current_case = gsc::stmt_ptr(std::make_unique<gsc::node>());
|
auto current_case = gsc::stmt_ptr(nullptr);
|
||||||
|
|
||||||
auto num = stmt->stmt->stmts.size();
|
auto num = stmt->stmt->stmts.size();
|
||||||
|
|
||||||
@ -1958,7 +1958,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
|
|
||||||
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
@ -1968,7 +1968,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
||||||
{
|
{
|
||||||
@ -1983,12 +1983,12 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gsc::comp_error(entry.as_node->loc, "missing case statement");
|
throw gsc::comp_error(entry.as_node->loc, "missing case statement");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
|
@ -1948,7 +1948,7 @@ void compiler::process_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt
|
|||||||
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
||||||
{
|
{
|
||||||
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
||||||
auto current_case = gsc::stmt_ptr(std::make_unique<gsc::node>());
|
auto current_case = gsc::stmt_ptr(nullptr);
|
||||||
|
|
||||||
auto num = stmt->stmt->stmts.size();
|
auto num = stmt->stmt->stmts.size();
|
||||||
|
|
||||||
@ -1958,7 +1958,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
|
|
||||||
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
@ -1968,7 +1968,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
||||||
{
|
{
|
||||||
@ -1983,12 +1983,12 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gsc::comp_error(entry.as_node->loc, "missing case statement");
|
throw gsc::comp_error(entry.as_node->loc, "missing case statement");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
|
@ -1954,7 +1954,7 @@ void compiler::process_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt
|
|||||||
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
||||||
{
|
{
|
||||||
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
||||||
auto current_case = gsc::stmt_ptr(std::make_unique<gsc::node>());
|
auto current_case = gsc::stmt_ptr(nullptr);
|
||||||
|
|
||||||
auto num = stmt->stmt->stmts.size();
|
auto num = stmt->stmt->stmts.size();
|
||||||
|
|
||||||
@ -1964,7 +1964,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
|
|
||||||
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
@ -1974,7 +1974,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
||||||
{
|
{
|
||||||
@ -1989,12 +1989,12 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gsc::comp_error(entry.as_node->loc, "missing case statement");
|
throw gsc::comp_error(entry.as_node->loc, "missing case statement");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
|
@ -1954,7 +1954,7 @@ void compiler::process_stmt_foreach(const gsc::context_ptr& ctx, const gsc::stmt
|
|||||||
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_switch_ptr& stmt)
|
||||||
{
|
{
|
||||||
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
auto stmt_list = std::make_unique<gsc::node_stmt_list>(stmt->stmt->loc);
|
||||||
auto current_case = gsc::stmt_ptr(std::make_unique<gsc::node>());
|
auto current_case = gsc::stmt_ptr(nullptr);
|
||||||
|
|
||||||
auto num = stmt->stmt->stmts.size();
|
auto num = stmt->stmt->stmts.size();
|
||||||
|
|
||||||
@ -1964,7 +1964,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
|
|
||||||
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
if(entry.as_node->type == gsc::node_t::stmt_case || entry.as_node->type == gsc::node_t::stmt_default)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
@ -1974,7 +1974,7 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
if(current_case.as_node->type == gsc::node_t::stmt_case)
|
||||||
{
|
{
|
||||||
@ -1989,12 +1989,12 @@ void compiler::process_stmt_switch(const gsc::context_ptr& ctx, const gsc::stmt_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gsc::comp_error(entry.as_node->loc, "missing case statement");
|
throw gsc::comp_error(entry.as_node->loc, "missing case statement");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current_case.as_node->type != gsc::node_t::null)
|
if(current_case.as_node != nullptr)
|
||||||
{
|
{
|
||||||
stmt_list->stmts.push_back(std::move(current_case));
|
stmt_list->stmts.push_back(std::move(current_case));
|
||||||
}
|
}
|
||||||
|
@ -342,10 +342,12 @@ union expr_call_type_ptr
|
|||||||
expr_call_pointer_ptr as_pointer;
|
expr_call_pointer_ptr as_pointer;
|
||||||
expr_call_function_ptr as_func;
|
expr_call_function_ptr as_func;
|
||||||
|
|
||||||
expr_call_type_ptr() {}
|
expr_call_type_ptr() : as_node(nullptr) {}
|
||||||
expr_call_type_ptr(node_ptr val): as_node(std::move(val)) {}
|
expr_call_type_ptr(node_ptr val): as_node(std::move(val)) {}
|
||||||
expr_call_type_ptr(expr_call_type_ptr && val) { new(&as_node) node_ptr(std::move(val.as_node)); }
|
expr_call_type_ptr(const expr_call_type_ptr &) = delete;
|
||||||
~expr_call_type_ptr(){}
|
expr_call_type_ptr& operator=(const expr_call_type_ptr&) = delete;
|
||||||
|
expr_call_type_ptr(expr_call_type_ptr&& val) { new(&as_node) node_ptr(std::move(val.as_node)); }
|
||||||
|
~expr_call_type_ptr();
|
||||||
};
|
};
|
||||||
|
|
||||||
union expr_ptr
|
union expr_ptr
|
||||||
@ -418,21 +420,13 @@ union expr_ptr
|
|||||||
asm_create_ptr as_asm_create;
|
asm_create_ptr as_asm_create;
|
||||||
asm_access_ptr as_asm_access;
|
asm_access_ptr as_asm_access;
|
||||||
|
|
||||||
expr_ptr() {}
|
expr_ptr() : as_node(nullptr) {}
|
||||||
expr_ptr(node_ptr val): as_node(std::move(val)) {}
|
expr_ptr(node_ptr val): as_node(std::move(val)) {}
|
||||||
expr_ptr (expr_ptr && val)
|
expr_ptr(const expr_ptr&) = delete;
|
||||||
{
|
expr_ptr& operator=(const expr_ptr&) = delete;
|
||||||
new(&as_node) node_ptr(std::move(val.as_node));
|
expr_ptr(expr_ptr && val) { new(&as_node) node_ptr(std::move(val.as_node)); }
|
||||||
}
|
expr_ptr& operator=(expr_ptr&& val) { new(&as_node) node_ptr(std::move(val.as_node)); return *(expr_ptr*)&as_node; }
|
||||||
|
~expr_ptr();
|
||||||
~expr_ptr(){}
|
|
||||||
|
|
||||||
expr_ptr& operator=(expr_ptr && val)
|
|
||||||
{
|
|
||||||
new(&as_node) node_ptr(std::move(val.as_node));
|
|
||||||
return *(expr_ptr*)&as_node;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const expr_ptr& rhs) const;
|
bool operator==(const expr_ptr& rhs) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -474,18 +468,13 @@ union stmt_ptr
|
|||||||
asm_remove_ptr as_asm_remove;
|
asm_remove_ptr as_asm_remove;
|
||||||
asm_clear_ptr as_asm_clear;
|
asm_clear_ptr as_asm_clear;
|
||||||
|
|
||||||
stmt_ptr() {}
|
stmt_ptr() : as_node(nullptr) {}
|
||||||
stmt_ptr(node_ptr val): as_node(std::move(val)) {}
|
stmt_ptr(node_ptr val): as_node(std::move(val)) {}
|
||||||
stmt_ptr(const stmt_ptr &) = delete;
|
stmt_ptr(const stmt_ptr &) = delete;
|
||||||
stmt_ptr & operator=(const stmt_ptr &) = delete;
|
stmt_ptr& operator=(const stmt_ptr&) = delete;
|
||||||
|
stmt_ptr(stmt_ptr&& val) { new(&as_node) node_ptr(std::move(val.as_node)); }
|
||||||
stmt_ptr (stmt_ptr && val) { new(&as_node) node_ptr(std::move(val.as_node)); }
|
stmt_ptr& operator=(stmt_ptr&& val ) { new(&as_node) node_ptr(std::move(val.as_node)); return *(stmt_ptr*)&as_node; }
|
||||||
stmt_ptr& operator=(stmt_ptr &&val )
|
~stmt_ptr();
|
||||||
{
|
|
||||||
new(&as_node) node_ptr(std::move(val.as_node));
|
|
||||||
return *(stmt_ptr*)&as_node;
|
|
||||||
}
|
|
||||||
~stmt_ptr(){}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
union define_ptr
|
union define_ptr
|
||||||
@ -495,10 +484,13 @@ union define_ptr
|
|||||||
constant_ptr as_constant;
|
constant_ptr as_constant;
|
||||||
thread_ptr as_thread;
|
thread_ptr as_thread;
|
||||||
|
|
||||||
define_ptr() {}
|
define_ptr() : as_node(nullptr) {}
|
||||||
define_ptr(node_ptr val): as_node(std::move(val)) {}
|
define_ptr(node_ptr val) : as_node(std::move(val)) {}
|
||||||
define_ptr(define_ptr && val) { new(&as_node) node_ptr(std::move(val.as_node)); }
|
define_ptr(const define_ptr &) = delete;
|
||||||
~define_ptr(){}
|
define_ptr& operator=(const define_ptr&) = delete;
|
||||||
|
define_ptr(define_ptr&& val) { new(&as_node) node_ptr(std::move(val.as_node)); }
|
||||||
|
define_ptr& operator=(define_ptr&& val ) { new(&as_node) node_ptr(std::move(val.as_node)); return *(define_ptr*)&as_node; }
|
||||||
|
~define_ptr();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct node
|
struct node
|
||||||
@ -1899,10 +1891,10 @@ struct node_stmt_if : public node
|
|||||||
context_ptr ctx;
|
context_ptr ctx;
|
||||||
|
|
||||||
node_stmt_if(expr_ptr expr, stmt_ptr stmt)
|
node_stmt_if(expr_ptr expr, stmt_ptr stmt)
|
||||||
: node(node_t::stmt_if), expr(std::move(expr)), stmt(std::move(stmt)) {}
|
: node(node_t::stmt_if), expr(std::move(expr)), stmt(std::move(stmt)), ctx(nullptr) {}
|
||||||
|
|
||||||
node_stmt_if(const location& loc, expr_ptr expr, stmt_ptr stmt)
|
node_stmt_if(const location& loc, expr_ptr expr, stmt_ptr stmt)
|
||||||
: node(node_t::stmt_if, loc), expr(std::move(expr)), stmt(std::move(stmt)) {}
|
: node(node_t::stmt_if, loc), expr(std::move(expr)), stmt(std::move(stmt)), ctx(nullptr) {}
|
||||||
|
|
||||||
auto print() -> std::string override
|
auto print() -> std::string override
|
||||||
{
|
{
|
||||||
@ -1932,10 +1924,10 @@ struct node_stmt_ifelse : public node
|
|||||||
context_ptr ctx_else;
|
context_ptr ctx_else;
|
||||||
|
|
||||||
node_stmt_ifelse(expr_ptr expr, stmt_ptr stmt_if, stmt_ptr stmt_else)
|
node_stmt_ifelse(expr_ptr expr, stmt_ptr stmt_if, stmt_ptr stmt_else)
|
||||||
: node(node_t::stmt_ifelse), expr(std::move(expr)), stmt_if(std::move(stmt_if)), stmt_else(std::move(stmt_else)) {}
|
: node(node_t::stmt_ifelse), expr(std::move(expr)), stmt_if(std::move(stmt_if)), stmt_else(std::move(stmt_else)), ctx_if(nullptr), ctx_else(nullptr) {}
|
||||||
|
|
||||||
node_stmt_ifelse(const location& loc, expr_ptr expr, stmt_ptr stmt_if, stmt_ptr stmt_else)
|
node_stmt_ifelse(const location& loc, expr_ptr expr, stmt_ptr stmt_if, stmt_ptr stmt_else)
|
||||||
: node(node_t::stmt_ifelse, loc), expr(std::move(expr)), stmt_if(std::move(stmt_if)), stmt_else(std::move(stmt_else)) {}
|
: node(node_t::stmt_ifelse, loc), expr(std::move(expr)), stmt_if(std::move(stmt_if)), stmt_else(std::move(stmt_else)), ctx_if(nullptr), ctx_else(nullptr) {}
|
||||||
|
|
||||||
auto print() -> std::string override
|
auto print() -> std::string override
|
||||||
{
|
{
|
||||||
@ -1984,10 +1976,10 @@ struct node_stmt_while : public node
|
|||||||
context_ptr ctx;
|
context_ptr ctx;
|
||||||
|
|
||||||
node_stmt_while(expr_ptr expr, stmt_ptr stmt)
|
node_stmt_while(expr_ptr expr, stmt_ptr stmt)
|
||||||
: node(node_t::stmt_while), expr(std::move(expr)), stmt(std::move(stmt)) {}
|
: node(node_t::stmt_while), expr(std::move(expr)), stmt(std::move(stmt)), ctx(nullptr) {}
|
||||||
|
|
||||||
node_stmt_while(const location& loc, expr_ptr expr, stmt_ptr stmt)
|
node_stmt_while(const location& loc, expr_ptr expr, stmt_ptr stmt)
|
||||||
: node(node_t::stmt_while, loc), expr(std::move(expr)), stmt(std::move(stmt)) {}
|
: node(node_t::stmt_while, loc), expr(std::move(expr)), stmt(std::move(stmt)), ctx(nullptr) {}
|
||||||
|
|
||||||
auto print() -> std::string override
|
auto print() -> std::string override
|
||||||
{
|
{
|
||||||
@ -2031,11 +2023,11 @@ struct node_stmt_for : public node
|
|||||||
|
|
||||||
node_stmt_for(stmt_ptr pre_expr, expr_ptr expr, stmt_ptr post_expr, stmt_ptr stmt)
|
node_stmt_for(stmt_ptr pre_expr, expr_ptr expr, stmt_ptr post_expr, stmt_ptr stmt)
|
||||||
: node(node_t::stmt_for), pre_expr(std::move(pre_expr)), expr(std::move(expr)),
|
: node(node_t::stmt_for), pre_expr(std::move(pre_expr)), expr(std::move(expr)),
|
||||||
post_expr(std::move(post_expr)), stmt(std::move(stmt)) {}
|
post_expr(std::move(post_expr)), stmt(std::move(stmt)), ctx(nullptr), ctx_post(nullptr) {}
|
||||||
|
|
||||||
node_stmt_for(const location& loc, stmt_ptr pre_expr, expr_ptr expr, stmt_ptr post_expr, stmt_ptr stmt)
|
node_stmt_for(const location& loc, stmt_ptr pre_expr, expr_ptr expr, stmt_ptr post_expr, stmt_ptr stmt)
|
||||||
: node(node_t::stmt_for, loc), pre_expr(std::move(pre_expr)), expr(std::move(expr)),
|
: node(node_t::stmt_for, loc), pre_expr(std::move(pre_expr)), expr(std::move(expr)),
|
||||||
post_expr(std::move(post_expr)), stmt(std::move(stmt)) {}
|
post_expr(std::move(post_expr)), stmt(std::move(stmt)), ctx(nullptr), ctx_post(nullptr) {}
|
||||||
|
|
||||||
auto print() -> std::string override
|
auto print() -> std::string override
|
||||||
{
|
{
|
||||||
@ -2083,23 +2075,29 @@ struct node_stmt_foreach : public node
|
|||||||
std::vector<std::string> vars;
|
std::vector<std::string> vars;
|
||||||
|
|
||||||
node_stmt_foreach(const location& loc, stmt_ptr stmt, bool use_key)
|
node_stmt_foreach(const location& loc, stmt_ptr stmt, bool use_key)
|
||||||
: node(node_t::stmt_foreach, loc), stmt(std::move(stmt)), use_key(use_key) {}
|
: node(node_t::stmt_foreach, loc), stmt(std::move(stmt)), use_key(use_key),
|
||||||
|
array_expr(nullptr), value_expr(nullptr), key_expr(nullptr), array(nullptr),
|
||||||
|
pre_expr(nullptr), cond_expr(nullptr), post_expr(nullptr), stmt0(nullptr), ctx(nullptr), ctx_post(nullptr) {}
|
||||||
|
|
||||||
node_stmt_foreach(expr_ptr element, expr_ptr container, stmt_ptr stmt)
|
node_stmt_foreach(expr_ptr element, expr_ptr container, stmt_ptr stmt)
|
||||||
: node(node_t::stmt_foreach), value_expr(std::move(element)), array_expr(std::move(container)),
|
: node(node_t::stmt_foreach), value_expr(std::move(element)), array_expr(std::move(container)),
|
||||||
stmt(std::move(stmt)), use_key(false) {}
|
stmt(std::move(stmt)), use_key(false), key_expr(nullptr), array(nullptr), pre_expr(nullptr),
|
||||||
|
cond_expr(nullptr), post_expr(nullptr), stmt0(nullptr), ctx(nullptr), ctx_post(nullptr) {}
|
||||||
|
|
||||||
node_stmt_foreach(expr_ptr key, expr_ptr element, expr_ptr container, stmt_ptr stmt)
|
node_stmt_foreach(expr_ptr key, expr_ptr element, expr_ptr container, stmt_ptr stmt)
|
||||||
: node(node_t::stmt_foreach), key_expr(std::move(key)), value_expr(std::move(element)), array_expr(std::move(container)),
|
: node(node_t::stmt_foreach), key_expr(std::move(key)), value_expr(std::move(element)), array_expr(std::move(container)),
|
||||||
stmt(std::move(stmt)), use_key(true) {}
|
stmt(std::move(stmt)), use_key(true), array(nullptr), pre_expr(nullptr), cond_expr(nullptr),
|
||||||
|
post_expr(nullptr), stmt0(nullptr), ctx(nullptr), ctx_post(nullptr) {}
|
||||||
|
|
||||||
node_stmt_foreach(const location& loc, expr_ptr element, expr_ptr container, stmt_ptr stmt)
|
node_stmt_foreach(const location& loc, expr_ptr element, expr_ptr container, stmt_ptr stmt)
|
||||||
: node(node_t::stmt_foreach, loc), value_expr(std::move(element)), array_expr(std::move(container)),
|
: node(node_t::stmt_foreach, loc), value_expr(std::move(element)), array_expr(std::move(container)),
|
||||||
stmt(std::move(stmt)), use_key(false) {}
|
stmt(std::move(stmt)), use_key(false), key_expr(nullptr), array(nullptr), pre_expr(nullptr),
|
||||||
|
cond_expr(nullptr), post_expr(nullptr), stmt0(nullptr), ctx(nullptr), ctx_post(nullptr) {}
|
||||||
|
|
||||||
node_stmt_foreach(const location& loc, expr_ptr key, expr_ptr element, expr_ptr container, stmt_ptr stmt)
|
node_stmt_foreach(const location& loc, expr_ptr key, expr_ptr element, expr_ptr container, stmt_ptr stmt)
|
||||||
: node(node_t::stmt_foreach, loc), key_expr(std::move(key)), value_expr(std::move(element)), array_expr(std::move(container)),
|
: node(node_t::stmt_foreach, loc), key_expr(std::move(key)), value_expr(std::move(element)), array_expr(std::move(container)),
|
||||||
stmt(std::move(stmt)), use_key(true) {}
|
stmt(std::move(stmt)), use_key(true), array(nullptr), pre_expr(nullptr), cond_expr(nullptr),
|
||||||
|
post_expr(nullptr), stmt0(nullptr), ctx(nullptr), ctx_post(nullptr) {}
|
||||||
|
|
||||||
auto print() -> std::string override
|
auto print() -> std::string override
|
||||||
{
|
{
|
||||||
@ -2133,10 +2131,10 @@ struct node_stmt_switch : public node
|
|||||||
context_ptr ctx;
|
context_ptr ctx;
|
||||||
|
|
||||||
node_stmt_switch(expr_ptr expr, stmt_list_ptr stmt)
|
node_stmt_switch(expr_ptr expr, stmt_list_ptr stmt)
|
||||||
: node(node_t::stmt_switch), expr(std::move(expr)), stmt(std::move(stmt)) {}
|
: node(node_t::stmt_switch), expr(std::move(expr)), stmt(std::move(stmt)), ctx(nullptr) {}
|
||||||
|
|
||||||
node_stmt_switch(const location& loc, expr_ptr expr, stmt_list_ptr stmt)
|
node_stmt_switch(const location& loc, expr_ptr expr, stmt_list_ptr stmt)
|
||||||
: node(node_t::stmt_switch, loc), expr(std::move(expr)), stmt(std::move(stmt)) {}
|
: node(node_t::stmt_switch, loc), expr(std::move(expr)), stmt(std::move(stmt)), ctx(nullptr) {}
|
||||||
|
|
||||||
auto print() -> std::string override
|
auto print() -> std::string override
|
||||||
{
|
{
|
||||||
@ -2156,17 +2154,17 @@ struct node_stmt_case : public node
|
|||||||
context_ptr ctx;
|
context_ptr ctx;
|
||||||
|
|
||||||
node_stmt_case(expr_ptr value)
|
node_stmt_case(expr_ptr value)
|
||||||
: node(node_t::stmt_case), value(std::move(value)) {}
|
: node(node_t::stmt_case), value(std::move(value)), stmt(nullptr), ctx(nullptr) {}
|
||||||
|
|
||||||
node_stmt_case(const location& loc, expr_ptr value)
|
node_stmt_case(const location& loc, expr_ptr value)
|
||||||
: node(node_t::stmt_case, loc), value(std::move(value)) {}
|
: node(node_t::stmt_case, loc), value(std::move(value)), stmt(nullptr), ctx(nullptr) {}
|
||||||
|
|
||||||
node_stmt_case(const location& loc, expr_ptr value, stmt_list_ptr stmt)
|
node_stmt_case(const location& loc, expr_ptr value, stmt_list_ptr stmt)
|
||||||
: node(node_t::stmt_case, loc), value(std::move(value)), stmt(std::move(stmt)) {}
|
: node(node_t::stmt_case, loc), value(std::move(value)), stmt(std::move(stmt)), ctx(nullptr) {}
|
||||||
|
|
||||||
auto print() -> std::string override
|
auto print() -> std::string override
|
||||||
{
|
{
|
||||||
if(stmt->stmts.size() == 0)
|
if(stmt != nullptr && stmt->stmts.size() == 0)
|
||||||
return "case " + value.as_node->print() + ":";
|
return "case " + value.as_node->print() + ":";
|
||||||
else
|
else
|
||||||
return "case " + value.as_node->print() + ":\n" + stmt->print();
|
return "case " + value.as_node->print() + ":\n" + stmt->print();
|
||||||
@ -2179,17 +2177,17 @@ struct node_stmt_default : public node
|
|||||||
context_ptr ctx;
|
context_ptr ctx;
|
||||||
|
|
||||||
node_stmt_default()
|
node_stmt_default()
|
||||||
: node(node_t::stmt_default) {}
|
: node(node_t::stmt_default), stmt(nullptr), ctx(nullptr) {}
|
||||||
|
|
||||||
node_stmt_default(const location& loc)
|
node_stmt_default(const location& loc)
|
||||||
: node(node_t::stmt_default, loc) {}
|
: node(node_t::stmt_default, loc), stmt(nullptr), ctx(nullptr) {}
|
||||||
|
|
||||||
node_stmt_default(const location& loc, stmt_list_ptr stmt)
|
node_stmt_default(const location& loc, stmt_list_ptr stmt)
|
||||||
: node(node_t::stmt_default, loc), stmt(std::move(stmt)) {}
|
: node(node_t::stmt_default, loc), stmt(std::move(stmt)), ctx(nullptr) {}
|
||||||
|
|
||||||
auto print() -> std::string override
|
auto print() -> std::string override
|
||||||
{
|
{
|
||||||
if(stmt->stmts.size() == 0)
|
if(stmt != nullptr && stmt->stmts.size() == 0)
|
||||||
return "default:";
|
return "default:";
|
||||||
else
|
else
|
||||||
return "default:\n" + stmt->print();
|
return "default:\n" + stmt->print();
|
||||||
|
@ -5,65 +5,176 @@
|
|||||||
|
|
||||||
#include "stdafx.hpp"
|
#include "stdafx.hpp"
|
||||||
|
|
||||||
namespace xsk
|
namespace xsk::gsc
|
||||||
{
|
{
|
||||||
|
|
||||||
std::uint32_t gsc::node::indent_;
|
std::uint32_t node::indent_;
|
||||||
|
|
||||||
bool gsc::expr_ptr::operator==(const gsc::expr_ptr& rhs) const
|
expr_call_type_ptr::~expr_call_type_ptr()
|
||||||
{
|
{
|
||||||
if(as_node->type != rhs.as_node->type)
|
if (as_node == nullptr) return;
|
||||||
return false;
|
|
||||||
|
|
||||||
switch(as_node->type)
|
switch (as_node->type)
|
||||||
{
|
{
|
||||||
case gsc::node_t::data_true:
|
case node_t::null: as_node.~node_ptr(); break;
|
||||||
return *as_true == *rhs.as_true;
|
case node_t::expr_call_pointer: as_pointer.~expr_call_pointer_ptr(); break;
|
||||||
case gsc::node_t::data_false:
|
case node_t::expr_call_function: as_func.~expr_call_function_ptr(); break;
|
||||||
return *as_false == *rhs.as_false;
|
default: break;
|
||||||
case gsc::node_t::data_integer:
|
|
||||||
return *as_integer == *rhs.as_integer;
|
|
||||||
case gsc::node_t::data_float:
|
|
||||||
return *as_float == *rhs.as_float;
|
|
||||||
case gsc::node_t::data_vector:
|
|
||||||
return *as_vector == *rhs.as_vector;
|
|
||||||
case gsc::node_t::data_string:
|
|
||||||
return *as_string == *rhs.as_string;
|
|
||||||
case gsc::node_t::data_istring:
|
|
||||||
return *as_istring == *rhs.as_istring;
|
|
||||||
case gsc::node_t::data_file:
|
|
||||||
return *as_file == *rhs.as_file;
|
|
||||||
case gsc::node_t::data_name:
|
|
||||||
return *as_name == *rhs.as_name;
|
|
||||||
case gsc::node_t::data_animtree:
|
|
||||||
return *as_animtree == *rhs.as_animtree;
|
|
||||||
case gsc::node_t::data_animation:
|
|
||||||
return *as_animation == *rhs.as_animation;
|
|
||||||
case gsc::node_t::data_level:
|
|
||||||
return *as_level == *rhs.as_level;
|
|
||||||
case gsc::node_t::data_anim:
|
|
||||||
return *as_anim == *rhs.as_anim;
|
|
||||||
case gsc::node_t::data_self:
|
|
||||||
return *as_self == *rhs.as_self;
|
|
||||||
case gsc::node_t::data_game:
|
|
||||||
return *as_game == *rhs.as_game;
|
|
||||||
case gsc::node_t::data_undefined:
|
|
||||||
return *as_undefined == *rhs.as_undefined;
|
|
||||||
case gsc::node_t::data_empty_array:
|
|
||||||
return *as_empty_array == *rhs.as_empty_array;
|
|
||||||
case gsc::node_t::data_thisthread:
|
|
||||||
return *as_thisthread == *rhs.as_thisthread;
|
|
||||||
case gsc::node_t::expr_paren:
|
|
||||||
return *as_paren == *rhs.as_paren;
|
|
||||||
case gsc::node_t::expr_size:
|
|
||||||
return *as_size == *rhs.as_size;
|
|
||||||
case gsc::node_t::expr_field:
|
|
||||||
return *as_field == *rhs.as_field;
|
|
||||||
case gsc::node_t::expr_array:
|
|
||||||
return *as_array == *rhs.as_array;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xsk
|
expr_ptr::~expr_ptr()
|
||||||
|
{
|
||||||
|
if (as_node == nullptr) return;
|
||||||
|
|
||||||
|
switch (as_node->type)
|
||||||
|
{
|
||||||
|
case node_t::null: as_node.~node_ptr(); break;
|
||||||
|
case node_t::data_true: as_true.~true_ptr(); break;
|
||||||
|
case node_t::data_false: as_false.~false_ptr(); break;
|
||||||
|
case node_t::data_integer: as_integer.~integer_ptr(); break;
|
||||||
|
case node_t::data_float: as_float.~float_ptr(); break;
|
||||||
|
case node_t::data_vector: as_vector.~vector_ptr(); break;
|
||||||
|
case node_t::data_string: as_string.~string_ptr(); break;
|
||||||
|
case node_t::data_istring: as_istring.~istring_ptr(); break;
|
||||||
|
case node_t::data_file: as_file.~file_ptr(); break;
|
||||||
|
case node_t::data_name: as_name.~name_ptr(); break;
|
||||||
|
case node_t::data_animtree: as_animtree.~animtree_ptr(); break;
|
||||||
|
case node_t::data_animation: as_animation.~animation_ptr(); break;
|
||||||
|
case node_t::data_level: as_level.~level_ptr(); break;
|
||||||
|
case node_t::data_anim: as_anim.~anim_ptr(); break;
|
||||||
|
case node_t::data_self: as_self.~self_ptr(); break;
|
||||||
|
case node_t::data_game: as_game.~game_ptr(); break;
|
||||||
|
case node_t::data_undefined: as_undefined.~undefined_ptr(); break;
|
||||||
|
case node_t::data_empty_array: as_empty_array.~empty_array_ptr(); break;
|
||||||
|
case node_t::data_thisthread: as_thisthread.~thisthread_ptr(); break;
|
||||||
|
case node_t::expr_paren: as_paren.~expr_paren_ptr(); break;
|
||||||
|
case node_t::expr_size: as_size.~expr_size_ptr(); break;
|
||||||
|
case node_t::expr_field: as_field.~expr_field_ptr(); break;
|
||||||
|
case node_t::expr_array: as_array.~expr_array_ptr(); break;
|
||||||
|
case node_t::expr_add_array: as_add_array.~expr_add_array_ptr(); break;
|
||||||
|
case node_t::expr_function: as_function.~expr_function_ptr(); break;
|
||||||
|
case node_t::expr_arguments: as_arguments.~expr_arguments_ptr(); break;
|
||||||
|
case node_t::expr_call_pointer: as_call_pointer.~expr_call_pointer_ptr(); break;
|
||||||
|
case node_t::expr_call_function: as_call_function.~expr_call_function_ptr(); break;
|
||||||
|
case node_t::expr_call: as_call.~expr_call_ptr(); break;
|
||||||
|
case node_t::expr_complement: as_complement.~expr_complement_ptr(); break;
|
||||||
|
case node_t::expr_not: as_not.~expr_not_ptr(); break;
|
||||||
|
case node_t::expr_add: as_add.~expr_add_ptr(); break;
|
||||||
|
case node_t::expr_sub: as_sub.~expr_sub_ptr(); break;
|
||||||
|
case node_t::expr_mult: as_mult.~expr_mult_ptr(); break;
|
||||||
|
case node_t::expr_div: as_div.~expr_div_ptr(); break;
|
||||||
|
case node_t::expr_mod: as_mod.~expr_mod_ptr(); break;
|
||||||
|
case node_t::expr_shift_left: as_shift_left.~expr_shift_left_ptr(); break;
|
||||||
|
case node_t::expr_shift_right: as_shift_right.~expr_shift_right_ptr(); break;
|
||||||
|
case node_t::expr_bitwise_or: as_bitwise_or.~expr_bitwise_or_ptr(); break;
|
||||||
|
case node_t::expr_bitwise_and: as_bitwise_and.~expr_bitwise_and_ptr(); break;
|
||||||
|
case node_t::expr_bitwise_exor: as_bitwise_exor.~expr_bitwise_exor_ptr(); break;
|
||||||
|
case node_t::expr_equality: as_equality.~expr_equality_ptr(); break;
|
||||||
|
case node_t::expr_inequality: as_inequality.~expr_inequality_ptr(); break;
|
||||||
|
case node_t::expr_less_equal: as_less_equal.~expr_less_equal_ptr(); break;
|
||||||
|
case node_t::expr_greater_equal: as_greater_equal.~expr_greater_equal_ptr(); break;
|
||||||
|
case node_t::expr_less: as_less.~expr_less_ptr(); break;
|
||||||
|
case node_t::expr_greater: as_greater.~expr_greater_ptr(); break;
|
||||||
|
case node_t::expr_or: as_or.~expr_or_ptr(); break;
|
||||||
|
case node_t::expr_and: as_and.~expr_and_ptr(); break;
|
||||||
|
case node_t::expr_ternary: as_ternary.~expr_ternary_ptr(); break;
|
||||||
|
case node_t::expr_assign_equal: as_assign_equal.~expr_assign_equal_ptr(); break;
|
||||||
|
case node_t::expr_assign_add: as_assign_add.~expr_assign_add_ptr(); break;
|
||||||
|
case node_t::expr_assign_sub: as_assign_sub.~expr_assign_sub_ptr(); break;
|
||||||
|
case node_t::expr_assign_mult: as_assign_mult.~expr_assign_mult_ptr(); break;
|
||||||
|
case node_t::expr_assign_div: as_assign_div.~expr_assign_div_ptr(); break;
|
||||||
|
case node_t::expr_assign_mod: as_assign_mod.~expr_assign_mod_ptr(); break;
|
||||||
|
case node_t::expr_assign_shift_left: as_assign_shift_left.~expr_assign_shift_left_ptr(); break;
|
||||||
|
case node_t::expr_assign_shift_right: as_assign_shift_right.~expr_assign_shift_right_ptr(); break;
|
||||||
|
case node_t::expr_assign_bitwise_or: as_assign_bw_or.~expr_assign_bitwise_or_ptr(); break;
|
||||||
|
case node_t::expr_assign_bitwise_and: as_assign_bw_and.~expr_assign_bitwise_and_ptr(); break;
|
||||||
|
case node_t::expr_assign_bitwise_exor: as_assign_bw_xor.~expr_assign_bitwise_exor_ptr(); break;
|
||||||
|
case node_t::expr_increment: as_increment.~expr_increment_ptr(); break;
|
||||||
|
case node_t::expr_decrement: as_decrement.~expr_decrement_ptr(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt_ptr::~stmt_ptr()
|
||||||
|
{
|
||||||
|
if (as_node == nullptr) return;
|
||||||
|
|
||||||
|
switch (as_node->type)
|
||||||
|
{
|
||||||
|
case node_t::null: as_node.~node_ptr(); break;
|
||||||
|
case node_t::stmt_list: as_list.~stmt_list_ptr(); break;
|
||||||
|
case node_t::stmt_call: as_call.~stmt_call_ptr(); break;
|
||||||
|
case node_t::stmt_assign: as_assign.~stmt_assign_ptr(); break;
|
||||||
|
case node_t::stmt_endon: as_endon.~stmt_endon_ptr(); break;
|
||||||
|
case node_t::stmt_notify: as_notify.~stmt_notify_ptr(); break;
|
||||||
|
case node_t::stmt_wait: as_wait.~stmt_wait_ptr(); break;
|
||||||
|
case node_t::stmt_waittill: as_waittill.~stmt_waittill_ptr(); break;
|
||||||
|
case node_t::stmt_waittillmatch: as_waittillmatch.~stmt_waittillmatch_ptr(); break;
|
||||||
|
case node_t::stmt_waittillframeend: as_waittillframeend.~stmt_waittillframeend_ptr(); break;
|
||||||
|
case node_t::stmt_waitframe: as_waitframe.~stmt_waitframe_ptr(); break;
|
||||||
|
case node_t::stmt_if: as_if.~stmt_if_ptr(); break;
|
||||||
|
case node_t::stmt_ifelse: as_ifelse.~stmt_ifelse_ptr(); break;
|
||||||
|
case node_t::stmt_while: as_while.~stmt_while_ptr(); break;
|
||||||
|
case node_t::stmt_for: as_for.~stmt_for_ptr(); break;
|
||||||
|
case node_t::stmt_foreach: as_foreach.~stmt_foreach_ptr(); break;
|
||||||
|
case node_t::stmt_switch: as_switch.~stmt_switch_ptr(); break;
|
||||||
|
case node_t::stmt_case: as_case.~stmt_case_ptr(); break;
|
||||||
|
case node_t::stmt_default: as_default.~stmt_default_ptr(); break;
|
||||||
|
case node_t::stmt_break: as_break.~stmt_break_ptr(); break;
|
||||||
|
case node_t::stmt_continue: as_continue.~stmt_continue_ptr(); break;
|
||||||
|
case node_t::stmt_return: as_return.~stmt_return_ptr(); break;
|
||||||
|
case node_t::stmt_breakpoint: as_breakpoint.~stmt_breakpoint_ptr(); break;
|
||||||
|
case node_t::stmt_prof_begin: as_prof_begin.~stmt_prof_begin_ptr(); break;
|
||||||
|
case node_t::stmt_prof_end: as_prof_end.~stmt_prof_end_ptr(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_ptr::~define_ptr()
|
||||||
|
{
|
||||||
|
if (as_node == nullptr) return;
|
||||||
|
|
||||||
|
switch(as_node->type)
|
||||||
|
{
|
||||||
|
case node_t::null: as_node.~node_ptr(); break;
|
||||||
|
case node_t::thread: as_thread.~thread_ptr(); break;
|
||||||
|
case node_t::constant: as_constant.~constant_ptr(); break;
|
||||||
|
case node_t::usingtree: as_usingtree.~usingtree_ptr(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool expr_ptr::operator==(const expr_ptr& rhs) const
|
||||||
|
{
|
||||||
|
if(as_node->type != rhs.as_node->type) return false;
|
||||||
|
|
||||||
|
switch(as_node->type)
|
||||||
|
{
|
||||||
|
case node_t::data_true: return *as_true == *rhs.as_true;
|
||||||
|
case node_t::data_false: return *as_false == *rhs.as_false;
|
||||||
|
case node_t::data_integer: return *as_integer == *rhs.as_integer;
|
||||||
|
case node_t::data_float: return *as_float == *rhs.as_float;
|
||||||
|
case node_t::data_vector: return *as_vector == *rhs.as_vector;
|
||||||
|
case node_t::data_string: return *as_string == *rhs.as_string;
|
||||||
|
case node_t::data_istring: return *as_istring == *rhs.as_istring;
|
||||||
|
case node_t::data_file: return *as_file == *rhs.as_file;
|
||||||
|
case node_t::data_name: return *as_name == *rhs.as_name;
|
||||||
|
case node_t::data_animtree: return *as_animtree == *rhs.as_animtree;
|
||||||
|
case node_t::data_animation: return *as_animation == *rhs.as_animation;
|
||||||
|
case node_t::data_level: return *as_level == *rhs.as_level;
|
||||||
|
case node_t::data_anim: return *as_anim == *rhs.as_anim;
|
||||||
|
case node_t::data_self: return *as_self == *rhs.as_self;
|
||||||
|
case node_t::data_game: return *as_game == *rhs.as_game;
|
||||||
|
case node_t::data_undefined: return *as_undefined == *rhs.as_undefined;
|
||||||
|
case node_t::data_empty_array: return *as_empty_array == *rhs.as_empty_array;
|
||||||
|
case node_t::data_thisthread: return *as_thisthread == *rhs.as_thisthread;
|
||||||
|
case node_t::expr_paren: return *as_paren == *rhs.as_paren;
|
||||||
|
case node_t::expr_size: return *as_size == *rhs.as_size;
|
||||||
|
case node_t::expr_field: return *as_field == *rhs.as_field;
|
||||||
|
case node_t::expr_array: return *as_array == *rhs.as_array;
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace xsk::gsc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user