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
Fill out MultiDimArray base class.
Has the storage-type-independent bits.
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
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
27 changes: 27 additions & 0 deletions
27
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayInstanceBase.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,27 @@ | ||
| package org.perl6.nqp.sixmodel.reprs; | ||
|
|
||
| import java.lang.System; | ||
|
|
||
| import org.perl6.nqp.runtime.ExceptionHandling; | ||
| import org.perl6.nqp.runtime.ThreadContext; | ||
| import org.perl6.nqp.sixmodel.SixModelObject; | ||
|
|
||
| public class MultiDimArrayInstanceBase extends SixModelObject { | ||
| public long[] dimensions; | ||
|
|
||
| public long[] dimensions(ThreadContext tc) { | ||
| return dimensions; | ||
| } | ||
|
|
||
| public void set_dimensions(ThreadContext tc, long[] dims) { | ||
| MultiDimArrayREPRData rd = (MultiDimArrayREPRData)this.st.REPRData; | ||
| if (rd.numDimensions == dims.length) { | ||
| System.arraycopy(dims, 0, this.dimensions, 0, dims.length); | ||
| } | ||
| else { | ||
| throw ExceptionHandling.dieInternal(tc, String.format( | ||
| "Array type of %d dimensions cannot be initialized with %d dimensions", | ||
| rd.numDimensions, dims.length)); | ||
| } | ||
| } | ||
| } |