mirror of
https://github.com/open-goal/jak-project
synced 2026-09-06 03:08:29 -04:00
[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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user