Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Serialize HLL related info.
  • Loading branch information
jnthn committed May 10, 2013
1 parent 863ea92 commit 9ad904b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
Expand Up @@ -176,6 +176,7 @@ public HLLConfig getHLLConfigFor(String language) {
HLLConfig config = hllConfiguration.get(language);
if (config == null) {
config = new HLLConfig();
config.name = language;
setupConfig(config);
hllConfiguration.put(language, config);
}
Expand Down
14 changes: 14 additions & 0 deletions src/vm/jvm/runtime/org/perl6/nqp/runtime/HLLConfig.java
Expand Up @@ -6,6 +6,20 @@
* Contains configuration specific to a given HLL.
*/
public class HLLConfig {
/* HLL type roles. */
public static final int ROLE_NONE = 0;
public static final int ROLE_INT = 1;
public static final int ROLE_NUM = 2;
public static final int ROLE_STR = 3;
public static final int ROLE_ARRAY = 4;
public static final int ROLE_HASH = 5;
public static final int ROLE_CODE = 6;

/**
* HLL name.
*/
public String name;

/**
* The types the languages wish to get things boxed as.
*/
Expand Down
Expand Up @@ -11,7 +11,7 @@

public class SerializationReader {
/* The current version of the serialization format. */
private final int CURRENT_VERSION = 5;
private final int CURRENT_VERSION = 6;

/* The minimum version of the serialization format. */
private final int MIN_VERSION = 4;
Expand Down Expand Up @@ -351,6 +351,12 @@ private void deserializeSTables() {
st.InvocationSpec.InvocationHandler = readRef();
}
}

/* HLL stuff. */
if (version >= 6) {
st.hllOwner = tc.gc.getHLLConfigFor(readStr());
st.hllRole = orig.getLong();
}

/* If the REPR has a function to deserialize representation data, call it. */
st.REPR.deserialize_repr_data(tc, st, this);
Expand Down
Expand Up @@ -17,7 +17,7 @@

public class SerializationWriter {
/* The current version of the serialization format. */
private final int CURRENT_VERSION = 5;
private final int CURRENT_VERSION = 6;

/* Various sizes (in bytes). */
private final int HEADER_SIZE = 4 * 16;
Expand Down Expand Up @@ -546,6 +546,10 @@ private void serializeStable(STable st) {
writeRef(st.InvocationSpec.InvocationHandler);
}

/* HLL info. */
writeStr(st.hllOwner == null ? "" : st.hllOwner.name);
writeInt(st.hllRole);

/* Location of REPR data. */
outputs[STABLES].putInt(outputs[STABLE_DATA].position());

Expand Down

0 comments on commit 9ad904b

Please sign in to comment.