Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve detection of wrong version of pre-compiled code being used, a…
…nd include the filename in the error rather than a weird SC identifier.
  • Loading branch information
jnthn committed Jul 26, 2011
1 parent 3279ea7 commit 95fbb94
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
17 changes: 15 additions & 2 deletions src/HLL/SerializationContextBuilder.pm
Expand Up @@ -149,13 +149,26 @@ class HLL::Compiler::SerializationContextBuilder {
}

# If it's this context, dead easy. Otherwise, need to build a
# cross-reference.
# cross-reference, plus check it if it's the first time we are
# seeing it.
if $sc =:= $!sc {
self.get_slot_past_for_object($obj);
}
else {
my $handle := $sc.handle;
%!dependencies{$handle} := $sc;
unless pir::exists(%!dependencies, $handle) {
%!dependencies{$handle} := $sc;
self.add_event(:deserialize_past(PAST::Op.new(
:pasttype('if'),
PAST::Op.new(
:pirop('isnull IP'),
PAST::Op.new( :pirop('nqp_get_sc Ps'), $handle )
),
PAST::Op.new(
:pirop('die vS'),
"Incorrect pre-compiled version of " ~ ($sc.description || '<unknown>') ~ " loaded"
))));
}
PAST::Op.new( :pirop('nqp_get_sc_object Psi'),
$handle, $sc.slot_index_for($obj)
)
Expand Down
7 changes: 4 additions & 3 deletions src/NQP/Grammar.pm
Expand Up @@ -17,9 +17,10 @@ grammar NQP::Grammar is HLL::Grammar {
# Serialization context builder - keeps track of objects that
# cross the compile-time/run-time boundary that are associated
# with this compilation unit.
my $*SC := NQP::SymbolTable.new(
# XXX Need to hash the source, or something.
:handle(~pir::time__N()));
my $file := pir::find_caller_lex__ps('$?FILES');
my $*SC := pir::isnull($file) ??
NQP::SymbolTable.new(:handle(~pir::time__N())) !!
NQP::SymbolTable.new(:handle(~pir::time__N()), :description($file));

my $*SCOPE := '';
my $*MULTINESS := '';
Expand Down
5 changes: 5 additions & 0 deletions src/NQP/SymbolTable.pm
Expand Up @@ -420,6 +420,11 @@ class NQP::SymbolTable is HLL::Compiler::SerializationContextBuilder {
PAST::Var.new( :name('cur_sc'), :scope('register'), :isdecl(1) ),
PAST::Op.new( :pirop('nqp_create_sc Ps'), self.handle() )
),
PAST::Op.new(
:pasttype('callmethod'), :name('set_description'),
PAST::Var.new( :name('cur_sc'), :scope('register') ),
self.sc.description
),
$des
),
$fix
Expand Down

0 comments on commit 95fbb94

Please sign in to comment.