Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make nqp::list and nqp::hash consider HLL config.
  • Loading branch information
jnthn committed Feb 27, 2013
1 parent 3651628 commit 923bfe8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/QAST/JASTCompiler.nqp
Expand Up @@ -295,7 +295,7 @@ QAST::OperationsJAST.add_core_op('list', -> $qastcomp, $op {
# Just desugar to create the empty list.
my $arr := $qastcomp.as_jast(QAST::Op.new(
:op('create'),
QAST::Op.new( :op('bootarray') )
QAST::Op.new( :op('hlllist') )
));
if +$op.list {
# Put list into a temporary so we can push to it.
Expand Down Expand Up @@ -433,7 +433,7 @@ QAST::OperationsJAST.add_core_op('list_b', -> $qastcomp, $op {
# Just desugar to create the empty list.
my $arr := $qastcomp.as_jast(QAST::Op.new(
:op('create'),
QAST::Op.new( :op('bootarray') )
QAST::Op.new( :op('hlllist') )
));
if +$op.list {
my $il := JAST::InstructionList.new();
Expand Down Expand Up @@ -467,7 +467,7 @@ QAST::OperationsJAST.add_core_op('hash', -> $qastcomp, $op {
# Just desugar to create the empty hash.
my $hash := $qastcomp.as_jast(QAST::Op.new(
:op('create'),
QAST::Op.new( :op('boothash') )
QAST::Op.new( :op('hllhash') )
));
if +$op.list {
# Put hash into a temporary so we can add the items to it.
Expand Down Expand Up @@ -1747,6 +1747,8 @@ QAST::OperationsJAST.map_classlib_core_op('bootintarray', $TYPE_OPS, 'bootintarr
QAST::OperationsJAST.map_classlib_core_op('bootnumarray', $TYPE_OPS, 'bootnumarray', [], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('bootstrarray', $TYPE_OPS, 'bootstrarray', [], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('boothash', $TYPE_OPS, 'boothash', [], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('hlllist', $TYPE_OPS, 'hlllist', [], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('hllhash', $TYPE_OPS, 'hllhash', [], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('create', $TYPE_OPS, 'create', [$RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('clone', $TYPE_OPS, 'clone', [$RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('isconcrete', $TYPE_OPS, 'isconcrete', [$RT_OBJ], $RT_INT, :tc);
Expand Down
2 changes: 2 additions & 0 deletions src/org/perl6/nqp/runtime/GlobalContext.java
Expand Up @@ -154,6 +154,8 @@ private void setupConfig(HLLConfig config) {
config.intBoxType = BOOTInt;
config.numBoxType = BOOTNum;
config.strBoxType = BOOTStr;
config.listType = BOOTArray;
config.hashType = BOOTHash;
config.slurpyArrayType = BOOTArray;
config.slurpyHashType = BOOTHash;
config.arrayIteratorType = BOOTIter;
Expand Down
10 changes: 10 additions & 0 deletions src/org/perl6/nqp/runtime/HLLConfig.java
Expand Up @@ -13,6 +13,16 @@ public class HLLConfig {
public SixModelObject numBoxType;
public SixModelObject strBoxType;

/**
* The type to use for nqp::list(...)
*/
public SixModelObject listType;

/**
* The type to use for nqp::hash(...)
*/
public SixModelObject hashType;

/**
* The type to use for slurpy arrays.
*/
Expand Down
10 changes: 10 additions & 0 deletions src/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -1454,6 +1454,12 @@ public static SixModelObject bootstrarray(ThreadContext tc) {
public static SixModelObject boothash(ThreadContext tc) {
return tc.gc.BOOTHash;
}
public static SixModelObject hlllist(ThreadContext tc) {
return tc.curFrame.codeRef.staticInfo.compUnit.hllConfig.listType;
}
public static SixModelObject hllhash(ThreadContext tc) {
return tc.curFrame.codeRef.staticInfo.compUnit.hllConfig.hashType;
}
public static SixModelObject findmethod(ThreadContext tc, SixModelObject invocant, String name) {
SixModelObject meth = invocant.st.MethodCache.get(name);
if (meth == null)
Expand Down Expand Up @@ -2744,6 +2750,10 @@ public static SixModelObject sethllconfig(String language, SixModelObject config
config.numBoxType = configHash.at_key_boxed(tc, "num_box");
if (configHash.exists_key(tc, "str_box") != 0)
config.strBoxType = configHash.at_key_boxed(tc, "str_box");
if (configHash.exists_key(tc, "list") != 0)
config.listType = configHash.at_key_boxed(tc, "list");
if (configHash.exists_key(tc, "hash") != 0)
config.hashType = configHash.at_key_boxed(tc, "hash");
if (configHash.exists_key(tc, "slurpy_array") != 0)
config.slurpyArrayType = configHash.at_key_boxed(tc, "slurpy_array");
if (configHash.exists_key(tc, "slurpy_hash") != 0)
Expand Down

0 comments on commit 923bfe8

Please sign in to comment.