Skip to content
This repository
Browse code

Sort out compile time value handling, so Rakudo can do it without usi…

…ng annotations.
  • Loading branch information...
commit 26a8bc14ed1b68c900e44649103d860d93f32e58 1 parent ffe1cba
Jonathan Worthington jnthn authored
15 src/QAST/CompileTimeValue.nqp
... ... @@ -1,5 +1,16 @@
1 1 # Composed or mixed in to any node that also has a compile-time known value.
2 2 role QAST::CompileTimeValue {
3   - has $!value;
4   - method value(*@value) { $!value := @value[0] if @value; $!value }
  3 + has $!compile_time_value;
  4 +
  5 + method has_compile_time_value() {
  6 + 1
  7 + }
  8 +
  9 + method compile_time_value() {
  10 + $!compile_time_value
  11 + }
  12 +
  13 + method set_compile_time_value($value) {
  14 + $!compile_time_value := $value
  15 + }
5 16 }
9 src/QAST/Node.nqp
@@ -50,6 +50,15 @@ class QAST::Node {
50 50 }
51 51 }
52 52
  53 + method has_compile_time_value() {
  54 + 0
  55 + }
  56 +
  57 + method set_compile_time_value($value) {
  58 + self.HOW.mixin(self, QAST::CompileTimeValue);
  59 + self.set_compile_time_value($value);
  60 + }
  61 +
53 62 method list() { @!array }
54 63 method pop() { nqp::pop(self.list) }
55 64 method push($value) { nqp::push(self.list, $value) }
5 src/QAST/WVal.nqp
... ... @@ -1,2 +1,7 @@
1 1 class QAST::WVal is QAST::Node does QAST::CompileTimeValue {
  2 + method value(*@value) {
  3 + @value
  4 + ?? self.set_compile_time_value(@value[0])
  5 + !! self.compile_time_value()
  6 + }
2 7 }
9 src/QAST/Want.nqp
... ... @@ -1,2 +1,11 @@
1 1 class QAST::Want is QAST::Node {
  2 + method has_compile_time_value() {
  3 + nqp::istype(self[0], QAST::Node)
  4 + ?? self[0].has_compile_time_value()
  5 + !! 0
  6 + }
  7 +
  8 + method compile_time_value() {
  9 + self[0].compile_time_value()
  10 + }
2 11 }

0 comments on commit 26a8bc1

Please sign in to comment.
Something went wrong with that request. Please try again.