Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Stub in MultiDimArray REPR on JVM.
- Loading branch information
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| package org.perl6.nqp.sixmodel.reprs; | ||
|
|
||
| import org.perl6.nqp.runtime.ExceptionHandling; | ||
| import org.perl6.nqp.runtime.ThreadContext; | ||
| import org.perl6.nqp.sixmodel.REPR; | ||
| import org.perl6.nqp.sixmodel.STable; | ||
| import org.perl6.nqp.sixmodel.SerializationReader; | ||
| import org.perl6.nqp.sixmodel.SerializationWriter; | ||
| import org.perl6.nqp.sixmodel.SixModelObject; | ||
| import org.perl6.nqp.sixmodel.StorageSpec; | ||
| import org.perl6.nqp.sixmodel.TypeObject; | ||
|
|
||
| public class MultiDimArray extends REPR { | ||
| public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) { | ||
| STable st = new STable(this, HOW); | ||
| SixModelObject obj = new TypeObject(); | ||
| obj.st = st; | ||
| st.WHAT = obj; | ||
| return st.WHAT; | ||
| } | ||
|
|
||
| public SixModelObject allocate(ThreadContext tc, STable st) { | ||
| throw ExceptionHandling.dieInternal(tc, "allocate NYI"); | ||
| } | ||
|
|
||
| public void compose(ThreadContext tc, STable st, SixModelObject repr_info) { | ||
| SixModelObject arrayInfo = repr_info.at_key_boxed(tc, "array"); | ||
| if (arrayInfo != null) { | ||
| MultiDimArrayREPRData reprData = new MultiDimArrayREPRData(); | ||
|
|
||
| SixModelObject dims = arrayInfo.at_key_boxed(tc, "dimensions"); | ||
| if (dims == null) | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "MultiDimArray REPR must be composed with a number of dimensions"); | ||
| int dimensions = (int)dims.get_int(tc); | ||
| if (dimensions < 1) | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "MultiDimArray REPR must be composed with at least 1 dimension"); | ||
| reprData.numDimensions = dimensions; | ||
|
|
||
| SixModelObject type = arrayInfo.at_key_boxed(tc, "type"); | ||
| StorageSpec ss = type != null ? type.st.REPR.get_storage_spec(tc, type.st) : null; | ||
| switch (ss != null ? ss.boxed_primitive : StorageSpec.REFERENCE) { | ||
| case StorageSpec.BP_INT: | ||
| case StorageSpec.BP_NUM: | ||
| case StorageSpec.BP_STR: | ||
| reprData.type = type; | ||
| reprData.ss = ss; | ||
| break; | ||
| default: | ||
| if (ss != null && ss.inlineable != StorageSpec.REFERENCE) | ||
| throw ExceptionHandling.dieInternal(tc, "MultiDimArray can only store native int/num/str or reference types"); | ||
| } | ||
|
|
||
| st.REPRData = reprData; | ||
| } | ||
| else { | ||
| throw ExceptionHandling.dieInternal(tc, "MultiDimArray REPR must be composed with array information"); | ||
| } | ||
| } | ||
|
|
||
| public SixModelObject deserialize_stub(ThreadContext tc, STable st) { | ||
| throw ExceptionHandling.dieInternal(tc, "deserialize NYI"); | ||
| } | ||
|
|
||
| public void deserialize_finish(ThreadContext tc, STable st, | ||
| SerializationReader reader, SixModelObject obj) { | ||
| throw ExceptionHandling.dieInternal(tc, "deserialize NYI"); | ||
| } | ||
|
|
||
| public void serialize(ThreadContext tc, SerializationWriter writer, SixModelObject obj) { | ||
| throw ExceptionHandling.dieInternal(tc, "serialize NYI"); | ||
| } | ||
|
|
||
| public StorageSpec get_value_storage_spec(ThreadContext tc, STable st) { | ||
| return st.REPRData == null ? StorageSpec.BOXED : ((MultiDimArrayREPRData)st.REPRData).ss; | ||
| } | ||
|
|
||
| /** | ||
| * REPR data serialization. Serializes the per-type representation data that | ||
| * is attached to the supplied STable. | ||
| */ | ||
| public void serialize_repr_data(ThreadContext tc, STable st, SerializationWriter writer) | ||
| { | ||
| throw ExceptionHandling.dieInternal(tc, "repr serialize NYI"); | ||
| } | ||
|
|
||
| /** | ||
| * REPR data deserialization. Deserializes the per-type representation data and | ||
| * attaches it to the supplied STable. | ||
| */ | ||
| public void deserialize_repr_data(ThreadContext tc, STable st, SerializationReader reader) | ||
| { | ||
| throw ExceptionHandling.dieInternal(tc, "repr deserialize NYI"); | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayREPRData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package org.perl6.nqp.sixmodel.reprs; | ||
|
|
||
| import org.perl6.nqp.sixmodel.SixModelObject; | ||
| import org.perl6.nqp.sixmodel.StorageSpec; | ||
|
|
||
| public class MultiDimArrayREPRData { | ||
| public StorageSpec ss; | ||
| public SixModelObject type; | ||
| public int numDimensions; | ||
| } |