Qore Programming Language Reference Manual 1.18.0
Loading...
Searching...
No Matches
Qore::ProgramControl Class Reference

The ProgramControl class provides safe information about a Qore program. More...

#include <QC_ProgramControl.dox.h>

Public Member Methods

nothing assignBreakpoint (Breakpoint bkpt)
 Assign Breakpoint instance to Program. If breakpoint has been assigned to an program then is unassigned in the first step.
 
 constructor ()
 Throws an exception to prevent objects of this class being created from script. More...
 
 copy ()
 Throws an exception to prevent objects of this class from being copied. More...
 
nothing deleteAllBreakpoints ()
 delete all breakpoints from instance
 
 destructor ()
 Dereferences the internal Program object and deletes the Qore object.
 
bool existsFunction (string name)
 Checks if a user function exists in the program object. More...
 
int findFunctionStatementId (string function, *list params)
 Find the first statement for function entry point. More...
 
list< hash< auto > > findFunctionVariants (string function)
 finds all variants of a function or class method and returns a list of the results More...
 
int findStatementId (string file, int line)
 Find statement related to position in file. More...
 
*hash< auto > getAllDefines ()
 Retrieves all parse defines in the current Program. More...
 
list< BreakpointgetBreakpoints ()
 get list of breakpoint assigned to program.
 
auto getDefine (string def)
 Retrieves the value of the given parse define in the current Program. More...
 
auto getGlobalVariable (string varname, *reference< bool > rexists)
 Returns a the value of the global variable identified by the first string argument. More...
 
hash< auto > getGlobalVars ()
 returns a hash of global variables More...
 
int getParseOptions ()
 Returns the current binary-or'ed parse option mask for the Program object. More...
 
int getProgramId ()
 Get program id. More...
 
*string getScriptDir ()
 Returns the current script directory as a string or NOTHING if not set. More...
 
*string getScriptName ()
 Returns the current script name as a string or NOTHING if not set. More...
 
*string getScriptPath ()
 Returns the current script directory and filename if known, otherwise returns NOTHING. More...
 
hash< string, hash< string, int > > getSourceFileNames ()
 Returns a list of file names registered to a statement when parsing source code. More...
 
hash< string, hash< string, int > > getSourceLabels ()
 Get list of label names which has been registered to a statement when parsing source code. More...
 
hash< StatementInfogetStatementIdInfo (int statementId, bool listBreakpoints=False)
 get information related to statement id More...
 
list< intgetThreadList ()
 returns a list of thread IDs active in this Program More...
 
TimeZone getTimeZone ()
 Returns the default local time zone for the object. More...
 
bool isDefined (string def)
 Returns True if the given parse define is defined in the current Program (does not have to have a value defined to return True), False if not. More...
 
nothing setGlobalVarValue (string name, auto value)
 set the value of a global variable More...
 

Static Public Member Methods

static list< ProgramControlgetAllPrograms ()
 Get instance of all programs. More...
 
static ProgramControl getProgram ()
 Get control for instance of current program. More...
 
static ProgramControl resolveProgramId (int programId)
 Get instance of program id. More...
 

Detailed Description

The ProgramControl class provides safe information about a Qore program.

Restrictions:
MUST HAVE: Qore::PO_ALLOW_DEBUGGER

The object is never instantiated in script but returned by a API function. The class provides only safe data non breaking security model.

See also
Program
Since
Qore 0.8.13

Member Function Documentation

◆ constructor()

Qore::ProgramControl::constructor ( )

Throws an exception to prevent objects of this class being created from script.

Exceptions
PROGRAM-CREATE-ERRORcopying ProgramControl objects is currently unsupported

◆ copy()

Qore::ProgramControl::copy ( )

Throws an exception to prevent objects of this class from being copied.

Exceptions
PROGRAM-COPY-ERRORcopying Program objects is currently unsupported

◆ existsFunction()

bool Qore::ProgramControl::existsFunction ( string  name)

Checks if a user function exists in the program object.

Code Flags:
RET_VALUE_ONLY

see Qore::Program::existsFunction "Program::existsFunction()"

◆ findFunctionStatementId()

int Qore::ProgramControl::findFunctionStatementId ( string  function,
*list  params 
)

Find the first statement for function entry point.

Parameters
functionname
paramsparam types to resolve particular variant
See also
ProgramControl::findStatementId()

◆ findFunctionVariants()

list< hash< auto > > Qore::ProgramControl::findFunctionVariants ( string  function)

finds all variants of a function or class method and returns a list of the results

Parameters
functionthe function or class method name; may also be namespace-justified
Returns
a list of hashes or nothing if the name cannot be resolved; when matched, each hash element has the following keys:
  • desc: a string description of the call which includes the name and the full text call signature
  • params: a list object that gives the params in a format that can be used by findFunctionStatementId

◆ findStatementId()

int Qore::ProgramControl::findStatementId ( string  file,
int  line 
)

Find statement related to position in file.

Parameters
filename where is looking for. Searching is done in three steps, in the first one is looking for full name match, in the second is looking for label full match (if exists) and in the third for end suffix match. File can by empty if program contains only one file. Beware of label formating, see Qore::Program::parse
lineto find statement. In case of multiple statements of line the first one is found
See also
ProgramControl::findFunctionStatementId()

