pub enum Expression {
Show 42 variants
Literal {
value: RuntimeValue,
},
Var {
name: String,
},
Default {
of_type: TypeDescriptor,
},
If {
cond: Box<Expression>,
then: Box<Expression>,
else: Box<Expression>,
},
EltRef {
value: Box<Expression>,
field: String,
index: IntLit,
},
EnumRef {
of_type: TypeDescriptor,
variant: String,
},
Tuple {
items: Vec<TupleItem>,
},
Vector {
items: Vec<TupleItem>,
},
TupleRef {
value: Box<Expression>,
index: IntLit,
},
TupleSlice {
value: Box<Expression>,
start: IntLit,
length: IntLit,
result_type: TypeDescriptor,
},
VectorRef {
value: Box<Expression>,
index: Box<Expression>,
result_type: TypeDescriptor,
},
VectorSlice {
value: Box<Expression>,
start: Box<Expression>,
length: IntLit,
result_type: TypeDescriptor,
},
BytesRef {
value: Box<Expression>,
index: Box<Expression>,
result_type: TypeDescriptor,
},
BytesSlice {
value: Box<Expression>,
start: Box<Expression>,
length: IntLit,
result_type: TypeDescriptor,
},
Binop {
op: String,
bits: Option<u32>,
of_type: Option<TypeDescriptor>,
left: Box<Expression>,
right: Box<Expression>,
},
Eq {
of_type: Option<TypeDescriptor>,
left: Box<Expression>,
right: Box<Expression>,
},
Neq {
of_type: Option<TypeDescriptor>,
left: Box<Expression>,
right: Box<Expression>,
},
And {
left: Box<Expression>,
right: Box<Expression>,
},
Or {
left: Box<Expression>,
right: Box<Expression>,
},
Not {
value: Box<Expression>,
},
Assign {
name: String,
value: Box<Expression>,
},
Call {
function: String,
function_uniq: Option<u64>,
arguments: Vec<Expression>,
},
New {
of_type: TypeDescriptor,
arguments: Vec<Expression>,
},
Seq {
items: Vec<Expression>,
},
Cast {
to: TypeDescriptor,
value: Box<Expression>,
},
SafeCast {
to: TypeDescriptor,
from: TypeDescriptor,
value: Box<Expression>,
},
DowncastUnsigned {
from_bits: Option<IntLit>,
to_bits: IntLit,
value: Box<Expression>,
},
FieldToBytes {
length: u32,
field_type: Option<FieldType>,
value: Box<Expression>,
},
CastToField {
field_type: FieldType,
from: TypeDescriptor,
value: Box<Expression>,
},
CastFromField {
maxval: IntLit,
field_type: FieldType,
value: Box<Expression>,
},
Emit {
event_version: u32,
event_tag: u32,
payload_length: u32,
payload: Box<Expression>,
vm_ops: Vec<VmInstr>,
},
CastFromBytes {
to: TypeDescriptor,
length: u32,
value: Box<Expression>,
},
VectorToBytes {
length: u32,
value: Box<Expression>,
},
BytesToVector {
length: u32,
value: Box<Expression>,
},
CastFromEnum {
from: TypeDescriptor,
to: TypeDescriptor,
value: Box<Expression>,
},
CastToEnum {
from: TypeDescriptor,
to: TypeDescriptor,
value: Box<Expression>,
},
Assert {
cond: Box<Expression>,
message: String,
},
Map {
length: IntLit,
function: RuntimeValue,
arguments: Vec<RuntimeValue>,
},
Fold {
length: IntLit,
function: RuntimeValue,
initial: RuntimeValue,
arguments: Vec<RuntimeValue>,
},
AdtOp(AdtOpInvocation),
ContractCall {
circuit: String,
address: Box<Expression>,
address_type: TypeDescriptor,
arguments: Vec<Expression>,
},
Unimplemented,
}Variants§
Literal
Fields
value: RuntimeValueVar
Default
Fields
of_type: TypeDescriptorIf
EltRef
EnumRef
Tuple
Vector
TupleRef
TupleSlice
VectorRef
VectorSlice
BytesRef
BytesSlice
Binop
Fields
of_type: Option<TypeDescriptor>Operand type for the arithmetic ops (+, -, *). Since
0.33 these carry a full type rather than a width, because a
curve field wraps at its own modulus — the type is what
selects the implementation.
left: Box<Expression>right: Box<Expression>Eq
Neq
And
Or
Not
Fields
value: Box<Expression>Assign
Call
Fields
function_uniq: Option<u64>Optional disambiguator for monomorphized generics — the
patched compactc fork emits function-uniq: <number> so
consumers can pick the right instantiation among multiple
circuits sharing the same source-level name. Older
fixtures don’t carry this field; consumers fall back to
“first match by name” when absent.
arguments: Vec<Expression>New
Seq
Fields
items: Vec<Expression>Cast
SafeCast
DowncastUnsigned
Narrow an unsigned integer to Uint<0..to_bits> (inclusive upper bound).
Despite the historical wire names from-bits / to-bits, both compactc
(schema 1/2) and compact-lift (schema 3) emit inclusive upper bounds
(maxval, e.g., 65535 for Uint<16>, 4294967295 for Uint<32>,
18446744073709551615 for Uint<64>, or arbitrary M for Uint<0..M>),
matching TypeDescriptor::Uint { maxval }.
FieldToBytes
Fields
field_type: Option<FieldType>Which field the operand is drawn from. Absent in schema 1, where the only field was the native one.
value: Box<Expression>CastToField
Widen a value into a field element. field-type names the target
field, from the operand’s type.
CastFromField
Narrow a field element to a Uint bounded by maxval, failing
if the value does not fit.
Emit
Emit a contract event (MIP-0002). payload evaluates to the
serialized bytes; vm-ops is the ledger-query sequence that
records the event, matching what the TypeScript emitter runs.
Fields
payload: Box<Expression>CastFromBytes
VectorToBytes
BytesToVector
CastFromEnum
CastToEnum
Assert
Map
Fold
AdtOp(AdtOpInvocation)
ContractCall
Unimplemented
Sentinel for unimplemented expression (development-time only).