Skip to content

Commit

Permalink
Start sketching out QAST::Var; not enough to do anything useful yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Apr 28, 2012
1 parent c0b439f commit 16319cd
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/QAST/Compiler.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 16319cd

Please sign in to comment.