Lya provides the following hooks.
-
sourceTransform(src)
: Apply a source transformation to the loaded library. Example analyses: uncomment.src
: String representation of the library- Expected
return
: a script representation of the library
-
onImport(caller, callee, name)
: Each time we load a library this hook is called. Usefull for dependency graphs. Analysis example: print-requirecaller
: the path of the module that loads the modulecalle
: the path of the loaded libraryname
: the name of the library
-
onRead(target, name, ...)
: Each time we read a value from an imported module this function is called. Example Analysis: read-write-executetarget
: The target object on which we get the property.name
: The name of the propertynameToStore
: The recommended name to use by Lya.currentModule
: The name of the module that calls the functiontypeClass
: Indicates which category the analysis belongs to (user-global, es-globals, node-globals etc)
-
onCallPre(target, thisArg, ...)
: Before the execution of a function this hook is called. Example analysis: profiling-relativetarget
: The target function to call.thisArg
: The value of this provided for the call to target.argumentsList
: An array-like object specifying the arguments with which target will be called.name
: The name of the functionnameToStore
: Recommended name to use for storing the result of the analysiscurrentModule
: The name of the module that calls the functiondeclareModule
: The name of the module where we declared the target functiontypeClass
: Indicates which category the analysis belongs to (user-global, es-globals, node-globals etc)
-
onCallPost(target, thisArg, ...)
: After the execution of a function this hooked is called. Extremly usefull for type analysis or time analysis. Example Analysis: simple-typestarget
: The target function to call.thisArg
: The value of this provided for the call to target.argumentsList
: An array-like object specifying the arguments with which target will be called.name
: The name of the functionnameToStore
: Recommended name to use for storing the result of the analysiscurrentModule
: The name of the module that calls the functiondeclareModule
: The name of the module where we declared the target functiontypeClass
: Indicates which category the analysis belongs to (user-global, es-globals, node-globals etc)result
: It contains the result of the target function execution.
-
onWrite(target, name, value, ...)
: This hook is called is called before we set a property on a object. Example Analysis: read-write-executetarget
: The target object on which to set the propertyname
: The name of the property to setvalue
: The value to setdeclareModule
: The name of the module where we declared the target functionparentName
: The name of the parent objectnameToStore
: Recommended name to use for storing the result of the analysis
-
onConstruct(target, args, currentName, nameToStore)
: We call this hook before the execution of a constructor.target
: The target function to callargs
: An array-like object specifying the arguments with which target should be calledcurrentName
: The name of the module where the constructor is callednameToStore
: Recommended name to use for storing the result of the analysis
-
onHas(target, prop, currentName, nameToStore)
: This method is called before you check if a property is in an object.target
: The target object in which to look for the propertyprop
: The property we look forcurrentName
: The name of the module where the constructor is callednameToStore
: Recommended name to use for storing the result of the analysis
-
onExit(data)
: Last call before program exit -- commonly used for flushing results. Example analyses: coarse-types.data
:- Expected
return
: None.
Lya provides the following utility function:
const getObjectInfo = (obj) => {
name: objName,
path: objPath,
}