Permalink
Browse files

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

…ng annotations.
  • Loading branch information...
1 parent ffe1cba commit 26a8bc14ed1b68c900e44649103d860d93f32e58 @jnthn jnthn committed Jul 26, 2012
Showing with 36 additions and 2 deletions.
  1. +13 −2 src/QAST/CompileTimeValue.nqp
  2. +9 −0 src/QAST/Node.nqp
  3. +5 −0 src/QAST/WVal.nqp
  4. +9 −0 src/QAST/Want.nqp
@@ -1,5 +1,16 @@
# Composed or mixed in to any node that also has a compile-time known value.
role QAST::CompileTimeValue {
- has $!value;
- method value(*@value) { $!value := @value[0] if @value; $!value }
+ has $!compile_time_value;
+
+ method has_compile_time_value() {
+ 1
+ }
+
+ method compile_time_value() {
+ $!compile_time_value
+ }
+
+ method set_compile_time_value($value) {
+ $!compile_time_value := $value
+ }
}
View
@@ -50,6 +50,15 @@ class QAST::Node {
}
}
+ method has_compile_time_value() {
+ 0
+ }
+
+ method set_compile_time_value($value) {
+ self.HOW.mixin(self, QAST::CompileTimeValue);
+ self.set_compile_time_value($value);
+ }
+
method list() { @!array }
method pop() { nqp::pop(self.list) }
method push($value) { nqp::push(self.list, $value) }
View
@@ -1,2 +1,7 @@
class QAST::WVal is QAST::Node does QAST::CompileTimeValue {
+ method value(*@value) {
+ @value
+ ?? self.set_compile_time_value(@value[0])
+ !! self.compile_time_value()
+ }
}
View
@@ -1,2 +1,11 @@
class QAST::Want is QAST::Node {
+ method has_compile_time_value() {
+ nqp::istype(self[0], QAST::Node)
+ ?? self[0].has_compile_time_value()
+ !! 0
+ }
+
+ method compile_time_value() {
+ self[0].compile_time_value()
+ }
}

0 comments on commit 26a8bc1

Please sign in to comment.