org.luaj.vm
Class LValue

java.lang.Object
  extended by org.luaj.vm.LValue
Direct Known Subclasses:
LBoolean, LFunction, LNil, LNumber, LString, LTable, LThread, LUserData

public abstract class LValue
extends java.lang.Object


Field Summary
static LString TM_INDEX
          Metatable tag for intercepting table gets
static LString TM_METATABLE
          Metatable tag for intercepting table sets
static LString TM_MODE
          Metatable tag for setting table mode
static LString TM_NEWINDEX
          Metatable tag for intercepting table sets
 
Constructor Summary
LValue()
           
 
Method Summary
protected static LValue compareError(java.lang.Object typea, java.lang.Object typeb)
           
protected  void conversionError(java.lang.String target)
           
 java.lang.String id()
           
 boolean isClosure()
          Returns true if this is a lua closure, false otherwise
 boolean isFunction()
          Return true if this is a LFunction
 boolean isInteger()
          Return true if this value can be represented as an "int"
 boolean isNil()
          Return true if this value is LNil.NIL, false otherwise
 boolean isNumber()
          Returns true if this is or can be made into a number
 boolean isString()
          Return true if this is a lua string, meaning it is either a LString or LNumber,since all numbers are convertible to strings in lua
 boolean isTable()
          Return true if this is a LTable
 boolean isUserData()
          Returns true if this is an LUserData
 LString luaAsString()
          Get the value as a LString
 boolean luaBinCmpDouble(int opcode, double rhs)
           
 boolean luaBinCmpInteger(int opcode, int rhs)
           
 boolean luaBinCmpString(int opcode, LString rhs)
           
 boolean luaBinCmpUnknown(int opcode, LValue lhs)
           
 LValue luaBinOpDouble(int opcode, double m_value)
           
 LValue luaBinOpInteger(int opcode, int m_value)
           
 LValue luaBinOpUnknown(int opcode, LValue lhs)
           
 void luaConcatTo(java.io.ByteArrayOutputStream baos)
          Concatenate this value to a ByteArrayOutputStream
 LTable luaGetEnv(LTable d)
          Get the environment of the object if it is a closure, or d if not a closure.
 LTable luaGetMetatable()
          Valid for all types: get a metatable.
 LValue luaGetTable(LuaState vm, LValue key)
          Dispatch a gettable operation.
abstract  int luaGetType()
          Valid for all types: return the int value identifying the type of this value
 LString luaGetTypeName()
          Valid for all types: return the type of this value as an LString
 int luaLength()
          Built-in opcode LEN, for Strings and Tables
 boolean luaSetEnv(LTable t)
          Set the environment if a thread, or closure, and return true, otherwise return false
 LTable luaSetMetatable(LValue metatable)
          Valid for tables
 void luaSetTable(LuaState vm, LValue key, LValue val)
          Dispatch a settable operation.
 boolean luaStackCall(LuaState vm)
           
 LValue luaToNumber()
          Convert to a number if possible, or nil otherwise
 LValue luaUnaryMinus()
          Arithmetic negative
 boolean toJavaBoolean()
          Return value as a boolean
 java.lang.Boolean toJavaBoxedBoolean()
          Convert to a Boolean value
 java.lang.Byte toJavaBoxedByte()
          Convert to a Byte value
 java.lang.Character toJavaBoxedCharacter()
          Convert to a boxed Character value
 java.lang.Double toJavaBoxedDouble()
          Convert to a boxed Double value
 java.lang.Float toJavaBoxedFloat()
          Convert to a boxed Float value
 java.lang.Integer toJavaBoxedInteger()
          Convert to a boxed Integer value
 java.lang.Long toJavaBoxedLong()
          Convert to a boxed Long value
 java.lang.Short toJavaBoxedShort()
          Convert to a boxed Short value
 byte toJavaByte()
          Return value as a byte
 char toJavaChar()
          Return value as a char
 double toJavaDouble()
          Return value as a double
 float toJavaFloat()
          Return value as a float
 java.lang.Object toJavaInstance()
          Convert to a Java Object iff this is a LUserData value
 int toJavaInt()
          Return value as an integer
 long toJavaLong()
          Return value as a long
 short toJavaShort()
          Return value as a double
 java.lang.String toJavaString()
          Convert to a Java String
 java.lang.String toString()
          Override standard toString with lua String conversion by default
 LValue toStrongReference()
          Dereference a potentially weak reference, and return the value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TM_INDEX

public static final LString TM_INDEX
Metatable tag for intercepting table gets


TM_NEWINDEX

public static final LString TM_NEWINDEX
Metatable tag for intercepting table sets


TM_METATABLE

public static final LString TM_METATABLE
Metatable tag for intercepting table sets


TM_MODE

public static final LString TM_MODE
Metatable tag for setting table mode

Constructor Detail

LValue

public LValue()
Method Detail

conversionError

protected void conversionError(java.lang.String target)

compareError

protected static LValue compareError(java.lang.Object typea,
                                     java.lang.Object typeb)

id

public java.lang.String id()

isInteger

public boolean isInteger()
Return true if this value can be represented as an "int"


