Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement getcurhllsym and bindcurhllsym.
  • Loading branch information
jnthn committed Jan 24, 2013
1 parent ebc30a8 commit b172cc3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/QAST/JASTCompiler.nqp
Expand Up @@ -1409,6 +1409,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('getcurhllsym', $TYPE_OPS, 'getcurhllsym', [$RT_STR], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindcurhllsym', $TYPE_OPS, 'bindcurhllsym', [$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
10 changes: 8 additions & 2 deletions src/org/perl6/nqp/runtime/GlobalContext.java
Expand Up @@ -67,10 +67,15 @@ public class GlobalContext {
*/
private HashMap<String, HLLConfig> hllConfiguration;

/**
* HLL global symbols.
*/
public HashMap<String, HashMap<String, SixModelObject>> hllSyms;

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

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

mainThread = new ThreadContext(this);
KnowHOWBootstrapper.bootstrap(mainThread);
Expand Down
19 changes: 17 additions & 2 deletions src/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -1685,12 +1685,27 @@ public static SixModelObject sethllconfig(String language, SixModelObject config
return configHash;
}
public static SixModelObject getcomp(String name, ThreadContext tc) {
return tc.gc.CompilerRegistry.get(name);
return tc.gc.compilerRegistry.get(name);
}
public static SixModelObject bindcomp(String name, SixModelObject comp, ThreadContext tc) {
tc.gc.CompilerRegistry.put(name, comp);
tc.gc.compilerRegistry.put(name, comp);
return comp;
}
public static SixModelObject getcurhllsym(String name, ThreadContext tc) {
String hllName = tc.curFrame.codeRef.staticInfo.compUnit.hllName();
HashMap<String, SixModelObject> hllSyms = tc.gc.hllSyms.get(hllName);
return hllSyms == null ? null : hllSyms.get(name);
}
public static SixModelObject bindcurhllsym(String name, SixModelObject value, ThreadContext tc) {
String hllName = tc.curFrame.codeRef.staticInfo.compUnit.hllName();
HashMap<String, SixModelObject> hllSyms = tc.gc.hllSyms.get(hllName);
if (hllSyms == null) {
hllSyms = new HashMap<String, SixModelObject>();
tc.gc.hllSyms.put(hllName, hllSyms);
}
hllSyms.put(name, value);
return value;
}

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

0 comments on commit b172cc3

Please sign in to comment.