[jak2] script-eval macro (#2315)

turns
```lisp
      (eval! (new 'stack 'script-context (process->ppointer self) self (the-as vector #f)) '(teleport))
      (eval! (new 'stack 'script-context (process->ppointer self) self (the-as vector #f)) (-> arg0 on-goto))
```
into
```lisp
      (script-eval '(teleport))
      (script-eval (-> arg0 on-goto))
```
This commit is contained in:
ManDude
2023-03-11 15:45:16 +00:00
committed by GitHub
parent 70452a753f
commit 77242bd12e
98 changed files with 2400 additions and 2707 deletions
+25
View File
@@ -123,6 +123,13 @@ Matcher Matcher::any_symbol(int match_id) {
return m;
}
Matcher Matcher::quoted_symbol(const std::string& name) {
Matcher m;
m.m_kind = Kind::QUOTED_SYMBOL;
m.m_str = name;
return m;
}
Matcher Matcher::symbol(const std::string& name) {
Matcher m;
m.m_kind = Kind::SYMBOL;
@@ -463,6 +470,24 @@ bool Matcher::do_match(Form* input, MatchResult::Maps* maps_out) const {
return false;
}
case Kind::QUOTED_SYMBOL: {
auto as_simple_atom = dynamic_cast<SimpleAtomElement*>(input->try_as_single_active_element());
if (as_simple_atom) {
if (as_simple_atom->atom().is_sym_ptr()) {
return as_simple_atom->atom().get_str() == m_str;
}
}
auto as_expr = dynamic_cast<SimpleExpressionElement*>(input->try_as_single_active_element());
if (as_expr && as_expr->expr().is_identity()) {
const auto& atom = as_expr->expr().get_arg(0);
if (atom.is_sym_ptr()) {
return atom.get_str() == m_str;
}
}
return false;
}
case Kind::SYMBOL: {
auto as_simple_atom = dynamic_cast<SimpleAtomElement*>(input->try_as_single_active_element());
if (as_simple_atom) {