isNil

public boolean isNil()
Return true if this value is LNil.NIL, false otherwise


luaStackCall

public boolean luaStackCall(LuaState vm)

luaBinOpUnknown

public LValue luaBinOpUnknown(int opcode,
                              LValue lhs)

luaBinOpInteger

public LValue luaBinOpInteger(int opcode,
                              int m_value)

luaBinOpDouble

public LValue luaBinOpDouble(int opcode,
                             double m_value)

luaBinCmpUnknown

public boolean luaBinCmpUnknown(int opcode,
                                LValue lhs)

luaBinCmpString

public boolean luaBinCmpString(int opcode,
                               LString rhs)

luaBinCmpInteger

public boolean luaBinCmpInteger(int opcode,
                                int rhs)

luaBinCmpDouble

public boolean luaBinCmpDouble(int opcode,
                               double rhs)

luaSetTable

public void luaSetTable(LuaState vm,
                        LValue key,
                        LValue val)
Dispatch a settable operation. Default method delegates back to the vm for metatable processing.


luaGetTable

public LValue luaGetTable(LuaState vm,
                          LValue key)
Dispatch a gettable operation. Default method delegates back to the vm for metatable processing.


luaAsString

public LString luaAsString()
Get the value as a LString


toString

public java.lang.String toString()
Override standard toString with lua String conversion by default

Overrides:
toString in class java.lang.Object

luaUnaryMinus

public LValue luaUnaryMinus()
Arithmetic negative


luaLength

public int luaLength()
Built-in opcode LEN, for Strings and Tables


luaGetMetatable

public LTable luaGetMetatable()
Valid for all types: get a metatable. Only tables and userdata can have a different metatable per instance, though, other types are restricted to one metatable per type. Since metatables on non-tables can only be set through Java and not Lua, this function should be overridden for each value type as necessary.

Returns:
null if there is no meta-table

luaSetMetatable

public LTable luaSetMetatable(LValue metatable)
Valid for tables

Parameters:
the - new LTable, or null or LNil.NIL to reset the metatable to none
Returns:
this if unchanged, or new LTable if copied using weak table

luaGetType

public abstract int luaGetType()
Valid for all types: return the int value identifying the type of this value


luaGetTypeName

public LString luaGetTypeName()
Valid for all types: return the type of this value as an LString


toJavaString

public java.lang.String toJavaString()
Convert to a Java String


toJavaBoolean

public boolean toJavaBoolean()
Return value as a boolean


toJavaByte

public byte toJavaByte()
Return value as a byte


toJavaChar

public char toJavaChar()
Return value as a char


toJavaDouble

public double toJavaDouble()
Return value as a double


toJavaFloat

public float toJavaFloat()
Return value as a float


toJavaInt

public int toJavaInt()
Return value as an integer


toJavaLong

public long toJavaLong()
Return value as a long


toJavaShort

public short toJavaShort()
Return value as a double


toJavaBoxedBoolean

public java.lang.Boolean toJavaBoxedBoolean()
Convert to a Boolean value


toJavaBoxedByte

public java.lang.Byte toJavaBoxedByte()
Convert to a Byte value


toJavaBoxedCharacter

public java.lang.Character toJavaBoxedCharacter()
Convert to a boxed Character value


toJavaBoxedDouble

public java.lang.Double toJavaBoxedDouble()
Convert to a boxed Double value


toJavaBoxedFloat

public java.lang.Float toJavaBoxedFloat()
Convert to a boxed Float value


toJavaBoxedInteger

public java.lang.Integer toJavaBoxedInteger()
Convert to a boxed Integer value


toJavaBoxedLong

public java.lang.Long toJavaBoxedLong()
Convert to a boxed Long value


toJavaBoxedShort

public java.lang.Short toJavaBoxedShort()
Convert to a boxed Short value


toJavaInstance

public java.lang.Object toJavaInstance()
Convert to a Java Object iff this is a LUserData value


luaSetEnv

public boolean luaSetEnv(LTable t)
Set the environment if a thread, or closure, and return true, otherwise return false


luaGetEnv

public LTable luaGetEnv(LTable d)
Get the environment of the object if it is a closure, or d if not a closure.

Parameters:
d - global environment to return if this is not a closure

luaToNumber

public LValue luaToNumber()
Convert to a number if possible, or nil otherwise


toStrongReference

public LValue toStrongReference()
Dereference a potentially weak reference, and return the value


luaConcatTo

public void luaConcatTo(java.io.ByteArrayOutputStream baos)
Concatenate this value to a ByteArrayOutputStream


isString

public boolean isString()
Return true if this is a lua string, meaning it is either a LString or LNumber,since all numbers are convertible to strings in lua


isTable

public boolean isTable()
Return true if this is a LTable


isFunction

public boolean isFunction()
Return true if this is a LFunction


isUserData

public boolean isUserData()
Returns true if this is an LUserData


isNumber

public boolean isNumber()
Returns true if this is or can be made into a number


isClosure

public boolean isClosure()
Returns true if this is a lua closure, false otherwise



Copyright © 2007-2013 Luaj.org. All Rights Reserved.