Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stub the NativeCall and CPointer REPRs.
- Loading branch information
Showing
6 changed files
with
118 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
38 changes: 38 additions & 0 deletions
38
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/CPointer.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,38 @@ | ||
package org.perl6.nqp.sixmodel.reprs; | ||
|
||
import org.perl6.nqp.sixmodel.REPR; | ||
import org.perl6.nqp.sixmodel.SerializationReader; | ||
import org.perl6.nqp.sixmodel.SixModelObject; | ||
import org.perl6.nqp.sixmodel.STable; | ||
import org.perl6.nqp.sixmodel.TypeObject; | ||
import org.perl6.nqp.runtime.ExceptionHandling; | ||
import org.perl6.nqp.runtime.ThreadContext; | ||
|
||
|
||
public class CPointer extends REPR { | ||
public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) { | ||
STable st = new STable(this, HOW); | ||
st.REPRData = null; /* No REPR data needed. */ | ||
SixModelObject obj = new TypeObject(); | ||
obj.st = st; | ||
st.WHAT = obj; | ||
return st.WHAT; | ||
} | ||
|
||
public SixModelObject allocate(ThreadContext tc, STable st) { | ||
SixModelObject obj = new CPointerInstance(); | ||
obj.st = st; | ||
return obj; | ||
} | ||
|
||
public SixModelObject deserialize_stub(ThreadContext tc, STable st) { | ||
/* This REPR can't be serialized. */ | ||
ExceptionHandling.dieInternal(tc, "Can't deserialize_stub a CPointer object."); | ||
|
||
return null; | ||
} | ||
|
||
public void deserialize_finish(ThreadContext tc, STable st, SerializationReader reader, SixModelObject obj) { | ||
ExceptionHandling.dieInternal(tc, "Can't deserialize_finish a CPointer object."); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/CPointerInstance.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,7 @@ | ||
package org.perl6.nqp.sixmodel.reprs; | ||
|
||
import org.perl6.nqp.sixmodel.SixModelObject; | ||
|
||
public class CPointerInstance extends SixModelObject { | ||
/* Nothing here yet. */ | ||
} |
38 changes: 38 additions & 0 deletions
38
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/NativeCall.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,38 @@ | ||
package org.perl6.nqp.sixmodel.reprs; | ||
|
||
import org.perl6.nqp.sixmodel.REPR; | ||
import org.perl6.nqp.sixmodel.SerializationReader; | ||
import org.perl6.nqp.sixmodel.SixModelObject; | ||
import org.perl6.nqp.sixmodel.STable; | ||
import org.perl6.nqp.sixmodel.TypeObject; | ||
import org.perl6.nqp.runtime.ExceptionHandling; | ||
import org.perl6.nqp.runtime.ThreadContext; | ||
|
||
|
||
public class NativeCall extends REPR { | ||
public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) { | ||
STable st = new STable(this, HOW); | ||
st.REPRData = null; /* No REPR data needed. */ | ||
SixModelObject obj = new TypeObject(); | ||
obj.st = st; | ||
st.WHAT = obj; | ||
return st.WHAT; | ||
} | ||
|
||
public SixModelObject allocate(ThreadContext tc, STable st) { | ||
SixModelObject obj = new NativeCallInstance(); | ||
obj.st = st; | ||
return obj; | ||
} | ||
|
||
public SixModelObject deserialize_stub(ThreadContext tc, STable st) { | ||
/* This REPR can't be serialized. */ | ||
ExceptionHandling.dieInternal(tc, "Can't deserialize_stub a NativeCall object."); | ||
|
||
return null; | ||
} | ||
|
||
public void deserialize_finish(ThreadContext tc, STable st, SerializationReader reader, SixModelObject obj) { | ||
ExceptionHandling.dieInternal(tc, "Can't deserialize_finish a NativeCall object."); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/NativeCallInstance.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,29 @@ | ||
package org.perl6.nqp.sixmodel.reprs; | ||
|
||
import org.perl6.nqp.sixmodel.SixModelObject; | ||
|
||
public class NativeCallInstance extends SixModelObject { | ||
/* Constants. Might be more idiomatic Java to move these to an enum. */ | ||
public static final byte ARG_VOID = 0; | ||
public static final byte ARG_CHAR = 2; | ||
public static final byte ARG_SHORT = 4; | ||
public static final byte ARG_INT = 6; | ||
public static final byte ARG_LONG = 8; | ||
public static final byte ARG_LONGLONG = 10; | ||
public static final byte ARG_FLOAT = 12; | ||
public static final byte ARG_DOUBLE = 14; | ||
public static final byte ARG_ASCIISTR = 16; | ||
public static final byte ARG_UTF8STR = 18; | ||
public static final byte ARG_UTF16STR = 20; | ||
public static final byte ARG_CSTRUCT = 22; | ||
public static final byte ARG_CARRAY = 24; | ||
public static final byte ARG_CALLBACK = 26; | ||
public static final byte ARG_CPOINTER = 28; | ||
public static final byte ARG_TYPE_MASK = 30; | ||
|
||
/* Flag for whether we should free a string after passing it or not. These | ||
* are going away once the array handling is refactored.*/ | ||
public static final byte ARG_NO_FREE_STR = 0; | ||
public static final byte ARG_FREE_STR = 1; | ||
public static final byte ARG_FREE_STR_MASK = 1; | ||
} |