Skip to content

Support time-related primitives #166

@j-hui

Description

@j-hui

We should be able to query the current time and time a scheduled variable was last-updated. In fact, ssm-runtime already supports this, and codegen even has bindings for it. I tried hacking this in with 072fb9a (for now and last, whose syntax is prefix @@) and 152d994 (adding in Time as an alias for U64).

But there are several problems, leading me to remove these features from the scanner in 11752b8:

  • Timestamps cause mad leaks. This is because they are 64-bit values and are stored on the heap. Reading them causes allocation, and for some reason they aren't being cleaned up properly.
  • We can't do any kind of arithmetic or comparisons with time. Arithmetic operators like +, -, <, and == are hard-coded as I32 -> I32 -> I32. To support time arithmetic, we would need them to be aware of U64 somehow. This involves type classes or some other kind of overloading, which we're not ready for. We would also need to do codegen for them differently because we would need to read the value out of the heap using ssm_time_read() rather than ssm_unmarshal().
  • We can't even "read" the time. An easy hack out of the above issue is to add primitives to read the lower and upper 32 bits out of the 64-bit timestamp, using ssm_time_read(), but we would need syntax for this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions