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 native lexical reference REPR bits.
- Loading branch information
Showing
5 changed files
with
158 additions
and
3 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
14 changes: 14 additions & 0 deletions
14
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/NativeRefInstance.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,14 @@ | ||
| package org.perl6.nqp.sixmodel.reprs; | ||
|
|
||
| import org.perl6.nqp.runtime.ThreadContext; | ||
| import org.perl6.nqp.sixmodel.SixModelObject; | ||
|
|
||
| /* Base for instances of native references. */ | ||
| public abstract class NativeRefInstance extends SixModelObject { | ||
| public abstract long fetch_i(ThreadContext tc); | ||
| public abstract double fetch_n(ThreadContext tc); | ||
| public abstract String fetch_s(ThreadContext tc); | ||
| public abstract void store_i(ThreadContext tc, long value); | ||
| public abstract void store_n(ThreadContext tc, double value); | ||
| public abstract void store_s(ThreadContext tc, String value); | ||
| } |
39 changes: 39 additions & 0 deletions
39
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/NativeRefInstanceIntLex.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,39 @@ | ||
| package org.perl6.nqp.sixmodel.reprs; | ||
|
|
||
| import org.perl6.nqp.runtime.ExceptionHandling; | ||
| import org.perl6.nqp.runtime.ThreadContext; | ||
| import org.perl6.nqp.sixmodel.SixModelObject; | ||
|
|
||
| /* Integer native lexical reference. */ | ||
| public class NativeRefInstanceIntLex extends SixModelObject { | ||
| public long[] lexicals; | ||
| public int idx; | ||
|
|
||
| public long fetch_i(ThreadContext tc) { | ||
| return lexicals[idx]; | ||
| } | ||
|
|
||
| public double fetch_n(ThreadContext tc) { | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "This container does not reference a native number"); | ||
| } | ||
|
|
||
| public String fetch_s(ThreadContext tc) { | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "This container does not reference a native string"); | ||
| } | ||
|
|
||
| public void store_i(ThreadContext tc, long value) { | ||
| lexicals[idx] = value; | ||
| } | ||
|
|
||
| public void store_n(ThreadContext tc, double value) { | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "This container does not reference a native number"); | ||
| } | ||
|
|
||
| public void store_s(ThreadContext tc, String value) { | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "This container does not reference a native string"); | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/NativeRefInstanceNumLex.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,39 @@ | ||
| package org.perl6.nqp.sixmodel.reprs; | ||
|
|
||
| import org.perl6.nqp.runtime.ExceptionHandling; | ||
| import org.perl6.nqp.runtime.ThreadContext; | ||
| import org.perl6.nqp.sixmodel.SixModelObject; | ||
|
|
||
| /* Integer native lexical reference. */ | ||
| public class NativeRefInstanceNumLex extends SixModelObject { | ||
| public double[] lexicals; | ||
| public int idx; | ||
|
|
||
| public long fetch_i(ThreadContext tc) { | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "This container does not reference a native integer"); | ||
| } | ||
|
|
||
| public double fetch_n(ThreadContext tc) { | ||
| return lexicals[idx]; | ||
| } | ||
|
|
||
| public String fetch_s(ThreadContext tc) { | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "This container does not reference a native string"); | ||
| } | ||
|
|
||
| public void store_i(ThreadContext tc, long value) { | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "This container does not reference a native integer"); | ||
| } | ||
|
|
||
| public void store_n(ThreadContext tc, double value) { | ||
| lexicals[idx] = value; | ||
| } | ||
|
|
||
| public void store_s(ThreadContext tc, String value) { | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "This container does not reference a native string"); | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/NativeRefInstanceStrLex.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,39 @@ | ||
| package org.perl6.nqp.sixmodel.reprs; | ||
|
|
||
| import org.perl6.nqp.runtime.ExceptionHandling; | ||
| import org.perl6.nqp.runtime.ThreadContext; | ||
| import org.perl6.nqp.sixmodel.SixModelObject; | ||
|
|
||
| /* Integer native lexical reference. */ | ||
| public class NativeRefInstanceStrLex extends SixModelObject { | ||
| public String[] lexicals; | ||
| public int idx; | ||
|
|
||
| public long fetch_i(ThreadContext tc) { | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "This container does not reference a native integer"); | ||
| } | ||
|
|
||
| public double fetch_n(ThreadContext tc) { | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "This container does not reference a native number"); | ||
| } | ||
|
|
||
| public String fetch_s(ThreadContext tc) { | ||
| return lexicals[idx]; | ||
| } | ||
|
|
||
| public void store_i(ThreadContext tc, long value) { | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "This container does not reference a native integer"); | ||
| } | ||
|
|
||
| public void store_n(ThreadContext tc, double value) { | ||
| throw ExceptionHandling.dieInternal(tc, | ||
| "This container does not reference a native number"); | ||
| } | ||
|
|
||
| public void store_s(ThreadContext tc, String value) { | ||
| lexicals[idx] = value; | ||
| } | ||
| } |