Commit e00ea518 authored by Kunshan Wang's avatar Kunshan Wang

WIP: bindings of all functions

parent 7613ecf2
This diff is collapsed.
......@@ -16,7 +16,13 @@ extern "C" {
// Values of subtypes can be cast to MuValue and back using the type cast
// expression in C, similar to casting one pointer to another.
// abstract value type
typedef void *MuValue; // Any Mu value
typedef void *MuSeqValue; // array or vector
typedef void *MuGenRefValue; // ref, iref, funcref, threadref, stackref, framecursorref
// concrete value types
typedef void *MuIntValue; // int<n>
typedef void *MuFloatValue; // float
typedef void *MuDoubleValue; // double
......@@ -184,7 +190,7 @@ struct MuCtx {
// Compare reference or general reference types.
// EQ. Available for ref, iref, funcref, threadref and stackref.
int (*ref_eq )(MuCtx *ctx, MuValue lhs, MuValue rhs);
int (*ref_eq )(MuCtx *ctx, MuGenRefValue lhs, MuGenRefValue rhs);
// ULT. Available for iref only.
int (*ref_ult)(MuCtx *ctx, MuIRefValue lhs, MuIRefValue rhs);
......@@ -194,15 +200,15 @@ struct MuCtx {
// Manipulate Mu values of the array or vector type
// str can be MuArrayValue or MuVectorValue
MuValue (*extract_element)(MuCtx *ctx, MuValue str, MuIntValue index);
MuValue (*insert_element )(MuCtx *ctx, MuValue str, MuIntValue index, MuValue newval);
MuValue (*extract_element)(MuCtx *ctx, MuSeqValue str, MuIntValue index);
MuSeqValue (*insert_element )(MuCtx *ctx, MuSeqValue str, MuIntValue index, MuValue newval);
// Heap allocation
MuRefValue (*new_fixed )(MuCtx *ctx, MuID mu_type);
MuRefValue (*new_hybrid)(MuCtx *ctx, MuID mu_type, MuIntValue length);
// Change the T or sig in ref<T>, iref<T> or func<sig>
MuValue (*refcast)(MuCtx *ctx, MuValue opnd, MuID new_type);
MuGenRefValue (*refcast)(MuCtx *ctx, MuGenRefValue opnd, MuID new_type);
// Memory addressing
MuIRefValue (*get_iref )(MuCtx *ctx, MuRefValue opnd);
......@@ -74,7 +74,7 @@ case class MuStackRefValue(ty: TypeStackRef, vb: BoxStack) extends MuGenRefValue
case class MuTagRef64Value(ty: TypeTagRef64, vb: BoxTagRef64) extends MuValue
case class MuUPtrValue(ty: TypeUPtr, vb: BoxPointer) extends MuValue
case class MuUFPValue(ty: TypeUFuncPtr, vb: BoxPointer) extends MuValue
case class MuFCRefValue(ty: TypeFrameCursorRef, vb: BoxFrameCursor) extends MuValue
case class MuFCRefValue(ty: TypeFrameCursorRef, vb: BoxFrameCursor) extends MuGenRefValue
abstract class TrapHandlerResult
object TrapHandlerResult {
......@@ -266,6 +266,7 @@ class MuCtx(_mutator: Mutator)(
case (l: MuFuncRefValue, r: MuFuncRefValue) => l.vb.func == r.vb.func
case (l: MuThreadRefValue, r: MuThreadRefValue) => l.vb.thread == r.vb.thread
case (l: MuStackRefValue, r: MuStackRefValue) => l.vb.stack == r.vb.stack
case (l: MuFCRefValue, r: MuFCRefValue) => l.vb.cursor == r.vb.cursor
case (l, r) => {
throw new IllegalArgumentException("Bad types for refEq: %s and %s".format(
l.showTy, r.showTy))
......@@ -896,4 +897,4 @@ object RichMuCtx {
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment