mirror of
https://github.com/open-goal/jak-project
synced 2026-07-12 07:38:53 -04:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user