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
-
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
- isFalsey → bool
-
Query the negation of isTruthy.
no setterinherited
- isFunc → bool
-
Query if this lua object is a table and has a field named '__call'.
no setterinherited
- isNil → bool
-
A lua object is nil if both its value and fields
are nil.
no setterinherited
- isNotFunc → bool
-
Query the negation of isFunc.
no setterinherited
- isNotTable → bool
-
Query the negation of isTable.
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
- 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
- length → int
-
Returns the arity of this object.
For lua table length, see tableSize;
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
- 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 LuaType based on if the following
properties hold:
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 find the metamethod '__call' and if found,
executes its closure.
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> (String 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 -
hasField(
String key) → bool -
Internal utility method to determine if this
unpacked lua object is a table and has a field named
key.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onRead(
dynamic callback(String)?) → void -
Whenever a lua object's fields or value is read, executes
callback.inherited -
onWrite(
dynamic callback(String, 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(
String key) → Object? -
If this lua object is a table,
unpacks
_fieldsand returns the value. Otherwise null is returned.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 check for string type conversion
as-needed instead.
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? -
Tries to cast
this.valueas num and performs a lossy integer division to obtain the leading part of the double. If the leading part is equal to the double representation, the value must be a whole number and therefore an integer. Otherwise, loss happened and it must be a real number and therefore a double. If the underlying type ofthis.valueis not num thennullis returned.inherited -
writeField(
String 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