Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Stash capture in current context. Also fix a viviself code-gen bug.
  • Loading branch information
jnthn committed Aug 22, 2010
1 parent 7d9fec6 commit 98196e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 7 additions & 3 deletions dotnet/compiler/PAST2DNSTCompiler.pm
Expand Up @@ -192,7 +192,8 @@ sub make_constants_init_method($name) {
'StaticBlockInfo[1]',
DNST::ArrayLiteral.new( :type('string') )
),
'TC.CurrentContext'
'TC.CurrentContext',
'null'
)
),

Expand Down Expand Up @@ -298,7 +299,7 @@ our multi sub dnst_for(PAST::Block $block) {
# Wrap in block prelude/postlude.
$result.push(DNST::Temp.new(
:name('C'), :type('var'),
DNST::New.new( :type('Context'), "StaticBlockInfo[$our_sbi]", "TC.CurrentContext" )
DNST::New.new( :type('Context'), "StaticBlockInfo[$our_sbi]", "TC.CurrentContext", "Capture" )
));
$result.push(DNST::Bind.new( 'TC.CurrentContext', 'C' ));
$result.push(DNST::TryFinally.new(
Expand Down Expand Up @@ -736,7 +737,10 @@ sub declare_lexical($var) {
if pir::defined($var.viviself) {
my $*BIND_CONTEXT := 'bind_lex';
my $result := emit_lexical_lookup($var.name);
$result.push(dnst_for($var.viviself));
{
my $*BIND_CONTEXT := '';
$result.push(dnst_for($var.viviself));
}
return $result;
}
else {
Expand Down
8 changes: 7 additions & 1 deletion dotnet/runtime/Runtime/Context.cs
Expand Up @@ -34,6 +34,11 @@ public class Context
/// </summary>
public Dictionary<string, RakudoObject> LexPad;

/// <summary>
/// The capture passed as part of the current call.
/// </summary>
public RakudoObject Capture;

/// <summary>
/// Creates an empty, uninitialized context.
/// </summary>
Expand All @@ -46,11 +51,12 @@ public Context()
/// </summary>
/// <param name="StaticCodeObject"></param>
/// <param name="Caller"></param>
public Context(RakudoCodeRef.Instance StaticCodeObject, Context Caller)
public Context(RakudoCodeRef.Instance StaticCodeObject, Context Caller, RakudoObject Capture)
{
// Set up static code object and caller pointers.
this.StaticCodeObject = StaticCodeObject;
this.Caller = Caller;
this.Capture = Capture;

// Static sub object should have this as the current
// context.
Expand Down

0 comments on commit 98196e3

Please sign in to comment.