Permalink
Browse files

Start sketching out QAST::Var; not enough to do anything useful yet.

  • Loading branch information...
1 parent c0b439f commit 16319cd74eda03931c633e5990f6941bdacac8cc @jnthn jnthn committed Apr 28, 2012
Showing with 31 additions and 0 deletions.
  1. +31 −0 src/QAST/Compiler.nqp
View
@@ -147,6 +147,37 @@ class QAST::Compiler is HLL::Compiler {
QAST::Operations.compile_op(self, '', $node)
}
+ multi method as_post(QAST::Var $node) {
+ my $scope := $node.scope;
+ my $decl := $node.decl;
+
+ # Handle any declarations; after this, we call through to the
+ # lookup code.
+ if $decl {
+ # If it's a parameter, add it to the things we should bind
+ # at block entry.
+ if $node.decl eq 'param' {
+ $*BLOCK.add_param($node);
+ }
+ elsif $decl ne 'var' {
+ pir::die("Don't understand declaration type '$decl'");
+ }
+
+ # Register storage.
+ if $scope eq 'local' {
+ $*BLOCK.add_local($node);
+ }
+ elsif $scope eq 'lexical' {
+ $*BLOCK.add_lexical($node);
+ }
+ else {
+ pir::die("Cannot declare $decl of scope '$scope'; use 'local' or 'lexical'");
+ }
+ }
+
+ pir::die("QAST::Var NYI");
+ }
+
multi method as_post(QAST::IVal $node) {
self.post_new('Ops', :result(~$node.value))
}

0 comments on commit 16319cd

Please sign in to comment.