Replies: 1 comment
-
Issue to track this: #1098 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently an IntegerNode only has
startOffset
andendOffset
.So the only way to get its value is by parsing the Integer from the source between these offsets.
This is easy for
123
but less so for0x123_456
for instance.It'd be convenient if YARP would make it easier to get the integer value of an IntegerNode.
Some ideas:
string
(like for CallNode#name, StringNode#unescaped, etc) or so with the cleaned up number in textual form, so e.g.0x123_456
would be1193046
(so only digits and optional leading-
). If we want to optimize serialized size we could make that optional when the source is already just digits and-
, but not sure this is worth the complexity. Maybe thestring
type could handle either from source or from some bytes in the serialized form?string
. Probably simpler to just have a variable-width binary integer field (and that using a simple and efficient-to-decode encoding of the value). This would likely make it quite a bit more efficient to create the AST from the serialized form.Currently any usage of YARP will need to parse the Integer after deserialization, for instance via
Kernel#Integer(String)
. That works but is less convenient and adds some overhead.For instance even the Ruby
IntegerNode
doesn't have avalue
method or so that would return the value of the literal.cc @andrykonchin as we looked at this today
Beta Was this translation helpful? Give feedback.
All reactions