Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement compiler registry (getcomp/bindcomp).
  • Loading branch information
jnthn committed Jan 23, 2013
1 parent 6228338 commit ebc30a8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/QAST/JASTCompiler.nqp
Expand Up @@ -1407,6 +1407,8 @@ QAST::OperationsJAST.add_core_op('setstaticlex', -> $qastcomp, $op {
});

# language/compiler ops
QAST::OperationsJAST.map_classlib_core_op('getcomp', $TYPE_OPS, 'getcomp', [$RT_STR], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindcomp', $TYPE_OPS, 'bindcomp', [$RT_STR, $RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('sethllconfig', $TYPE_OPS, 'sethllconfig', [$RT_STR, $RT_OBJ], $RT_OBJ, :tc);

# process related opcodes
Expand Down
6 changes: 6 additions & 0 deletions src/org/perl6/nqp/runtime/GlobalContext.java
Expand Up @@ -67,6 +67,11 @@ public class GlobalContext {
*/
private HashMap<String, HLLConfig> hllConfiguration;

/**
* Compiler registry.
*/
public HashMap<String, SixModelObject> CompilerRegistry;

/**
* Serialization context lookup hash.
*/
Expand All @@ -85,6 +90,7 @@ public GlobalContext()
hllConfiguration = new HashMap<String, HLLConfig>();
scs = new HashMap<String, SerializationContext>();
scRefs = new HashMap<String, SixModelObject>();
CompilerRegistry = new HashMap<String, SixModelObject>();

mainThread = new ThreadContext(this);
KnowHOWBootstrapper.bootstrap(mainThread);
Expand Down
7 changes: 7 additions & 0 deletions src/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -1684,6 +1684,13 @@ public static SixModelObject sethllconfig(String language, SixModelObject config
config.slurpyHashType = configHash.at_key_boxed(tc, "slurpy_hash");
return configHash;
}
public static SixModelObject getcomp(String name, ThreadContext tc) {
return tc.gc.CompilerRegistry.get(name);
}
public static SixModelObject bindcomp(String name, SixModelObject comp, ThreadContext tc) {
tc.gc.CompilerRegistry.put(name, comp);
return comp;
}

/* Coercions. */
public static long coerce_s2i(String in) {
Expand Down

0 comments on commit ebc30a8

Please sign in to comment.