◆ getAllDefines()

*hash< auto > Qore::ProgramControl::getAllDefines ( )

Retrieves all parse defines in the current Program.

see Qore::Program::getAllDefines "Program::getAllDefines()"

◆ getAllPrograms()

static list< ProgramControl > Qore::ProgramControl::getAllPrograms ( )
static

Get instance of all programs.

Restrictions:
MUST HAVE: Qore::PO_ALLOW_DEBUGGER
Code Flags:
RET_VALUE_ONLY

Use ProgramControl::resolveProgramId() to get instance

◆ getDefine()

auto Qore::ProgramControl::getDefine ( string  def)

Retrieves the value of the given parse define in the current Program.

see Qore::Program::getDefine "Program::getDefine()"

◆ getGlobalVariable()

auto Qore::ProgramControl::getGlobalVariable ( string  varname,
*reference< bool >  rexists 
)

Returns a the value of the global variable identified by the first string argument.

see Qore::Program::getGlobalVariable "Program::getGlobalVariable()"

◆ getGlobalVars()

hash< auto > Qore::ProgramControl::getGlobalVars ( )

returns a hash of global variables

Code Flags:
CONSTANT

see Qore::Program::getGlobalVars "Program::getGlobalVars()"

◆ getParseOptions()

int Qore::ProgramControl::getParseOptions ( )

Returns the current binary-or'ed parse option mask for the Program object.

see Qore::Program::getParseOptions "Program::getParseOptions()"

◆ getProgram()

static ProgramControl Qore::ProgramControl::getProgram ( )
static

Get control for instance of current program.

Restrictions:
MUST HAVE: Qore::PO_ALLOW_DEBUGGER
Code Flags:
RET_VALUE_ONLY

◆ getProgramId()

int Qore::ProgramControl::getProgramId ( )

Get program id.

Code Flags:
RET_VALUE_ONLY

see Qore::Program::getProgramId "Program::getProgramId()"

◆ getScriptDir()

*string Qore::ProgramControl::getScriptDir ( )

Returns the current script directory as a string or NOTHING if not set.

see Qore::Program::getScriptDir "Program::getScriptDir()"

◆ getScriptName()

*string Qore::ProgramControl::getScriptName ( )

Returns the current script name as a string or NOTHING if not set.

see Qore::Program::getScriptPath "Program::getScriptPath()"

◆ getScriptPath()

*string Qore::ProgramControl::getScriptPath ( )

Returns the current script directory and filename if known, otherwise returns NOTHING.

see Qore::Program::getScriptPath "Program::getScriptPath()"

◆ getSourceFileNames()

hash< string, hash< string, int > > Qore::ProgramControl::getSourceFileNames ( )

Returns a list of file names registered to a statement when parsing source code.

See also
ProgramControl::getSourceLabels()
Returns
a hash where keys are file names and the value is hash of labels, in this hash, the keys are label names and values are the label's section offset in the file.
Since
Qore 0.8.13.3

◆ getSourceLabels()

hash< string, hash< string, int > > Qore::ProgramControl::getSourceLabels ( )

Get list of label names which has been registered to a statement when parsing source code.

See also
ProgramControl::getSourceFileNames()
Returns
a hash where keys are file names and the value is hash of labels, in this hash, the keys are label names and values are the label's section offset in the file.
Since
Qore 0.8.13.3

◆ getStatementIdInfo()

hash< StatementInfo > Qore::ProgramControl::getStatementIdInfo ( int  statementId,
bool  listBreakpoints = False 
)

get information related to statement id

Parameters
statementId
listBreakpointslist also breakpoints assigned to statement, no effect if %no-debugging (since 0.9)
Returns
a hash of statement info
See also
ProgramControl::findStatementId() ProgramControl::findFunctionStatementId()

◆ getThreadList()

list< int > Qore::ProgramControl::getThreadList ( )

returns a list of thread IDs active in this Program

Code Flags:
CONSTANT

see Qore::Program::getThreadList "Program::getThreadList()"

◆ getTimeZone()

TimeZone Qore::ProgramControl::getTimeZone ( )

Returns the default local time zone for the object.

see Qore::Program::getTimeZone "Program::getTimeZone()"

◆ isDefined()

bool Qore::ProgramControl::isDefined ( string  def)

Returns True if the given parse define is defined in the current Program (does not have to have a value defined to return True), False if not.

see Qore::Program::isDefined "Program::isDefined()"

◆ resolveProgramId()

static ProgramControl Qore::ProgramControl::resolveProgramId ( int  programId)
static

Get instance of program id.

Restrictions:
MUST HAVE: Qore::PO_ALLOW_DEBUGGER
See also
ProgramControl::resolveProgramId()
Exceptions
PROGRAM-ERRORif the programId cannot identify ProgramControl instance

◆ setGlobalVarValue()

nothing Qore::ProgramControl::setGlobalVarValue ( string  name,
auto  value 
)

set the value of a global variable

see Qore::Program::setGlobalVars "Program::setGlobalVars()"