Skip to content

Op Types Reference

Every operation in a DUUMBI program is a node in the semantic graph with a @type from the duumbi: namespace. This page documents all ops with their Cranelift IR mapping and JSON-LD usage.

OpCranelift IRDescription
ConsticonstInteger constant (i64)
ConstF64f64constFloat constant (f64)
ConstBooliconst (i8)Boolean constant
Addiadd / faddAddition
Subisub / fsubSubtraction
Mulimul / fmulMultiplication
Divsdiv / fdivDivision
// Const: integer literal
{ "@type": "duumbi:Const", "value": 42 }
// ConstF64: floating-point literal
{ "@type": "duumbi:ConstF64", "value": 3.14 }
// Add: binary arithmetic (works on i64 and f64)
{
"@type": "duumbi:Add",
"duumbi:left": { "@id": "duumbi:main/main/entry/0" },
"duumbi:right": { "@id": "duumbi:main/main/entry/1" }
}
OpCranelift IRDescription
Compareicmp / fcmpComparison (returns bool)
BranchbrifConditional branch
CallcallFunction call
ReturnreturnReturn from function
Matchbrif on discriminantPattern match (Result/Option)
// Compare: comparison operators (eq, ne, lt, le, gt, ge)
{
"@type": "duumbi:Compare",
"duumbi:op": "le",
"duumbi:left": { "@id": "duumbi:main/fib/entry/0" },
"duumbi:right": { "@type": "duumbi:Const", "value": 1 }
}
// Branch: if-else
{
"@type": "duumbi:Branch",
"duumbi:condition": { "@id": "duumbi:main/fib/entry/1" },
"duumbi:then_block": "duumbi:main/fib/then",
"duumbi:else_block": "duumbi:main/fib/else"
}
// Call: function call with arguments
{
"@type": "duumbi:Call",
"duumbi:function": "fibonacci",
"duumbi:args": [{ "@id": "duumbi:main/fib/else/0" }]
}
// Match: pattern matching on Result/Option
{
"@type": "duumbi:Match",
"duumbi:value": { "@id": "duumbi:main/main/entry/3" },
"duumbi:ok_block": "duumbi:main/main/ok_arm",
"duumbi:err_block": "duumbi:main/main/err_arm"
}
OpCranelift IRDescription
Loaduse_varLoad variable value
Storedef_varStore to variable
// Store: assign a value to a variable
{
"@type": "duumbi:Store",
"duumbi:name": "counter",
"duumbi:value": { "@type": "duumbi:Const", "value": 0 }
}
// Load: read a variable
{ "@type": "duumbi:Load", "duumbi:name": "counter" }
OpCranelift IRDescription
Printcall duumbi_print_*Print i64, f64, or bool
PrintStringcall duumbi_print_stringPrint string
// Print: output an integer to stdout
{
"@type": "duumbi:Print",
"duumbi:value": { "@id": "duumbi:main/main/entry/2" }
}
OpRuntime functionDescription
ConstStringduumbi_string_newCreate string constant
StringConcatduumbi_string_concatConcatenate strings
StringEqualsduumbi_string_equalsString equality
StringCompareduumbi_string_compareLexicographic comparison
StringLengthduumbi_string_lenString length
StringSliceduumbi_string_sliceSubstring extraction
StringContainsduumbi_string_containsSubstring search
StringFindduumbi_string_findFind index of substring
StringFromI64duumbi_string_from_i64Integer to string
// ConstString: create a string literal
{ "@type": "duumbi:ConstString", "value": "hello, world" }
// StringConcat: join two strings
{
"@type": "duumbi:StringConcat",
"duumbi:left": { "@id": "duumbi:main/main/entry/0" },
"duumbi:right": { "@id": "duumbi:main/main/entry/1" }
}
// StringSlice: extract substring (start, end indices)
{
"@type": "duumbi:StringSlice",
"duumbi:value": { "@id": "duumbi:main/main/entry/0" },
"duumbi:start": 0,
"duumbi:end": 5
}
OpRuntime functionDescription
ArrayNewduumbi_array_newCreate empty array
ArrayPushduumbi_array_pushPush element
ArrayGetduumbi_array_getGet element by index
ArraySetduumbi_array_setSet element by index
ArrayLengthduumbi_array_lenArray length
// ArrayNew: create typed empty array
{ "@type": "duumbi:ArrayNew", "duumbi:element_type": "i64" }
// ArrayPush: append element (mutates array)
{
"@type": "duumbi:ArrayPush",
"duumbi:array": { "@id": "duumbi:main/main/entry/0" },
"duumbi:value": { "@type": "duumbi:Const", "value": 42 }
}
OpRuntime functionDescription
StructNewduumbi_struct_newCreate struct
FieldGetduumbi_struct_field_getGet field value
FieldSetduumbi_struct_field_setSet field value
// StructNew: create a named struct
{
"@type": "duumbi:StructNew",
"duumbi:struct_name": "Point",
"duumbi:fields": {
"x": { "@type": "duumbi:Const", "value": 10 },
"y": { "@type": "duumbi:Const", "value": 20 }
}
}
// FieldGet: access a field
{
"@type": "duumbi:FieldGet",
"duumbi:value": { "@id": "duumbi:main/main/entry/0" },
"duumbi:field": "x"
}
OpRuntime functionDescription
Allocduumbi_allocAllocate value
Movepointer copyTransfer ownership
Borrowpointer copyImmutable borrow (&T)
BorrowMutpointer copyMutable borrow (&mut T)
Dropduumbi_*_freeDeallocate

See the Ownership Model guide for detailed rules and examples.

// Alloc: allocate a heap value
{
"@type": "duumbi:Alloc",
"duumbi:value": { "@type": "duumbi:ConstString", "value": "hello" }
}
// Borrow: create an immutable reference
{
"@type": "duumbi:Borrow",
"duumbi:source": { "@id": "duumbi:main/main/entry/0" }
}
// Drop: deallocate when done
{
"@type": "duumbi:Drop",
"duumbi:value": { "@id": "duumbi:main/main/entry/0" }
}
OpRuntime functionDescription
ResultOkduumbi_result_new_okCreate Ok value
ResultErrduumbi_result_new_errCreate Err value
ResultIsOkduumbi_result_is_okCheck if Ok
ResultUnwrapduumbi_result_unwrapUnwrap Ok value
ResultUnwrapErrduumbi_result_unwrap_errUnwrap Err value
OptionSomeduumbi_option_new_someCreate Some value
OptionNoneduumbi_option_new_noneCreate None
OptionIsSomeduumbi_option_is_someCheck if Some
OptionUnwrapduumbi_option_unwrapUnwrap Some value
// ResultOk: wrap a value in Ok
{
"@type": "duumbi:ResultOk",
"duumbi:value": { "@type": "duumbi:Const", "value": 42 }
}
// Match: pattern match on Result — exhaustive handling required
{
"@type": "duumbi:Match",
"duumbi:value": { "@id": "duumbi:main/main/entry/0" },
"duumbi:ok_block": "duumbi:main/main/ok_arm",
"duumbi:err_block": "duumbi:main/main/err_arm"
}

See the Error Codes reference for all validation errors.