Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix things so we make it to the deserialize op.
This means the string heap and code ref lists are being assembled
successfully. Commented out post-deserialization tasks for now; these
will need some abstraction work later on. This means that things are in
place to start the real work of implementing deserialization.
  • Loading branch information
jnthn committed Jan 18, 2013
1 parent 9a95f10 commit e06e1f2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/QAST/JASTCompiler.nqp
Expand Up @@ -1860,14 +1860,14 @@ class QAST::CompilerJAST {
}

# Add post-deserialization tasks.
for @post_des {
$block.push(QAST::Stmt.new($_));
}
#for @post_des {
# $block.push(QAST::Stmt.new($_));
#}

# Compile to JAST and register this block as the deserialization
# handler.
self.as_jast($block);
my $des_meth := JAST::Method.new( :name('deserializeIdx'), :returns('Integer') );
my $des_meth := JAST::Method.new( :name('deserializeIdx'), :returns('Integer'), :static(0) );
$des_meth.append(JAST::PushIndex.new( :value($*CODEREFS.cuid_to_idx($block.cuid)) ));
$des_meth.append(JAST::Instruction.new( :op('ireturn') ));
$*JCLASS.add_method($des_meth);
Expand All @@ -1881,7 +1881,7 @@ class QAST::CompilerJAST {
QAST::Op.new( :op('null') )
);
self.as_jast($load_block);
my $load_meth := JAST::Method.new( :name('loadIdx'), :returns('Integer') );
my $load_meth := JAST::Method.new( :name('loadIdx'), :returns('Integer'), :static(0) );
$load_meth.append(JAST::PushIndex.new( :value($*CODEREFS.cuid_to_idx($load_block.cuid)) ));
$load_meth.append(JAST::Instruction.new( :op('ireturn') ));
$*JCLASS.add_method($load_meth);
Expand Down Expand Up @@ -1952,7 +1952,7 @@ class QAST::CompilerJAST {
}

# Overall deserialization QAST.
QAST::Stmt.new(
QAST::Stmts.new(
QAST::Op.new(
:op('bind'),
QAST::Var.new( :name('cur_sc'), :scope('local'), :decl('var') ),
Expand Down
18 changes: 18 additions & 0 deletions src/org/perl6/nqp/runtime/CompilationUnit.java
Expand Up @@ -70,6 +70,17 @@ public void initializeCompilationUnit(ThreadContext tc) {

/* Get HLL configuration object. */
hllConfig = tc.gc.getHLLConfigFor(this.hllName());

/* Run any deserialization code. */
int dIdx = deserializeIdx();
if (dIdx >= 0)
try {
Ops.invoke(tc, codeRefs[dIdx], -1);
}
catch (Exception e)
{
throw new RuntimeException("Deserialization failed: " + e.getMessage());
}
}

/**
Expand Down Expand Up @@ -111,4 +122,11 @@ public CodeRef lookupCodeRef(String uniqueId) {
* Code generation emits this to supply the HLL name from QAST::CompUnit.
*/
public abstract String hllName();

/**
* Code generation overrides this if there's an SC to deserialize.
*/
public int deserializeIdx() {
return -1;
}
}

0 comments on commit e06e1f2

Please sign in to comment.