LuaObjectNoSemantics class
Represents a lua object for analyzing irregardless if it is a well-defined variable or value. This permits any visitor to look pass semantic errors and continue marching through the grapheme.
Constructors
Properties
- arity → int
-
Returns the arity of this object.
For lua table length, see tableSize;
no setterinherited
-
asMapEntry
→ MapEntry<
String, LuaObject> -
Convenience util to project this lua object
into a map entry keyed by its own id.
no setterinherited
- doc ↔ LuaDoc?
-
If this object has html content, it may
show up in the autodoc generation.
getter/setter pairinherited
- fields → LuaFieldsMap?
-
Returns the stored
_fieldsvalueno setterinherited - funcDef ↔ FuncExpr?
-
If this lua object is a function, it will have FuncExpr
node with information about its arguments.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
The variable name.
Note that if this instance is a value in a table,
then the table may know it by a different name. See fields.
finalinherited
- isCallable → bool
-
Query if this object's meta table has __call defined.
no setterinherited
- isFalsey → bool
-
Query the negation of isTruthy.
no setterinherited
- isFunc → bool
-
Query if this lua object has a Function stord in value.
For the metamethod
__callsee isCallable.no setterinherited - isNil → bool
-
A lua object is nil if both its value and fields
are nil.
no setterinherited
- isNotCallable → bool
-
Query if this object does not have __call defined in the meta table.
no setterinherited
- isNotFunc → bool
-
Query the negation of isFunc.
no setterinherited
- isNotTable → bool
-
Query the negation of isTable.
no setterinherited
- isNotThread → bool
-
Query the negation of isThread.
no setterinherited
- isPrintable → bool
-
Query if std "print" can print the value.
This is short for asking if the lua object is a table
or a function, which would return the address in the VM
at runtime for this lua obejct.
no setterinherited
- isRef → bool
-
Query if the stored value is of type LuaObject.
no setterinherited
- isTable → bool
-
A lua object is a table if its fields are non null.
no setterinherited
- isThread → bool
-
Query if the stored value is of type LuaThread.
no setterinherited
- isTruthy → bool
-
In lua, all values have a truthyness which
means they can be used in conditional statements.
If value is null or false, then the result is false.
All other values and the result is true.
If this lua object is a table, then the result is true.
no setterinherited
- isValue → bool
-
Query if the stored value is not a reference and the value is not null.
no setterinherited
- luaTypeInfo → String
-
Returns the lua equivalent runtime type
information. The result is the same as
what lua
type(x)would return. This is useful for quick type checking and printing helpful error messages.no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scope ↔ Scope?
-
If this lua object is a function, it will have Scope
to evaluate closures correctly.
getter/setter pairinherited
- skipSemanitcs → bool
-
A reference object to a LuaObjectNoSemantics type
should be treated transitively as a LuaObjectNoSemantics type.
no setterinherited
- tableSize → int
-
Begins at field "1" and increments this key by one
until no field is found with that key. Returns the
largest integer field found minus one.
This mimics lua's table len (#) behavior.
no setterinherited
- type → LuaType
-
Query the internal LuaType based on if the following
properties hold. Note that these are internal types
and not directly from the lua spec.
no setterinherited
- typeinfo → String
-
Returns the lua runtime type information.
Unlike vanilla lua, this runtime comes with
additional runtime semantics.
no setterinherited
- uses ↔ int
-
How often this object was read or written during evaluation.
Can be used for optimization and reporting unused variables.
getter/setter pairinherited
- value ↔ Object?
-
Bumps uses by one and
returns the stored
_fieldsif a table or_valueotherwise.getter/setter pairinherited
Methods
-
call(
) → Object? -
Attempts to execute the value closure if
isFunctionis true. Otherwise this throws an error.inherited -
deref(
) → LuaObject -
Unpacks a lua object if it holds a reference to another
lua object during runtime. Otherwise if isRef is false,
then it returns itself.
inherited
-
fieldValueAs<
T> (Object key, {T? or}) → T? -
Inspects the result of readField with
key. If the result's type is LuaObject, then it also inspects itsthis.value. If the underlying value type isT, then it is returned. If no underlying value type matchesT, thenoris returned.inherited -
getMetatable(
) → LuaObject -
Returns the
_metatableor LuaObject.nil.inherited -
hasField(
Object key) → bool -
Internal utility method to determine if this
unpacked lua object is a table and has a field with value
key.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onRead(
dynamic callback(Object)?) → void -
Whenever a lua object's fields or value is read, executes
callback.inherited -
onWrite(
dynamic callback(Object, Object?)?) → void -
Whenever a lua object's fields or value is modified (written),
executes
callback. If the lua object's storage is value, then the first argument ofcallbackwill be 'self'. Otherwise it is the string name of the field's key.inherited -
readField(
Object key) → Object? -
If this lua object is a table,
then reads
_fieldsbykeyand returns the value. Otherwise null is returned.inherited -
readMetatable(
String key) → Object? -
If this lua object has a meta table
thenr reads
_metatableby stringkeyand returns the value.inherited -
setMetatable(
LuaObject mt) → void -
Sets
_metatabletomtoverwriting any previous table.inherited -
tableInsert(
int index, LuaObject value) → LuaObject? -
Convenience method to implement std table
methods.
inherited
-
tableRemove(
int index) → LuaObject? -
Convenience method to implement std table
methods.
inherited
-
toRef(
) → LuaObject -
Creates and returns a LuaObject.ref instance
of itself.
inherited
-
toString(
) → String -
Due to a dart bug, I cannot throw if we're converting a table
or some other unknown data type to a string.
Instead, unhandled types return their variable name wrapped
in angle brackets <>. I'll perform strict type checks as-needed
for known types.
inherited
-
valueAs<
T> () → T? -
Inspects
this.value. If the type is LuaObject, inspects itsthis.value. If the underlying value type isT, then it is returned. If no underlying value type matchesT, thenullis returned.inherited -
valueAsInt(
) → int? -
If value is int, then returns int.
Otherwise, is null.
inherited
-
writeField(
Object key, Object? value) → Object? -
If this lua object is a table, then
it writes
valuetokeyand returns the fieldkey. Otherwise if the lua object is not a table, then null is returned.inherited -
writeFieldFrom(
LuaObject value) → LuaObject -
Given a LuaObject, adopt it as a field with the name
given by LuaObject.id.
inherited
-
writeFields(
LuaFieldsMap map) → void -
A convenience utility to write all fields from some input
map. This assumes you may need the name of the field to be different from any existing LuaObject.id in the entries.inherited -
writeFieldsFrom(
List< LuaObject> luaObjects) → void -
Given a list of LuaObject, adopt them as fields with
their name given by LuaObject.id.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited