Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Resolve dependent SCs table.
  • Loading branch information
jnthn committed Jan 18, 2013
1 parent d5fa57f commit 3f98780
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/org/perl6/nqp/sixmodel/SerializationReader.java
Expand Up @@ -49,6 +49,9 @@ public class SerializationReader {
private int reposTableOffset;
private int reposTableEntries;

/* Serialization contexts we depend on. */
SerializationContext[] dependentSCs;

public SerializationReader(ThreadContext tc, SerializationContext sc,
String[] sh, CodeRef[] cr, ByteBuffer orig) {
this.tc = tc;
Expand All @@ -64,7 +67,7 @@ public void deserialize() {

// Split the input into the various segments.
checkAndDisectInput();

resolveDependencies();
throw new RuntimeException("Deserialization NYI");
}

Expand Down Expand Up @@ -170,4 +173,27 @@ private void checkAndDisectInput() {
objDataEnd = closureTableOffset;
contextDataEnd = reposTableOffset;
}

private void resolveDependencies() {
dependentSCs = new SerializationContext[depTableEntries];
orig.position(depTableOffset);
for (int i = 0; i < depTableEntries; i++) {
String handle = lookupString(orig.getInt());
String desc = lookupString(orig.getInt());
SerializationContext sc = tc.gc.scs.get(handle);
if (sc == null) {
if (desc == null)
desc = handle;
throw new RuntimeException(
"Missing or wrong version of dependency '" + desc + "'");
}
dependentSCs[i] = sc;
}
}

private String lookupString(int idx) {
if (idx >= sh.length)
throw new RuntimeException("Attempt to read past end of string heap (index " + idx + ")");
return sh[idx];
}
}

0 comments on commit 3f98780

Please sign in to comment.