QoreProgram.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
QoreProgram.h
Program Object Definition
Qore Programming Language
Copyright (C) 2003 - 2021 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Note that the Qore library is released under a choice of three open-source
licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
information.
*/
#ifndef _QORE_QOREPROGRAM_H
#define _QORE_QOREPROGRAM_H
#include <qore/AbstractPrivateData.h>
#include <qore/Restrictions.h>
//#include <qore/intern/qore_program_private.h>
// warnings - must correspond with the string order in QoreProgram.cpp
// new warnings must also be added as constants
#define QP_WARN_NONE 0
#define QP_WARN_WARNING_MASK_UNCHANGED (1 << 0)
#define QP_WARN_DUPLICATE_LOCAL_VARS (1 << 1)
#define QP_WARN_UNKNOWN_WARNING (1 << 2)
#define QP_WARN_UNDECLARED_VAR (1 << 3)
#define QP_WARN_DUPLICATE_GLOBAL_VARS (1 << 4)
#define QP_WARN_UNREACHABLE_CODE (1 << 5)
#define QP_WARN_NONEXISTENT_METHOD_CALL (1 << 6)
#define QP_WARN_INVALID_OPERATION (1 << 7)
#define QP_WARN_CALL_WITH_TYPE_ERRORS (1 << 8)
#define QP_WARN_RETURN_VALUE_IGNORED (1 << 9)
#define QP_WARN_DEPRECATED (1 << 10)
#define QP_WARN_EXCESS_ARGS (1 << 11)
#define QP_WARN_DUPLICATE_HASH_KEY (1 << 12)
#define QP_WARN_UNREFERENCED_VARIABLE (1 << 13)
#define QP_WARN_DUPLICATE_BLOCK_VARS (1 << 14)
#define QP_WARN_MODULE_ONLY (1 << 15)
#define QP_WARN_BROKEN_LOGIC_PRECEDENCE (1 << 16)
#define QP_WARN_INVALID_CATCH (1 << 17)
#define QP_WARN_ALL -1
#define QP_WARN_MODULES (QP_WARN_UNREACHABLE_CODE|QP_WARN_NONEXISTENT_METHOD_CALL|QP_WARN_INVALID_OPERATION|QP_WARN_CALL_WITH_TYPE_ERRORS|QP_WARN_RETURN_VALUE_IGNORED|QP_WARN_DUPLICATE_HASH_KEY|QP_WARN_DUPLICATE_BLOCK_VARS|QP_WARN_BROKEN_LOGIC_PRECEDENCE|QP_WARN_INVALID_CATCH)
#define QP_WARN_DEFAULT (QP_WARN_UNKNOWN_WARNING|QP_WARN_MODULES|QP_WARN_DEPRECATED)
enum BreakpointPolicy : unsigned char {
BKP_PO_NONE = 0,
BKP_PO_ACCEPT = 1,
BKP_PO_REJECT = 2,
};
DLLEXPORT extern const char** qore_warnings;
DLLEXPORT extern unsigned qore_num_warnings;
DLLEXPORT int get_warning_code(const char* str);
// forward references
class AbstractCallReferenceNode;
class LocalVar;
class ExceptionSink;
class QoreListNode;
class QoreNamespace;
class RootQoreNamespace;
class QoreStringNode;
class QoreHashNode;
class FunctionCallNode;
class AbstractStatement;
class UnresolvedProgramCallReferenceNode;
class Var;
class LVList;
class UserFunctionVariant;
class QoreParseTypeInfo;
class ParamList;
class AbstractQoreZoneInfo;
class qore_program_private;
class AbstractQoreProgramExternalData;
class QoreBreakpoint;
class AbstractQoreFunctionVariant;
class QoreRWLock;
class QoreExternalFunction;
class QoreExternalGlobalVar;
class QoreExternalConstant;
typedef std::list<QoreBreakpoint*> bkp_list_t;
struct QoreBreakpointList_t : public bkp_list_t {
DLLEXPORT QoreBreakpointList_t();
// dereferences all breakpoints and clears the list
DLLEXPORT ~QoreBreakpointList_t();
};
class QoreProgram : public AbstractPrivateData {
friend class qore_program_private_base;
friend class qore_program_private;
friend class qore_debug_program_private;
friend struct ThreadLocalProgramData;
private:
qore_program_private* priv;
DLLLOCAL QoreProgram(const QoreProgram&);
DLLLOCAL QoreProgram& operator=(const QoreProgram&);
protected:
DLLLOCAL virtual ~QoreProgram();
public:
DLLEXPORT QoreProgram();
DLLEXPORT QoreProgram(int64 parse_options);
DLLEXPORT QoreValue callFunction(const char* name, const QoreListNode* args, ExceptionSink* xsink);
DLLEXPORT QoreValue run(ExceptionSink* xsink);
DLLEXPORT QoreValue runTopLevel(ExceptionSink* xsink);
DLLEXPORT void parseFileAndRun(const char* filename);
DLLEXPORT void parseAndRun(FILE *fp, const char* name);
DLLEXPORT void parseAndRun(const char* str, const char* name);
DLLEXPORT void runClass(const char* classname, ExceptionSink* xsink);
DLLEXPORT void parseFileAndRunClass(const char* filename, const char* classname);
DLLEXPORT void parseAndRunClass(FILE *fp, const char* name, const char* classname);
DLLEXPORT void parseAndRunClass(const char* str, const char* name, const char* classname);
DLLEXPORT void parse(FILE *fp, const char* name, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
DLLEXPORT void parse(const QoreString* str, const QoreString* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
DLLEXPORT void parse(const QoreString* str, const QoreString* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink, int warn_mask, const QoreString* source, int offset);
DLLEXPORT void parse(const char* str, const char* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
DLLEXPORT void parse(const char* str, const char* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink, int warn_mask, const char* source, int offset);
DLLEXPORT void parseFile(const char* filename, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL, bool only_first_except = false);
DLLEXPORT void parsePending(const char* code, const char* label, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
DLLEXPORT void parsePending(const char* code, const char* label, ExceptionSink* xsink, ExceptionSink* warn_sink, int warn_mask, const char* source, int offset);
DLLEXPORT void parsePending(const QoreString* str, const QoreString* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
DLLEXPORT void parsePending(const QoreString* str, const QoreString* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink, int warn_mask, const QoreString* source, int offset);
DLLEXPORT void parseCommit(ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
DLLEXPORT int parseRollback(ExceptionSink* xsink);
DLLEXPORT bool existsFunction(const char* name);
using AbstractPrivateData::deref;
DLLEXPORT virtual void deref(ExceptionSink* xsink);
DLLEXPORT QoreProgram* programRefSelf() const;
DLLEXPORT void lockOptions();
DLLEXPORT void setExecClass(const char* ecn = 0);
DLLEXPORT void parseSetParseOptions(int64 po);
DLLEXPORT void parseDisableParseOptions(int64 po);
DLLEXPORT void waitForTermination();
DLLEXPORT void waitForTerminationAndDeref(ExceptionSink* xsink);
DLLEXPORT QoreNamespace* getQoreNS() const;
DLLEXPORT RootQoreNamespace* getRootNS() const;
DLLEXPORT int setWarningMask(int wm);
DLLEXPORT int enableWarning(int code);
DLLEXPORT int disableWarning(int code);
DLLEXPORT int getParseOptions() const;
DLLEXPORT int64 getParseOptions64() const;
DLLEXPORT void setParseOptions(int64 po, ExceptionSink* xsink);
DLLEXPORT void disableParseOptions(int64 po, ExceptionSink* xsink);
DLLEXPORT void replaceParseOptions(int64 po, ExceptionSink* xsink);
DLLEXPORT QoreListNode* getUserFunctionList();
DLLEXPORT bool checkWarning(int code) const;
DLLEXPORT int getWarningMask() const;
DLLEXPORT bool checkFeature(const char* f) const;
DLLEXPORT QoreListNode* getFeatureList() const;
DLLEXPORT QoreStringNode* getScriptName() const;
DLLEXPORT QoreStringNode* getScriptPath() const;
DLLEXPORT QoreStringNode* getScriptDir() const;
DLLEXPORT void setScriptPath(const char* path);
DLLEXPORT QoreValue getGlobalVariableValue(const char* var, bool &found) const;
DLLEXPORT QoreValue getGlobalVariableVal(const char* var, bool &found) const;
// retrieves the time zone setting for the program
DLLEXPORT const AbstractQoreZoneInfo *currentTZ() const;
// sets the program's time zone
DLLEXPORT void setTZ(const AbstractQoreZoneInfo *n_TZ);
DLLEXPORT void addFeature(const char* name);
DLLEXPORT void parseSetTimeZone(const char* zone);
DLLEXPORT void parseDefine(const char* str, QoreValue val);
DLLEXPORT void parseDefine(const char* str, const char* val);
// @deprecated use parseCmdLineDefines(ExceptionSink& xs, ExceptionSink& ws, int w, const std::map<std::string, std::string>& defmap) instead
DLLEXPORT void parseCmdLineDefines(const std::map<std::string, std::string> defmap, ExceptionSink& xs, ExceptionSink& ws, int w);
DLLEXPORT void parseCmdLineDefines(ExceptionSink& xs, ExceptionSink& ws, int w, const std::map<std::string, std::string>& defmap);
DLLEXPORT void setExternalData(const char* owner, AbstractQoreProgramExternalData* pud);
DLLEXPORT AbstractQoreProgramExternalData* getExternalData(const char* owner) const;
DLLEXPORT AbstractQoreProgramExternalData* removeExternalData(const char* owner);
DLLEXPORT QoreHashNode* getGlobalVars() const;
DLLEXPORT int setGlobalVarValue(const char* name, QoreValue val, ExceptionSink* xsink);
// finds a function or class method variant if possible
DLLEXPORT const AbstractQoreFunctionVariant* runtimeFindCall(const char* name, const QoreListNode* params, ExceptionSink* xsink) const;
// finds all variants of a function or class method and returns a list of the results
DLLEXPORT QoreListNode* runtimeFindCallVariants(const char* name, ExceptionSink* xsink) const;
DLLEXPORT QoreListNode* getThreadList() const;
DLLEXPORT const QoreClass* findClass(const char* path, ExceptionSink* xsink) const;
DLLEXPORT class_vec_t findAllClassesRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
DLLEXPORT hashdecl_vec_t findAllHashDeclsRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
DLLEXPORT func_vec_t findAllFunctionsRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
DLLEXPORT ns_vec_t findAllNamespacesRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
DLLEXPORT gvar_vec_t findAllGlobalVarsRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
DLLEXPORT const_vec_t findAllNamespaceConstantsRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
DLLEXPORT const QoreExternalFunction* findFunction(const char* path) const;
DLLEXPORT const TypedHashDecl* findHashDecl(const char* path, const QoreNamespace*& pns) const;
DLLEXPORT QoreNamespace* findNamespace(const QoreString& path);
DLLEXPORT const QoreNamespace* findNamespace(const QoreString& path) const;
DLLEXPORT const QoreExternalGlobalVar* findGlobalVar(const char* path, const QoreNamespace*& pns) const;
DLLEXPORT const QoreExternalConstant* findNamespaceConstant(const char* path, const QoreNamespace*& pns) const;
DLLEXPORT void depRef();
DLLEXPORT void depDeref();
DLLEXPORT QoreHashNode* getThreadData();
DLLEXPORT int issueModuleCmd(const char* module, const char* cmd, ExceptionSink* xsink);
DLLLOCAL QoreProgram(QoreProgram* pgm, int64 po, bool ec = false, const char* ecn = nullptr);
DLLLOCAL LocalVar *createLocalVar(const char* name, const QoreTypeInfo *typeInfo);
// returns 0 if a "requires" exception has already occurred
DLLLOCAL ExceptionSink* getParseExceptionSink();
DLLLOCAL void addFile(char* f);
DLLLOCAL QoreListNode* getVarList();
DLLLOCAL void parseSetIncludePath(const char* path);
DLLLOCAL const char* parseGetIncludePath() const;
/* for run-time module loading; the parse lock must be grabbed
before loading new modules - note this should only be assigned
to an AutoLock or SafeLocker object!
*/
DLLLOCAL QoreThreadLock *getParseLock();
DLLLOCAL const LVList* getTopLevelLVList() const;
DLLLOCAL const char* parseGetScriptDir() const;
// can only be called while parsing from the same thread doing the parsing
DLLLOCAL bool parseExceptionRaised() const;
// TODO: implement !
DLLEXPORT QoreValue getLocalVariableVal(const char* var, bool &found) const;
DLLEXPORT void assignBreakpoint(QoreBreakpoint *bkpt, ExceptionSink *xsink);
DLLEXPORT void deleteAllBreakpoints();
DLLEXPORT void getBreakpoints(QoreBreakpointList_t &bkptList);
DLLEXPORT void getStatementBreakpoints(const AbstractStatement* statement, QoreBreakpointList_t &bkptList);
DLLEXPORT AbstractStatement* findStatement(const char* fileName, int line) const;
DLLEXPORT AbstractStatement* findFunctionStatement(const char* functionName, const QoreListNode* params, ExceptionSink* xsink) const;
DLLEXPORT unsigned long getStatementId(const AbstractStatement* statement) const;
DLLEXPORT AbstractStatement* resolveStatementId(unsigned long statementId) const;
DLLEXPORT QoreHashNode* getSourceFileNames(ExceptionSink* xsink) const;
DLLEXPORT QoreHashNode* getSourceLabels(ExceptionSink* xsink) const;
DLLEXPORT unsigned getProgramId() const;
DLLEXPORT static QoreProgram* resolveProgramId(unsigned programId);
DLLEXPORT void registerQoreObject(QoreObject *o, ExceptionSink* xsink) const;
DLLEXPORT void unregisterQoreObject(QoreObject *o, ExceptionSink* xsink) const;
DLLEXPORT QoreObject* findQoreObject() const;
DLLEXPORT static QoreObject* getQoreObject(QoreProgram* pgm);
DLLEXPORT static QoreListNode* getAllQoreObjects(ExceptionSink* xsink);
DLLEXPORT bool checkAllowDebugging(ExceptionSink* xsink);
};
class QoreProgramHelper {
private:
QoreProgram* pgm;
ExceptionSink& xsink;
public:
DLLEXPORT QoreProgramHelper(ExceptionSink& xs);
DLLEXPORT QoreProgramHelper(int64 parse_options, ExceptionSink& xs);
DLLEXPORT ~QoreProgramHelper();
DLLEXPORT QoreProgram* operator->();
DLLEXPORT QoreProgram* operator*();
};
class CurrentProgramRuntimeExternalParseContextHelper {
public:
DLLEXPORT CurrentProgramRuntimeExternalParseContextHelper();
DLLEXPORT ~CurrentProgramRuntimeExternalParseContextHelper();
DLLEXPORT operator bool() const;
private:
bool valid = true;
// not implemented
CurrentProgramRuntimeExternalParseContextHelper(const CurrentProgramRuntimeExternalParseContextHelper&) = delete;
void* operator new(size_t) = delete;
};
class QoreProgramContextHelper {
public:
DLLEXPORT QoreProgramContextHelper(QoreProgram* pgm);
DLLEXPORT ~QoreProgramContextHelper();
private:
QoreProgram* old_pgm;
// not implemented
QoreProgramContextHelper(const QoreProgramContextHelper&) = delete;
void* operator new(size_t) = delete;
};
class AbstractQoreProgramExternalData {
public:
DLLEXPORT virtual ~AbstractQoreProgramExternalData();
virtual AbstractQoreProgramExternalData* copy(QoreProgram* pgm) const = 0;
virtual void init();
virtual void doDeref() = 0;
};
typedef std::list<AbstractStatement*> AbstractStatementList_t;
typedef std::list<int> TidList_t;
class QoreBreakpoint : public AbstractPrivateData {
private:
qore_program_private* pgm;
AbstractStatementList_t statementList;
typedef std::map<int/*tid*/, int/*count*/> TidMap_t;
TidMap_t tidMap;
QoreObject* qo; // reference to Qore script object, it's private object but we cannot
static QoreRWLock lck_breakpoint; // to protect breakpoint manipulation
static QoreBreakpointList_t breakpointList;
static volatile unsigned breakpointIdCounter; // to generate breakpointId
unsigned breakpointId;
DLLLOCAL void unassignAllStatements();
DLLLOCAL bool isStatementAssigned(const AbstractStatement *statement) const;
DLLLOCAL bool checkPgm(ExceptionSink* xsink) const;
friend class qore_program_private;
friend class AbstractStatement;
protected:
DLLLOCAL virtual ~QoreBreakpoint();
DLLLOCAL virtual bool checkBreak() const;
public:
bool enabled;
BreakpointPolicy policy;
DLLEXPORT QoreBreakpoint();
DLLEXPORT QoreBreakpoint& operator=(const QoreBreakpoint& other);
DLLEXPORT void assignProgram(QoreProgram *new_pgm, ExceptionSink* xsink);
/* Get assigned program to breakpoint
*
*/
DLLEXPORT QoreProgram* getProgram() const;
DLLEXPORT void assignStatement(AbstractStatement* statement, ExceptionSink* xsink);
DLLEXPORT void unassignStatement(AbstractStatement* statement, ExceptionSink* xsink);
DLLEXPORT void getStatements(AbstractStatementList_t &statList, ExceptionSink* xsink);
DLLEXPORT QoreListNode* getStatementIds(ExceptionSink* xsink);
DLLEXPORT AbstractStatement* resolveStatementId(unsigned long statementId, ExceptionSink* xsink) const;
DLLEXPORT void getThreadIds(TidList_t &tidList, ExceptionSink* xsink);
DLLEXPORT void setThreadIds(TidList_t tidList, ExceptionSink* xsink);
DLLEXPORT void addThreadId(int tid, ExceptionSink* xsink);
DLLEXPORT void removeThreadId(int tid, ExceptionSink* xsink);
DLLEXPORT bool isThreadId(int tid, ExceptionSink* xsink);
DLLEXPORT void clearThreadIds(ExceptionSink* xsink);
DLLEXPORT unsigned getBreakpointId() const;
DLLEXPORT static QoreBreakpoint* resolveBreakpointId(unsigned breakpointId);
DLLEXPORT void setQoreObject(QoreObject* n_qo);
DLLEXPORT QoreObject* getQoreObject();
};
class QoreExternalProgramContextHelper {
public:
DLLEXPORT QoreExternalProgramContextHelper(ExceptionSink* xsink, QoreProgram* pgm);
DLLEXPORT ~QoreExternalProgramContextHelper();
private:
class ProgramThreadCountContextHelper* priv;
};
class QoreExternalProgramCallContextHelper {
public:
DLLEXPORT QoreExternalProgramCallContextHelper(QoreProgram* pgm);
DLLEXPORT ~QoreExternalProgramCallContextHelper();
private:
class QoreExternalProgramCallContextHelperPriv* priv;
};
#endif // _QORE_QOREPROGRAM_H
QoreProgram::deleteAllBreakpoints
DLLEXPORT void deleteAllBreakpoints()
QoreProgram::waitForTermination
DLLEXPORT void waitForTermination()
this call blocks until the program&#39;s last thread terminates
QoreProgram::getThreadList
DLLEXPORT QoreListNode * getThreadList() const
returns a list of threads active in this Program object
QoreProgramHelper::~QoreProgramHelper
DLLEXPORT ~QoreProgramHelper()
waits until all background threads in the Qore library have terminated and until the QoreProgram obje...
QoreProgram::lockOptions
DLLEXPORT void lockOptions()
locks parse options so they may not be changed
QoreProgram::getWarningMask
DLLEXPORT int getWarningMask() const
returns the warning mask
QoreProgram::depRef
DLLEXPORT void depRef()
incremements the weak reference count for the program object
QoreBreakpoint::getStatementIds
DLLEXPORT QoreListNode * getStatementIds(ExceptionSink *xsink)
QoreProgram::unregisterQoreObject
DLLEXPORT void unregisterQoreObject(QoreObject *o, ExceptionSink *xsink) const
unregister link to Qore script object
QoreBreakpoint::assignProgram
DLLEXPORT void assignProgram(QoreProgram *new_pgm, ExceptionSink *xsink)
QoreProgram::parsePending
DLLEXPORT void parsePending(const char *code, const char *label, ExceptionSink *xsink, ExceptionSink *warn_sink=0, int warn_mask=QP_WARN_ALL)
parses code from the given string but does not commit changes to the QoreProgram
QoreProgram::addFeature
DLLEXPORT void addFeature(const char *name)
manually add the feature to the program
CurrentProgramRuntimeExternalParseContextHelper
allows for the parse lock for the current program to be acquired by binary modules ...
Definition: QoreProgram.h:935
AbstractQoreProgramExternalData::copy
virtual AbstractQoreProgramExternalData * copy(QoreProgram *pgm) const =0
For reference-counted classes, returns the same object with the reference count incremented.
QoreProgram::findAllNamespacesRegex
DLLEXPORT ns_vec_t findAllNamespacesRegex(const QoreString &pattern, int re_opts, ExceptionSink *xsink) const
returns a list of all namespaces that match the pattern
QoreExternalConstant
external wrapper class for constants
Definition: QoreReflection.h:200
QoreProgram::findFunction
DLLEXPORT const QoreExternalFunction * findFunction(const char *path) const
search for the given function in the program; can be a simple function name or a namespace-prefixed p...
QoreProgram::findClass
DLLEXPORT const QoreClass * findClass(const char *path, ExceptionSink *xsink) const
search for the given class in the program; can be a simple class name or a namespace-prefixed path (e...
QoreExternalProgramContextHelper::QoreExternalProgramContextHelper
DLLEXPORT QoreExternalProgramContextHelper(ExceptionSink *xsink, QoreProgram *pgm)
try to attach to the given program, if not possible, then a Qore-language exception is thrown ...
QoreHashNode
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:50
QoreProgram::getScriptDir
DLLEXPORT QoreStringNode * getScriptDir() const
returns the script directory, if known (0 if not)
QoreProgram::resolveProgramId
static DLLEXPORT QoreProgram * resolveProgramId(unsigned programId)
get the program from program id
QoreProgram::~QoreProgram
virtual DLLLOCAL ~QoreProgram()
the destructor is private in order to prohibit the object from being allocated on the stack ...
QoreExternalProgramCallContextHelper
allows the program call context to be set by external modules
Definition: QoreProgram.h:1146
QoreProgram::findNamespace
DLLEXPORT QoreNamespace * findNamespace(const QoreString &path)
search for the given namespace in the program; can be a simple namespace name or a namespace-prefixed...
QoreExternalProgramContextHelper
allows a program to be used and guarantees that it will stay valid until the destructor is run if suc...
Definition: QoreProgram.h:1131
QoreProgram::waitForTerminationAndDeref
DLLEXPORT void waitForTerminationAndDeref(ExceptionSink *xsink)
this call blocks until the program&#39;s last thread terminates, and then calls QoreProgram::deref() ...
AbstractPrivateData
the base class for all data to be used as private data of Qore objects
Definition: AbstractPrivateData.h:44
QoreProgramContextHelper::QoreProgramContextHelper
DLLEXPORT QoreProgramContextHelper(QoreProgram *pgm)
sets the current Program context
Restrictions.h
QoreProgram::setExecClass
DLLEXPORT void setExecClass(const char *ecn=0)
sets the name of the application class to be executed (instantiated) instead of top-level code ...
QoreBreakpoint::resolveStatementId
DLLEXPORT AbstractStatement * resolveStatementId(unsigned long statementId, ExceptionSink *xsink) const
QoreProgram::run
DLLEXPORT QoreValue run(ExceptionSink *xsink)
runs the program (instantiates the program class if a program class has been set) and returns the ret...
QoreProgram::findAllClassesRegex
DLLEXPORT class_vec_t findAllClassesRegex(const QoreString &pattern, int re_opts, ExceptionSink *xsink) const
returns a list of all classes that match the pattern
QoreBreakpoint
Class implementing breakpoint for debugging.
Definition: QoreProgram.h:1020
QoreProgram::runtimeFindCallVariants
DLLEXPORT QoreListNode * runtimeFindCallVariants(const char *name, ExceptionSink *xsink) const
QoreProgram::callFunction
DLLEXPORT QoreValue callFunction(const char *name, const QoreListNode *args, ExceptionSink *xsink)
calls a function from the function name and returns the return value
QoreProgram::getGlobalVariableVal
DLLEXPORT QoreValue getGlobalVariableVal(const char *var, bool &found) const
returns the value of the global variable given (do not include the "$" symbol), the caller owns the r...
QoreProgram::programRefSelf
DLLEXPORT QoreProgram * programRefSelf() const
references "this" and returns a non-const pointer to itself
QoreProgram::findAllNamespaceConstantsRegex
DLLEXPORT const_vec_t findAllNamespaceConstantsRegex(const QoreString &pattern, int re_opts, ExceptionSink *xsink) const
returns a list of all namespace constants that match the pattern
AbstractQoreProgramExternalData::~AbstractQoreProgramExternalData
virtual DLLEXPORT ~AbstractQoreProgramExternalData()
Destroys the object.
QoreProgram::findGlobalVar
DLLEXPORT const QoreExternalGlobalVar * findGlobalVar(const char *path, const QoreNamespace *&pns) const
search for the given global variable in the program; can be a simple function name or a namespace-pre...
QoreProgram::getProgramId
DLLEXPORT unsigned getProgramId() const
get the program id
QoreProgram::getRootNS
DLLEXPORT RootQoreNamespace * getRootNS() const
returns a pointer to the root namespace
QoreProgram::getStatementBreakpoints
DLLEXPORT void getStatementBreakpoints(const AbstractStatement *statement, QoreBreakpointList_t &bkptList)
QoreNamespace
contains constants, classes, and subnamespaces in QoreProgram objects
Definition: QoreNamespace.h:65
QoreProgramHelper::operator*
DLLEXPORT QoreProgram * operator*()
returns the QoreProgram object being managed
QoreProgram::depDeref
DLLEXPORT void depDeref()
dereferences a weak reference for the program object
QoreProgramContextHelper::~QoreProgramContextHelper
DLLEXPORT ~QoreProgramContextHelper()
restores the previous Program context
QoreProgram::parseFileAndRun
DLLEXPORT void parseFileAndRun(const char *filename)
parses the given filename and runs the file
AbstractQoreProgramExternalData::init
virtual void init()
Called after copy() on the new object.
QoreProgramContextHelper
allows for external modules to set the current Program context explicitly
Definition: QoreProgram.h:957
CurrentProgramRuntimeExternalParseContextHelper::~CurrentProgramRuntimeExternalParseContextHelper
DLLEXPORT ~CurrentProgramRuntimeExternalParseContextHelper()
releases the parse lock for the current program
QoreBreakpoint::assignStatement
DLLEXPORT void assignStatement(AbstractStatement *statement, ExceptionSink *xsink)
QoreBreakpoint::policy
BreakpointPolicy policy
Definition: QoreProgram.h:1047
QoreBreakpoint::setThreadIds
DLLEXPORT void setThreadIds(TidList_t tidList, ExceptionSink *xsink)
QoreProgram::setParseOptions
DLLEXPORT void setParseOptions(int64 po, ExceptionSink *xsink)
sets the parse options and adds Qore-language exception information if an error occurs ...
QoreProgram::findAllHashDeclsRegex
DLLEXPORT hashdecl_vec_t findAllHashDeclsRegex(const QoreString &pattern, int re_opts, ExceptionSink *xsink) const
returns a list of all typed hashes (hashdecls) that match the pattern
AbstractCallReferenceNode
base class for call references, reference-counted, dynamically allocated only
Definition: CallReferenceNode.h:39
QoreProgram::getFeatureList
DLLEXPORT QoreListNode * getFeatureList() const
returns a list of features in the program object
QoreProgram::findNamespaceConstant
DLLEXPORT const QoreExternalConstant * findNamespaceConstant(const char *path, const QoreNamespace *&pns) const
search for the given namespace constant in the program; can be a simple function name or a namespace-...
QoreProgramHelper
safely manages QoreProgram objects; note the the destructor will block until all background threads i...
Definition: QoreProgram.h:908
CurrentProgramRuntimeExternalParseContextHelper::CurrentProgramRuntimeExternalParseContextHelper
DLLEXPORT CurrentProgramRuntimeExternalParseContextHelper()
acquires the parse lock; if already acquired by another thread, then this call blocks until the lock ...
QoreProgram::parseSetTimeZone
DLLEXPORT void parseSetTimeZone(const char *zone)
sets the time zone during parsing
QoreBreakpoint::checkBreak
virtual DLLLOCAL bool checkBreak() const
check if program flow should be interrupted
QoreString
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:81
QoreStringNode
Qore&#39;s string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
QoreProgram::parseAndRun
DLLEXPORT void parseAndRun(FILE *fp, const char *name)
parses the given file and runs the file
getProgram
DLLEXPORT QoreProgram * getProgram()
returns the current QoreProgram
QoreProgram::getUserFunctionList
DLLEXPORT QoreListNode * getUserFunctionList()
returns a list of all user functions in this program
QoreProgram::setGlobalVarValue
DLLEXPORT int setGlobalVarValue(const char *name, QoreValue val, ExceptionSink *xsink)
sets the value of the given global variable
RootQoreNamespace
the root namespace of a QoreProgram object
Definition: QoreNamespace.h:337
QoreProgram::existsFunction
DLLEXPORT bool existsFunction(const char *name)
returns true if the given function exists as a user function, false if not
QoreBreakpoint::operator=
DLLEXPORT QoreBreakpoint & operator=(const QoreBreakpoint &other)
QoreListNode
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
QoreProgram::assignBreakpoint
DLLEXPORT void assignBreakpoint(QoreBreakpoint *bkpt, ExceptionSink *xsink)
QoreProgram::parseSetParseOptions
DLLEXPORT void parseSetParseOptions(int64 po)
adds the parse options given to the parse option mask
QoreProgram::getParseOptions
DLLEXPORT int getParseOptions() const
returns the parse options currently set for this program; DEPRECATED; use getParseOptions64() instead...
QoreProgram::enableWarning
DLLEXPORT int enableWarning(int code)
enables a warning by its code
QoreProgram::disableParseOptions
DLLEXPORT void disableParseOptions(int64 po, ExceptionSink *xsink)
turns off the parse options given in the passed mask and adds Qore-language exception information if ...
QoreProgram::checkWarning
DLLEXPORT bool checkWarning(int code) const
returns true if the warning code is set
QoreClass
defines a Qore-language class
Definition: QoreClass.h:239
QoreProgram::findQoreObject
DLLEXPORT QoreObject * findQoreObject() const
find Qore script object related to QoreProgram instance
QoreBreakpoint::resolveBreakpointId
static DLLEXPORT QoreBreakpoint * resolveBreakpointId(unsigned breakpointId)
get the breakpoint from breakpoint id
AbstractQoreProgramExternalData
an abstract class for program-specific external data
Definition: QoreProgram.h:981
AbstractPrivateData::deref
virtual DLLLOCAL void deref()
decrements the reference count of the object without the possibility of throwing a Qore-language exce...
Definition: AbstractPrivateData.h:65
QoreProgram::parseCommit
DLLEXPORT void parseCommit(ExceptionSink *xsink, ExceptionSink *warn_sink=0, int warn_mask=QP_WARN_ALL)
commits pending changes to the program
QoreProgram::getStatementId
DLLEXPORT unsigned long getStatementId(const AbstractStatement *statement) const
get the statement id
QoreProgram::getQoreNS
DLLEXPORT QoreNamespace * getQoreNS() const
returns a pointer to the "Qore" namespace
QoreProgram::setWarningMask
DLLEXPORT int setWarningMask(int wm)
sets the warning mask
QoreBreakpoint::getThreadIds
DLLEXPORT void getThreadIds(TidList_t &tidList, ExceptionSink *xsink)
QoreProgram::findHashDecl
DLLEXPORT const TypedHashDecl * findHashDecl(const char *path, const QoreNamespace *&pns) const
search for the given typed hash (hashdecl) in the program; can be a simple function name or a namespa...
QoreProgram::getGlobalVariableValue
DLLEXPORT QoreValue getGlobalVariableValue(const char *var, bool &found) const
returns the value of the global variable given (do not include the "$" symbol), the caller owns the r...
QoreProgram::setExternalData
DLLEXPORT void setExternalData(const char *owner, AbstractQoreProgramExternalData *pud)
sets a pointer to external data in the Program
QoreProgram::setScriptPath
DLLEXPORT void setScriptPath(const char *path)
sets the script path
QoreValue
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:267
QoreBreakpoint::unassignStatement
DLLEXPORT void unassignStatement(AbstractStatement *statement, ExceptionSink *xsink)
QoreProgram
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only ...
Definition: QoreProgram.h:127
QoreProgram::getSourceLabels
DLLEXPORT QoreHashNode * getSourceLabels(ExceptionSink *xsink) const
get list of labels which appears in a statement
QoreProgram::parse
DLLEXPORT void parse(FILE *fp, const char *name, ExceptionSink *xsink, ExceptionSink *warn_sink=0, int warn_mask=QP_WARN_ALL)
parses code from the file given and commits changes to the QoreProgram
QoreProgram::parseAndRunClass
DLLEXPORT void parseAndRunClass(FILE *fp, const char *name, const char *classname)
parses the given file and runs the code by instantiating the class given
QoreProgram::getQoreObject
static DLLEXPORT QoreObject * getQoreObject(QoreProgram *pgm)
get QoreObject of QoreProgram
QoreObject
the implementation of Qore&#39;s object data type, reference counted, dynamically-allocated only ...
Definition: QoreObject.h:60
QoreProgram::parseGetScriptDir
DLLLOCAL const char * parseGetScriptDir() const
returns the script directory, if known (0 if not), does not grab the parse lock, only to be called wh...
QoreProgram::parseDefine
DLLEXPORT void parseDefine(const char *str, QoreValue val)
defines a parse-time variable; call only at parse time (or before parsing)
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
QoreProgram::getScriptPath
DLLEXPORT QoreStringNode * getScriptPath() const
returns the script path (directory and name), if known (0 if not)
QoreProgram::findStatement
DLLEXPORT AbstractStatement * findStatement(const char *fileName, int line) const
QoreProgram::runClass
DLLEXPORT void runClass(const char *classname, ExceptionSink *xsink)
instantiates the class given and runs its constructor
QoreProgram::getLocalVariableVal
DLLEXPORT QoreValue getLocalVariableVal(const char *var, bool &found) const
QoreBreakpoint::getBreakpointId
DLLEXPORT unsigned getBreakpointId() const
get the breakpoint id
QoreProgram::getScriptName
DLLEXPORT QoreStringNode * getScriptName() const
returns the script file name, if known (0 if not)
QoreProgram::getAllQoreObjects
static DLLEXPORT QoreListNode * getAllQoreObjects(ExceptionSink *xsink)
list all programs as QoreObject list
QoreProgram::issueModuleCmd
DLLEXPORT int issueModuleCmd(const char *module, const char *cmd, ExceptionSink *xsink)
issues a module command for the given module; the module is loaded into the current Program object if...
QoreProgram::checkAllowDebugging
DLLEXPORT bool checkAllowDebugging(ExceptionSink *xsink)
check if program can provide debugging stuff
QoreProgram::findFunctionStatement
DLLEXPORT AbstractStatement * findFunctionStatement(const char *functionName, const QoreListNode *params, ExceptionSink *xsink) const
int64
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:260
QoreProgram::QoreProgram
DLLEXPORT QoreProgram()
creates the object
QoreProgram::disableWarning
DLLEXPORT int disableWarning(int code)
disables a warning by its code
QoreProgram::getThreadData
DLLEXPORT QoreHashNode * getThreadData()
returns the thread-local data for the current thread and the Program object
QoreProgram::getGlobalVars
DLLEXPORT QoreHashNode * getGlobalVars() const
retrieves a hash of global variables and their values
TypedHashDecl
typed hash declaration
Definition: TypedHashDecl.h:44
QoreExternalProgramCallContextHelper::QoreExternalProgramCallContextHelper
DLLEXPORT QoreExternalProgramCallContextHelper(QoreProgram *pgm)
sets the call context to the given program
QoreProgram::findAllGlobalVarsRegex
DLLEXPORT gvar_vec_t findAllGlobalVarsRegex(const QoreString &pattern, int re_opts, ExceptionSink *xsink) const
returns a list of all global variables that match the pattern
QoreProgram::getExternalData
DLLEXPORT AbstractQoreProgramExternalData * getExternalData(const char *owner) const
retrieves the external data pointer
QoreProgram::parseDisableParseOptions
DLLEXPORT void parseDisableParseOptions(int64 po)
disables the parse options given to the parse option mask
QoreBreakpoint::getStatements
DLLEXPORT void getStatements(AbstractStatementList_t &statList, ExceptionSink *xsink)
QoreProgram::findAllFunctionsRegex
DLLEXPORT func_vec_t findAllFunctionsRegex(const QoreString &pattern, int re_opts, ExceptionSink *xsink) const
returns a list of all functions that match the pattern
QoreProgram::registerQoreObject
DLLEXPORT void registerQoreObject(QoreObject *o, ExceptionSink *xsink) const
register link to Qore script object
QoreProgramHelper::operator->
DLLEXPORT QoreProgram * operator->()
returns the QoreProgram object being managed
QoreThreadLock
provides a mutually-exclusive thread lock
Definition: QoreThreadLock.h:49
QoreRWLock
provides a simple POSIX-threads-based read-write lock
Definition: QoreRWLock.h:47
QoreProgram::getBreakpoints
DLLEXPORT void getBreakpoints(QoreBreakpointList_t &bkptList)
QoreProgramHelper::QoreProgramHelper
DLLEXPORT QoreProgramHelper(ExceptionSink &xs)
creates the QoreProgram object: DEPRECATED: use QoreProgramHelper(int64, ExceptionSink&) instead ...
QoreBreakpoint::isThreadId
DLLEXPORT bool isThreadId(int tid, ExceptionSink *xsink)
QoreProgram::replaceParseOptions
DLLEXPORT void replaceParseOptions(int64 po, ExceptionSink *xsink)
replaces the parse options in the program with those given by the argument; adds Qore-language except...
QoreBreakpoint::removeThreadId
DLLEXPORT void removeThreadId(int tid, ExceptionSink *xsink)
QoreProgram::parseRollback
DLLEXPORT int parseRollback(ExceptionSink *xsink)
rolls back changes to the program object that were added with QoreProgram::parsePending() ...
QoreProgram::runTopLevel
DLLEXPORT QoreValue runTopLevel(ExceptionSink *xsink)
tuns the top level code and returns any return value
QoreBreakpoint::addThreadId
DLLEXPORT void addThreadId(int tid, ExceptionSink *xsink)
QoreProgram::parseFileAndRunClass
DLLEXPORT void parseFileAndRunClass(const char *filename, const char *classname)
parses the given filename and runs the program by instantiating the class given
QoreBreakpoint::clearThreadIds
DLLEXPORT void clearThreadIds(ExceptionSink *xsink)
QoreProgram::removeExternalData
DLLEXPORT AbstractQoreProgramExternalData * removeExternalData(const char *owner)
removes a pointer to external data in the Program; does not dereference the data
QoreProgram::checkFeature
DLLEXPORT bool checkFeature(const char *f) const
returns true if the given feature is present in the program object
QoreProgram::getSourceFileNames
DLLEXPORT QoreHashNode * getSourceFileNames(ExceptionSink *xsink) const
get list of files which appears in a statement
QoreProgram::resolveStatementId
DLLEXPORT AbstractStatement * resolveStatementId(unsigned long statementId) const
get the statement from statement id
QoreProgram::parseFile
DLLEXPORT void parseFile(const char *filename, ExceptionSink *xsink, ExceptionSink *warn_sink=0, int warn_mask=QP_WARN_ALL, bool only_first_except=false)
parses code from the file given and commits changes to the QoreProgram
QoreProgram::runtimeFindCall
DLLEXPORT const AbstractQoreFunctionVariant * runtimeFindCall(const char *name, const QoreListNode *params, ExceptionSink *xsink) const
AbstractQoreProgramExternalData::doDeref
virtual void doDeref()=0
For non-reference counted classes, deletes the object immediately.
QoreProgram::getParseOptions64
DLLEXPORT int64 getParseOptions64() const
returns the parse options currently set for this program
QoreExternalProgramCallContextHelper::~QoreExternalProgramCallContextHelper
DLLEXPORT ~QoreExternalProgramCallContextHelper()
resets the call context to the original state
QoreExternalProgramContextHelper::~QoreExternalProgramContextHelper
DLLEXPORT ~QoreExternalProgramContextHelper()
destroys the object and releases the program to be destroyed if it was successfully acquired in the c...
currentTZ
DLLEXPORT const AbstractQoreZoneInfo * currentTZ()
returns the current local time zone, note that if 0 = UTC