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
Add partial P6bigint REPR and some basic ops.
This is enough to pass the first 5 of 60-bigint.t. Note that P6bigint currently is not able to embed itself into a P6opaque.
- Loading branch information
Showing
5 changed files
with
138 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
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
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
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,43 @@ | ||
| package org.perl6.nqp.sixmodel.reprs; | ||
|
|
||
| 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.SixModelObject; | ||
| import org.perl6.nqp.sixmodel.StorageSpec; | ||
| import org.perl6.nqp.sixmodel.TypeObject; | ||
|
|
||
| public class P6bigint 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) { | ||
| P6bigintInstance obj = new P6bigintInstance(); | ||
| obj.st = st; | ||
| return obj; | ||
| } | ||
|
|
||
| public StorageSpec get_storage_spec(ThreadContext tc, STable st) { | ||
| StorageSpec ss = new StorageSpec(); | ||
| ss.inlineable = StorageSpec.INLINED; | ||
| ss.boxed_primitive = StorageSpec.BP_INT; | ||
| ss.bits = 64; | ||
| ss.can_box = StorageSpec.CAN_BOX_INT; | ||
| return ss; | ||
| } | ||
|
|
||
| public SixModelObject deserialize_stub(ThreadContext tc, STable st) { | ||
| throw new RuntimeException("Deserialization NYI for P6bigint"); | ||
| } | ||
|
|
||
| public void deserialize_finish(ThreadContext tc, STable st, | ||
| SerializationReader reader, SixModelObject obj) { | ||
| throw new RuntimeException("Deserialization NYI for P6bigint"); | ||
| } | ||
| } |
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,22 @@ | ||
| package org.perl6.nqp.sixmodel.reprs; | ||
|
|
||
| import java.math.BigInteger; | ||
|
|
||
| import org.perl6.nqp.runtime.ThreadContext; | ||
| import org.perl6.nqp.sixmodel.SixModelObject; | ||
|
|
||
| public class P6bigintInstance extends SixModelObject { | ||
| public BigInteger value; | ||
|
|
||
| public void initialize(ThreadContext tc) { | ||
| value = BigInteger.ZERO; | ||
| } | ||
|
|
||
| public void set_int(ThreadContext tc, long value) { | ||
| this.value = BigInteger.valueOf(value); | ||
| } | ||
|
|
||
| public long get_int(ThreadContext tc) { | ||
| return value.longValue(); | ||
| } | ||
| } |