ValueClass class
Example usage:
// Create a Point class with metamethods
final pointClass = ValueClass.create({
"__add": (a, b) => Value({
"x": (a.raw["x"] as num) + (b.raw["x"] as num),
"y": (a.raw["y"] as num) + (b.raw["y"] as num),
}),
"__tostring": (p) => "Point(${p.raw['x']}, ${p.raw['y']})",
});
ValueClass represents a constructor for creating new Value objects with a predefined metatable.
- Inheritance
-
- Object
- BuiltinFunction
- ValueClass
Constructors
-
ValueClass(Map<
String, dynamic> _metatable)
Properties
- canBytecodeInlineWithoutManagedFrame → bool
-
Whether the bytecode VM may bypass managed call-stack setup for this
builtin when no debug hook is active.
no setterinherited
- doc → FunctionDoc?
-
Optional documentation metadata for auto-generated library docs.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- interpreter → LuaRuntime?
-
The interpreter instance that this builtin function belongs to.
This is optional for backwards compatibility with existing functions.
finalinherited
- isBytecodeAssertBuiltin → bool
-
Whether this builtin is the base-library
assertand therefore eligible for the bytecode VM's dedicated assert-success fast path.no setterinherited - isBytecodeDebugGetLocalBuiltin → bool
-
Whether this builtin is
debug.getlocalfor bytecode-local fast paths.no setterinherited - isBytecodeDebugSetLocalBuiltin → bool
-
Whether this builtin is
debug.setlocalfor bytecode-local fast paths.no setterinherited - isBytecodeProtectedCallBuiltin → bool
-
Whether this builtin is
pcallfor bytecode protected-call fast paths.no setterinherited -
metamethods
→ Map<
String, dynamic> -
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
List< Object?> args) → Object? -
Executes the built-in function with the given arguments.
override
-
dartStringValue(
String raw) → Value -
Reuses runtime-cached wrappers for public Dart string results while
preserving the public
raw is Stringinterop contract.inherited -
fastCall0(
) → Object? -
Optional fixed-arity fast paths used by the bytecode VM hot call sites.
inherited
-
fastCall1(
Object? arg0) → Object? -
Optional single-argument fast path used by hot bytecode call sites.
inherited
-
fastCall2(
Object? arg0, Object? arg1) → Object? -
Optional two-argument fast path used by hot bytecode call sites.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
primitiveValue(
Object? raw) → Value -
Wraps a raw primitive value in a transient Value without creating a
permanent cache entry. This avoids the HashMap overhead in
Interpreter.constantPrimitiveValue for builtin results (e.g.
every distinct double from
math.sin) where caching never hits.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
create(
Map< String, dynamic> metamethods) → ValueClass - Creates a new ValueClass with the given metamethods
-
function(
Function value) → Value - Creates a new function with default function metamethods
-
meta(
[Map< String, dynamic> ? initial]) → Value -
number(
num value) → Value - Creates a new number with default number metamethods
-
string(
String value) → Value - Creates a new string with default string metamethods
-
table(
[dynamic initial]) → Value - Creates a new table (without default metatable, as per Lua specification)
-
userdata(
dynamic value) → Value - Creates a new userdata with default userdata metamethods