Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Translate PAST::Stmt/PAST::Stmts to QAST::Stmt/QAST::Stmts.
  • Loading branch information
jnthn committed Aug 1, 2012
1 parent ae3c767 commit 077f198
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
30 changes: 15 additions & 15 deletions src/NQPQ/Actions.pm
Expand Up @@ -6,8 +6,8 @@ class NQP::Actions is HLL::Actions {

sub block_immediate($block) {
$block.blocktype('immediate');
unless $block.symtable() || $block.handlers() {
my $stmts := PAST::Stmts.new( :node($block) );
unless $block.symtable() {
my $stmts := QAST::Stmts.new( :node($block) );
for $block.list { $stmts.push($_); }
$block := $stmts;
}
Expand Down Expand Up @@ -69,7 +69,7 @@ class NQP::Actions is HLL::Actions {
# mainline.
$unit.unshift(PAST::Var.new( :scope('parameter'), :name('@ARGS'), :slurpy(1),
:directaccess(1) ));
my $main_tasks := PAST::Stmts.new(
my $main_tasks := QAST::Stmts.new(
PAST::Op.new( :pirop('load_bytecode vs'), 'ModuleLoader.pbc' ),
PAST::Op.new(
:pasttype('callmethod'), :name('set_mainline_module'),
Expand Down Expand Up @@ -113,13 +113,13 @@ class NQP::Actions is HLL::Actions {
}

method statementlist($/) {
my $past := PAST::Stmts.new( :node($/) );
my $past := QAST::Stmts.new( :node($/) );
if $<statement> {
for $<statement> {
my $ast := $_.ast;
$ast := $ast<sink> if nqp::defined($ast<sink>);
if $ast<bareblock> { $ast := block_immediate($ast); }
$ast := PAST::Stmt.new($ast) if $ast ~~ PAST::Node;
$ast := QAST::Stmt.new($ast) if nqp::istype($ast, QAST::Node);
$past.push( $ast );
}
}
Expand Down Expand Up @@ -246,7 +246,7 @@ class NQP::Actions is HLL::Actions {
if nqp::defined($module) {
import_HOW_exports($module);
}
make PAST::Stmts.new();
make QAST::Stmts.new();
}

method statement_control:sym<if>($/) {
Expand Down Expand Up @@ -308,14 +308,14 @@ class NQP::Actions is HLL::Actions {
my $block := $<block>.ast;
push_block_handler($/, $block);
$*W.cur_lexpad().handlers()[0].handle_types_except('CONTROL');
make PAST::Stmts.new(:node($/));
make QAST::Stmts.new(:node($/));
}

method statement_control:sym<CONTROL>($/) {
my $block := $<block>.ast;
push_block_handler($/, $block);
$*W.cur_lexpad().handlers()[0].handle_types('CONTROL');
make PAST::Stmts.new(:node($/));
make QAST::Stmts.new(:node($/));
}

sub push_block_handler($/, $block) {
Expand All @@ -339,7 +339,7 @@ class NQP::Actions is HLL::Actions {
$BLOCK.handlers.unshift(
PAST::Control.new(
:node($/),
PAST::Stmts.new(
QAST::Stmts.new(
PAST::Op.new( :pasttype('call'),
$block,
PAST::Var.new( :scope('register'), :name('exception')),
Expand All @@ -362,7 +362,7 @@ class NQP::Actions is HLL::Actions {

method statement_prefix:sym<INIT>($/) {
$*W.cur_lexpad().push($<blorst>.ast);
make PAST::Stmts.new();
make QAST::Stmts.new();
}

method statement_prefix:sym<try>($/) {
Expand All @@ -373,7 +373,7 @@ class NQP::Actions is HLL::Actions {
unless $past.handlers() {
$past.handlers([PAST::Control.new(
:handle_types_except('CONTROL'),
PAST::Stmts.new(
QAST::Stmts.new(
PAST::Op.new( :pasttype('bind_6model'),
PAST::Var.new( :scope('keyed'),
PAST::Var.new( :scope('register'), :name('exception')),
Expand Down Expand Up @@ -534,7 +534,7 @@ class NQP::Actions is HLL::Actions {
$/.CURSOR.panic("$*SCOPE scoped packages are not supported");
}

make PAST::Stmts.new();
make QAST::Stmts.new();
}

method package_def($/) {
Expand Down Expand Up @@ -660,7 +660,7 @@ class NQP::Actions is HLL::Actions {
$*W.pkg_add_attribute($*PACKAGE, %*HOW{$*PKGDECL ~ '-attr'},
%lit_args, %obj_args);

$past := PAST::Stmts.new();
$past := QAST::Stmts.new();
}
elsif $*SCOPE eq 'our' {
# Depending on if this was already considered our scoped,
Expand Down Expand Up @@ -1052,7 +1052,7 @@ class NQP::Actions is HLL::Actions {
my $past;
if $<proto> {
$past :=
PAST::Stmts.new(
QAST::Stmts.new(
PAST::Block.new( :name($name),
PAST::Op.new(
PAST::Var.new( :name('self'), :scope('parameter') ),
Expand Down Expand Up @@ -1469,7 +1469,7 @@ class NQP::RegexActions is QRegex::P6Regex::Actions {
my $block := $<block>.ast;
$block.blocktype('immediate');
my $past :=
PAST::Stmts.new(
QAST::Stmts.new(
PAST::Op.new(
PAST::Var.new( :name('$/') ),
PAST::Op.new(
Expand Down
31 changes: 16 additions & 15 deletions src/NQPQ/World.pm
@@ -1,4 +1,5 @@
use NQPP6QRegex;
use QAST;

class NQP::World is HLL::World {
# The stack of lexical pads, actually as PAST::Block objects. The
Expand All @@ -11,7 +12,7 @@ class NQP::World is HLL::World {
# to a list of code objects.
has %!code_objects_to_fix_up;

# Mapping of PAST::Stmts node containing fixups, keyed by sub ID. If
# Mapping of QAST::Stmts node containing fixups, keyed by sub ID. If
# we do dynamic compilation then we do the fixups immediately and
# then clear this list.
has %!code_object_fixup_list;
Expand All @@ -22,7 +23,7 @@ class NQP::World is HLL::World {
# Creates a new lexical scope and puts it on top of the stack.
method push_lexpad($/) {
# Create pad, link to outer and add to stack.
my $pad := PAST::Block.new( PAST::Stmts.new(), :node($/) );
my $pad := PAST::Block.new( QAST::Stmts.new(), :node($/) );
if +@!BLOCKS {
$pad<outer> := @!BLOCKS[+@!BLOCKS - 1];
}
Expand Down Expand Up @@ -65,7 +66,7 @@ class NQP::World is HLL::World {

# Do load for pre-compiled situation.
if self.is_precompilation_mode() {
self.add_load_dependency_task(:deserialize_past(PAST::Stmts.new(
self.add_load_dependency_task(:deserialize_past(QAST::Stmts.new(
PAST::Op.new(
:pirop('load_bytecode vs'), 'ModuleLoader.pbc'
),
Expand Down Expand Up @@ -105,7 +106,7 @@ class NQP::World is HLL::World {

# Make sure we do the loading during deserialization.
if self.is_precompilation_mode() {
self.add_load_dependency_task(:deserialize_past(PAST::Stmts.new(
self.add_load_dependency_task(:deserialize_past(QAST::Stmts.new(
PAST::Op.new(
:pirop('load_bytecode vs'), 'ModuleLoader.pbc'
),
Expand Down Expand Up @@ -144,7 +145,7 @@ class NQP::World is HLL::World {
:directaccess(1) ));

# Fixup and deserialization task is the same.
my $fixup := PAST::Stmts.new(
my $fixup := QAST::Stmts.new(
PAST::Op.new(
:pasttype('callmethod'), :name('set_static_lexpad_value'),
PAST::Val.new( :value($block), :returns('LexInfo')),
Expand Down Expand Up @@ -226,7 +227,7 @@ class NQP::World is HLL::World {
};

# See if we already have our compile-time dummy. If not, create it.
my $fixups := PAST::Stmts.new();
my $fixups := QAST::Stmts.new();
my $dummy;
my $code_ref_idx;
if nqp::defined($past<compile_time_dummy>) {
Expand Down Expand Up @@ -427,7 +428,7 @@ class NQP::World is HLL::World {
method run_begin_block($past) {
# Create a wrapper that makes all outer symbols visible.
my $wrapper := PAST::Block.new(
PAST::Stmts.new(),
QAST::Stmts.new(),
$past
);
my %seen;
Expand Down Expand Up @@ -480,15 +481,15 @@ class NQP::World is HLL::World {
# it doesn't exist, and fix it up if it already does.
method to_past() {
if self.is_precompilation_mode() {
my $load_tasks := PAST::Stmts.new();
my $load_tasks := QAST::Stmts.new();
for self.load_dependency_tasks() {
$load_tasks.push(PAST::Stmt.new($_));
$load_tasks.push(QAST::Stmt.new($_));
}
my $fixup_tasks := PAST::Stmts.new();
my $fixup_tasks := QAST::Stmts.new();
for self.fixup_tasks() {
$fixup_tasks.push(PAST::Stmt.new($_));
$fixup_tasks.push(QAST::Stmt.new($_));
}
return PAST::Stmts.new(
return QAST::Stmts.new(
PAST::Op.new( :pirop('nqp_dynop_setup v') ),
PAST::Op.new( :pirop('nqp_bigint_setup v') ),
PAST::Op.new(
Expand All @@ -513,12 +514,12 @@ class NQP::World is HLL::World {
);
}
else {
my $tasks := PAST::Stmts.new();
my $tasks := QAST::Stmts.new();
for self.load_dependency_tasks() {
$tasks.push(PAST::Stmt.new($_));
$tasks.push(QAST::Stmt.new($_));
}
for self.fixup_tasks() {
$tasks.push(PAST::Stmt.new($_));
$tasks.push(QAST::Stmt.new($_));
}
return $tasks
}
Expand Down

0 comments on commit 077f198

Please sign in to comment.