Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Refactor interactive mode context handling slightly.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Jul 7, 2010
1 parent 04f7885 commit d01b490
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/HLL/Compiler.pm
Expand Up @@ -98,6 +98,7 @@ class HLL::Compiler is PCT::HLLCompiler {
$stdin.encoding($encoding);
}

my $save_ctx;
while 1 {
last unless $stdin;

Expand All @@ -108,25 +109,26 @@ class HLL::Compiler is PCT::HLLCompiler {

# Set the current position of stdout for autoprinting control
my $*AUTOPRINTPOS := (pir::getinterp__P()).stdhandle(1).tell();
our $interactive_ctx;
our %interactive_pad;
my $*CTXSAVE := self;
my $*MAIN_CTX;

if $code {
$code := $code ~ "\n";
my $output;
{
$output := self.eval($code, :outer_ctx($interactive_ctx), |%adverbs);
$output := self.eval($code, :outer_ctx($save_ctx), |%adverbs);
CATCH {
pir::print(~$! ~ "\n");
next;
}
};
if pir::defined($*MAIN_CTX) {
our $interactive_ctx;
our %interactive_pad;
for $*MAIN_CTX.lexpad_full() {
%interactive_pad{$_.key} := $_.value;
}
$save_ctx := $interactive_ctx;
}
next if pir::isnull($output);

Expand Down

0 comments on commit d01b490

Please sign in to comment.