Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactors to get signatures built in the right lexical scope (e.g. so…
… they find the types in the right lexical scope).
  • Loading branch information
jnthn committed Aug 22, 2010
1 parent 2d77d23 commit 8876bee
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
40 changes: 35 additions & 5 deletions dotnet/compiler/PAST2DNSTCompiler.pm
Expand Up @@ -14,6 +14,7 @@ method compile(PAST::Node $node) {
# Any loadinits we'll need to run, and if we're in one.
my $*IN_LOADINIT;
my @*LOADINITS;
my @*SIGINITS;

# We'll build a static block info array too; this helps us do so.
my $*OUTER_SBI := 0;
Expand Down Expand Up @@ -64,6 +65,9 @@ method compile(PAST::Node $node) {
for @*LOADINITS {
$loadinit_calls.push($_);
}
for @*SIGINITS {
$loadinit_calls.push($_);
}

# Finally, startup handling code.
# XXX This will need to change some day for modules.
Expand Down Expand Up @@ -267,7 +271,7 @@ our multi sub dnst_for(PAST::Block $block) {
}
}

# See if we have a loadinit.
# Handle loadinit.
if +@($block.loadinit) {
my $*OUTER_SBI := $our_sbi;
my @*INNER_BLOCKS;
Expand All @@ -285,11 +289,37 @@ our multi sub dnst_for(PAST::Block $block) {
}
}

# Add signature generation/setup as a kind of loadinit.
@*LOADINITS.push(DNST::Bind.new(
"StaticBlockInfo[$our_sbi].Sig",
compile_signature(@*PARAMS)
# Add signature generation/setup. We need to do this in the
# correct lexical scope.
my $sig_setup_block := get_unique_id('block');
my @params;
@params.push('ThreadContext TC');
@inner_blocks.push(DNST::Method.new(
:return_type('void'),
:name($sig_setup_block),
:params(@params),
DNST::Temp.new(
:type('Context'), :name('C'),
DNST::New.new(
:type('Context'),
DNST::MethodCall.new(
:on('CodeObjectUtility'), :name('BuildStaticBlockInfo'),
'null',
"StaticBlockInfo[$our_sbi]",
DNST::ArrayLiteral.new( :type('string') )
),
'TC.CurrentContext',
'null'
)
),
DNST::Bind.new( 'TC.CurrentContext', 'C' ),
DNST::Bind.new(
"StaticBlockInfo[$our_sbi].Sig",
compile_signature(@*PARAMS)
),
DNST::Bind.new( 'TC.CurrentContext', 'C.Caller' )
));
@*SIGINITS.push(DNST::Call.new( :name($sig_setup_block), :void(1), 'TC' ));

# Before start of statements, we want to bind the signature.
$stmts.unshift(DNST::MethodCall.new(
Expand Down
7 changes: 6 additions & 1 deletion dotnet/runtime/Runtime/Signatures/SignatureBinder.cs
Expand Up @@ -49,11 +49,16 @@ public static void Bind(Context C, RakudoObject Capture)
var Positionals = NativeCapture.Positionals ?? EmptyPos;
var Nameds = NativeCapture.Nameds ?? EmptyNamed;

// If we have no signature, that's same as an empty signature.
var Sig = C.StaticCodeObject.Sig;
if (Sig == null)
return;

// Current positional.
var CurPositional = 0;

// Iterate over the parameters.
var Params = C.StaticCodeObject.Sig.Parameters;
var Params = Sig.Parameters;
foreach (var Param in Params)
{
// Positional required?
Expand Down

0 comments on commit 8876bee

Please sign in to comment.