[decompiler] small fixes for methods and more reference tests (#419)

* clean up method stuff, fix a few small bugs, and add references for easy -h files

* more small fixes and reference tests
This commit is contained in:
water111
2021-05-06 00:42:49 -04:00
committed by GitHub
parent 0a6602e320
commit 21fefa0aaa
41 changed files with 3427 additions and 220 deletions
+19
View File
@@ -130,6 +130,13 @@ Matcher Matcher::while_loop(const Matcher& condition, const Matcher& body) {
return m;
}
Matcher Matcher::any_constant_token(int match_id) {
Matcher m;
m.m_kind = Kind::ANY_CONSTANT_TOKEN;
m.m_string_out_id = match_id;
return m;
}
bool Matcher::do_match(Form* input, MatchResult::Maps* maps_out) const {
switch (m_kind) {
case Kind::ANY:
@@ -251,6 +258,18 @@ bool Matcher::do_match(Form* input, MatchResult::Maps* maps_out) const {
return false;
} break;
case Kind::ANY_CONSTANT_TOKEN: {
auto as_ct = input->try_as_element<ConstantTokenElement>();
if (as_ct) {
if (m_string_out_id != -1) {
maps_out->strings[m_string_out_id] = as_ct->value();
}
return true;
} else {
return false;
}
} break;
case Kind::CAST: {
auto as_cast = dynamic_cast<CastElement*>(input->try_as_single_element());
if (as_cast) {