jak2: add current-time macro for process clocks (#2662)

Closes #1872

---------

Co-authored-by: ManDude <7569514+ManDude@users.noreply.github.com>
This commit is contained in:
Hat Kid
2023-05-18 22:33:46 +02:00
committed by GitHub
parent 0fcd9da639
commit 8d28bb3480
535 changed files with 26686 additions and 28650 deletions
+20
View File
@@ -3876,6 +3876,19 @@ ConstantTokenElement* DerefElement::try_as_art_const(const Env& env, FormPool& p
return nullptr;
}
GenericElement* DerefElement::try_as_curtime(FormPool& pool) {
auto mr = match(Matcher::deref(Matcher::s6(), false,
{DerefTokenMatcher::string("clock"),
DerefTokenMatcher::string("frame-counter")}),
this);
if (mr.matched) {
return pool.alloc_element<GenericElement>(
GenericOperator::make_function(pool.form<ConstantTokenElement>("current-time")));
}
return nullptr;
}
void DerefElement::update_from_stack(const Env& env,
FormPool& pool,
FormStack& stack,
@@ -3911,6 +3924,13 @@ void DerefElement::update_from_stack(const Env& env,
env.dts->ts.try_enum_lookup("game-task-node"), pool, env, m_tokens.at(1).int_constant()));
}
// current-time macro
auto as_curtime = try_as_curtime(pool);
if (as_curtime) {
result->push_back(as_curtime);
return;
}
result->push_back(this);
}