Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
reapply directaccess patches now that we again build against an up-to…
…-date parrot
  • Loading branch information
mlschroe committed Nov 16, 2011
1 parent 2fcf054 commit 86080ba
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 16 deletions.
20 changes: 11 additions & 9 deletions src/NQP/Actions.pm
Expand Up @@ -79,7 +79,8 @@ class NQP::Actions is HLL::Actions {
# register the mainline as a module (so trying to use ourself in the
# program will not explode). If we have a MAIN sub, call it at end of
# mainline.
$unit.unshift(PAST::Var.new( :scope('parameter'), :name('@ARGS'), :slurpy(1) ));
$unit.unshift(PAST::Var.new( :scope('parameter'), :name('@ARGS'), :slurpy(1),
:directaccess(1) ));
my $main_tasks := PAST::Stmts.new(
PAST::Op.new( :pirop('load_bytecode vs'), 'ModuleLoader.pbc' ),
PAST::Op.new(
Expand Down Expand Up @@ -548,7 +549,8 @@ class NQP::Actions is HLL::Actions {
# for parametric types, pass along the role body block.
if pir::can($how, 'parametric') && $how.parametric($how) {
$past.blocktype('declaration');
$past.unshift(PAST::Var.new( :name('$?CLASS'), :scope('parameter') ));
$past.unshift(PAST::Var.new( :name('$?CLASS'), :scope('parameter'),
:directaccess(1) ));
$past.symbol('$?CLASS', :scope('lexical'));
$*SC.pkg_set_body_block($*PACKAGE, $past);
$*SC.install_lexical_symbol($past, '$?PACKAGE', $*PACKAGE);
Expand Down Expand Up @@ -665,7 +667,7 @@ class NQP::Actions is HLL::Actions {
}
else {
$BLOCK[0].push(PAST::Var.new(
:name($name), :scope('lexical'), :isdecl(1),
:name($name), :scope('lexical'), :isdecl(1), :directaccess(1),
:lvalue(1), :viviself( vivitype($sigil) ),
:node($/)
));
Expand Down Expand Up @@ -744,7 +746,7 @@ class NQP::Actions is HLL::Actions {
PAST::Var.new( :name($name), :scope('outer') ),
$cholder
);
@BLOCK[0][0].push(PAST::Var.new( :name($name), :isdecl(1),
@BLOCK[0][0].push(PAST::Var.new( :name($name), :isdecl(1), :directaccess(1),
:viviself($dispatch_setup), :scope('lexical') ) );
@BLOCK[0].symbol($name, :scope('lexical'), :cholder($cholder) );
}
Expand All @@ -761,7 +763,7 @@ class NQP::Actions is HLL::Actions {
# with the proto.
if $*SCOPE eq 'our' { pir::die('our-scoped protos not yet implemented') }
my $cholder := PAST::Op.new( :pasttype('list') );
@BLOCK[0][0].push(PAST::Var.new( :name($name), :isdecl(1),
@BLOCK[0][0].push(PAST::Var.new( :name($name), :isdecl(1), :directaccess(1),
:viviself($past), :scope('lexical') ) );
@BLOCK[0][0].push(PAST::Op.new(
:pirop('set_dispatchees 0PP'),
Expand All @@ -774,7 +776,7 @@ class NQP::Actions is HLL::Actions {
$past.pirflags(':instanceof("DispatcherSub")');
}
else {
@BLOCK[0][0].push(PAST::Var.new( :name($name), :isdecl(1),
@BLOCK[0][0].push(PAST::Var.new( :name($name), :isdecl(1), :directaccess(1),
:viviself($past), :scope('lexical') ) );
@BLOCK[0].symbol($name, :scope('lexical') );
if $*SCOPE eq 'our' {
Expand Down Expand Up @@ -828,7 +830,7 @@ class NQP::Actions is HLL::Actions {
# Always need an invocant.
unless $past<signature_has_invocant> {
$past[0].unshift(PAST::Var.new(
:name('self'), :scope('parameter'),
:name('self'), :scope('parameter'), :directaccess(1),
:multitype($*SC.get_object_sc_ref_past($*PACKAGE))
));
}
Expand Down Expand Up @@ -900,7 +902,7 @@ class NQP::Actions is HLL::Actions {
my $inv := $<invocant>[0].ast;
$BLOCKINIT.push($inv);
$BLOCKINIT.push(PAST::Var.new(
:name('self'), :scope('lexical'), :isdecl(1),
:name('self'), :scope('lexical'), :isdecl(1), :directaccess(1),
:viviself(PAST::Var.new( :scope('lexical'), :name($inv.name) ))
));
@BLOCK[0]<signature_has_invocant> := 1
Expand Down Expand Up @@ -955,7 +957,7 @@ class NQP::Actions is HLL::Actions {
method param_var($/) {
my $name := ~$/;
my $past := PAST::Var.new( :name($name), :scope('parameter'),
:isdecl(1), :node($/) );
:isdecl(1), :directaccess(1), :node($/) );
@BLOCK[0].symbol($name, :scope('lexical') );
make $past;
}
Expand Down
3 changes: 2 additions & 1 deletion src/NQP/SymbolTable.pm
Expand Up @@ -114,7 +114,8 @@ class NQP::SymbolTable is HLL::Compiler::SerializationContextBuilder {
method install_lexical_symbol($block, $name, $obj) {
# Install the object directly as a block symbol.
$block.symbol($name, :scope('lexical'), :value($obj));
$block[0].push(PAST::Var.new( :scope('lexical'), :name($name), :isdecl(1) ));
$block[0].push(PAST::Var.new( :scope('lexical'), :name($name), :isdecl(1),
:directaccess(1) ));

# Fixup and deserialization task is the same.
my $fixup := PAST::Stmts.new(
Expand Down
46 changes: 40 additions & 6 deletions src/PAST/SixModelPASTExtensions.pir
Expand Up @@ -63,8 +63,8 @@ some PAST that will produce it or a name that it can be looked up by.
.sub 'lexical_6model_type' :method
.param pmc node

# See if we have a type. If so, use it to determine what op to use
# and what the register type will be.
# See if we have a type. If so, use it to determine what the
# register type will be.
.local pmc type
.local int primitive_type_id
type = node.'type'()
Expand Down Expand Up @@ -192,11 +192,13 @@ some PAST that will produce it or a name that it can be looked up by.
name = node.'name'()
name = self.'escape'(name)

.local pmc lexregs
lexregs = find_dynamic_lex '%*LEXREGS'

.local int isdecl
isdecl = node.'isdecl'()

.local pmc type
.local string reg_type, fetch_op_name, store_op_name
.local string reg_type
(reg_type) = self.'lexical_6model_type'(node)

lexical_post:
Expand All @@ -207,14 +209,31 @@ some PAST that will produce it or a name that it can be looked up by.
$P0 = get_hll_global ['POST'], 'Ops'
ops = $P0.'new'('node'=>node)
if reg_type == 'P' goto need_vivify
$P1 = self.'uniquereg'(reg_type)
$P1 = self.'tempreg'(reg_type)
ops.'result'($P1)
if null lexregs goto no_lexregs_2
.local string lexreg
lexreg = lexregs[name]
unless lexreg goto no_lexregs_2
$P0 = get_hll_global ['POST'], 'Op'
fetchop = $P0.'new'($P1, lexreg, 'pirop'=>'set')
ops.'push'(fetchop)
.return (ops)
no_lexregs_2:
$P0 = get_hll_global ['POST'], 'Op'
fetchop = $P0.'new'($P1, name, 'pirop'=>'find_lex')
ops.'push'(fetchop)
ops.'result'($P1)
.return (ops)
need_vivify:
$P0 = get_hll_global ['POST'], 'Op'
if null lexregs goto no_lexregs
.local string lexreg
lexreg = lexregs[name]
unless lexreg goto no_lexregs
fetchop = $P0.'new'(ops, lexreg, 'pirop'=>'set')
storeop = $P0.'new'(lexreg, ops, 'pirop'=>'set')
.tailcall self.'vivify'(node, ops, fetchop, storeop)
no_lexregs:
fetchop = $P0.'new'(ops, name, 'pirop'=>'find_lex')
storeop = $P0.'new'(name, ops, 'pirop'=>'store_lex')
.tailcall self.'vivify'(node, ops, fetchop, storeop)
Expand All @@ -235,11 +254,26 @@ some PAST that will produce it or a name that it can be looked up by.
ops.'push_pirop'('set', lexreg, bindpost)
have_lexreg:
ops.'push_pirop'('.lex', name, lexreg)
.local int directaccess
directaccess = node.'directaccess'()
unless directaccess goto no_directaccess
unless null lexregs goto have_lexregs
lexregs = new 'Hash'
store_dynamic_lex '%*LEXREGS', lexregs
have_lexregs:
lexregs[name] = lexreg
no_directaccess:
ops.'result'(lexreg)
.return (ops)

lexical_bind:
$P0 = get_hll_global ['POST'], 'Op'
if null lexregs goto no_lexregs_bind
.local string lexreg
lexreg = lexregs[name]
unless lexreg goto no_lexregs_bind
.tailcall $P0.'new'(lexreg, bindpost, 'pirop'=>'set', 'result'=>bindpost)
no_lexregs_bind:
.tailcall $P0.'new'(name, bindpost, 'pirop'=>'store_lex', 'result'=>bindpost)
.end

Expand Down

0 comments on commit 86080ba

Please sign in to comment.