jit/util.funcinfo

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Also menu state)
 
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=util.funcinfo
 
|Parent=jit
 
 
|Description=Retrieves LuaJIT information about a given function, similarly to {{LibraryFunction|debug|getinfo}}. Possible table fields:
 
|Description=Retrieves LuaJIT information about a given function, similarly to {{LibraryFunction|debug|getinfo}}. Possible table fields:
 
* linedefined: as for {{LibraryFunction|debug|getinfo}}
 
* linedefined: as for {{LibraryFunction|debug|getinfo}}
Line 17: Line 15:
 
* loc: a string describing the source and currentline, like "<source>:<line>"
 
* loc: a string describing the source and currentline, like "<source>:<line>"
 
* ffid: the fast function id of the function (if it is one). In this case only upvalues above and addr below are valid
 
* ffid: the fast function id of the function (if it is one). In this case only upvalues above and addr below are valid
* addr: the address of the function (if it is not a Lua function). If it's a C function rather than a fast function, only upvalues above is valid*  
+
* addr: the address of the function (if it is not a Lua function). If it's a C function rather than a fast function, only upvalues above is valid*
 
|Realm=Shared and Menu
 
|Realm=Shared and Menu
 
|IsClass=No
 
|IsClass=No
Line 24: Line 22:
 
|type=function
 
|type=function
 
|name=func
 
|name=func
|desc=Function to retrieve info about.
+
|desc=Function or Proto to retrieve info about.
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 33: Line 31:
 
{{Ret
 
{{Ret
 
|type=table
 
|type=table
|name=info
+
|desc=Information about the supplied function/proto.
|desc=Information about the supplied function.
+
 
}}
 
}}
 
{{Example
 
{{Example

Latest revision as of 08:27, 30 October 2019

 jit.util.funcinfo( )

Contents

Description

Retrieves LuaJIT information about a given function, similarly to debug.getinfo. Possible table fields:

  • linedefined: as for debug.getinfo
  • lastlinedefined: as for debug.getinfo
  • params: the number of parameters the function takes
  • stackslots: the number of stack slots the function's local variable use
  • upvalues: the number of upvalues the function uses
  • bytecodes: the number of bytecodes it the compiled function
  • gcconsts: the number of garbage collectable constants
  • nconsts: the number of lua_Number (double) constants
  • children: Boolean representing whether the function creates closures
  • currentline: as for debug.getinfo
  • isvararg: if the function is a vararg function
  • source: as for debug.getinfo
  • loc: a string describing the source and currentline, like "<source>:<line>"
  • ffid: the fast function id of the function (if it is one). In this case only upvalues above and addr below are valid
  • addr: the address of the function (if it is not a Lua function). If it's a C function rather than a fast function, only upvalues above is valid*

Arguments

function func

Function or Proto to retrieve info about.

Arguments

number pos=0

Returns

table

Information about the supplied function/proto.

Examples

Example

Demonstrates output of this function.

PrintTable(jit.util.funcinfo(print))

local print = print
_G.print = function(...) print(...) end -- redefine print

PrintTable(jit.util.funcinfo(print))

Output:

-- First PrintTable output:
addr	=	1773317824
ffid	=	25
upvalues	=	1

-- Second PrintTable output:
linedefined	=	1
currentline	=	1
params	=	0
stackslots	=	2
source	=	@lua_run
lastlinedefined	=	1
children	=	false
upvalues	=	1
nconsts	=	0
isvararg	=	true
loc	=	lua_run:1
bytecodes	=	5
gcconsts	=	0
Personal tools
Navigation