34 #ifndef _QORE_QOREPROGRAM_H
36 #define _QORE_QOREPROGRAM_H
38 #include <qore/AbstractPrivateData.h>
43 #define QP_WARN_NONE 0
44 #define QP_WARN_WARNING_MASK_UNCHANGED (1 << 0)
45 #define QP_WARN_DUPLICATE_LOCAL_VARS (1 << 1)
46 #define QP_WARN_UNKNOWN_WARNING (1 << 2)
47 #define QP_WARN_UNDECLARED_VAR (1 << 3)
48 #define QP_WARN_DUPLICATE_GLOBAL_VARS (1 << 4)
49 #define QP_WARN_UNREACHABLE_CODE (1 << 5)
50 #define QP_WARN_NONEXISTENT_METHOD_CALL (1 << 6)
51 #define QP_WARN_INVALID_OPERATION (1 << 7)
52 #define QP_WARN_CALL_WITH_TYPE_ERRORS (1 << 8)
53 #define QP_WARN_RETURN_VALUE_IGNORED (1 << 9)
54 #define QP_WARN_DEPRECATED (1 << 10)
55 #define QP_WARN_EXCESS_ARGS (1 << 11)
56 #define QP_WARN_DUPLICATE_HASH_KEY (1 << 12)
57 #define QP_WARN_UNREFERENCED_VARIABLE (1 << 13)
58 #define QP_WARN_DUPLICATE_BLOCK_VARS (1 << 14)
59 #define QP_WARN_MODULE_ONLY (1 << 15)
60 #define QP_WARN_ALL -1
62 #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)
64 #define QP_WARN_DEFAULT (QP_WARN_UNKNOWN_WARNING|QP_WARN_MODULES|QP_WARN_DEPRECATED)
67 DLLEXPORT
extern const char** qore_warnings;
70 DLLEXPORT
extern unsigned qore_num_warnings;
73 DLLEXPORT
int get_warning_code(
const char* str);
83 class FunctionCallNode;
84 class AbstractStatement;
85 class UnresolvedProgramCallReferenceNode;
88 class UserFunctionVariant;
90 class QoreParseTypeInfo;
92 class AbstractQoreZoneInfo;
93 class qore_program_private;
104 friend class qore_program_private_base;
105 friend class qore_program_private;
108 qore_program_private* priv;
114 DLLLOCAL QoreProgram& operator=(
const QoreProgram&);
184 DLLEXPORT
void parseAndRun(FILE *fp,
const char* name);
196 DLLEXPORT
void parseAndRun(
const char* str,
const char* name);
233 DLLEXPORT
void parseAndRunClass(FILE *fp,
const char* name,
const char* classname);
246 DLLEXPORT
void parseAndRunClass(
const char* str,
const char* name,
const char* classname);
305 DLLEXPORT
void parse(
const char* str,
const char* lstr,
ExceptionSink* xsink,
ExceptionSink* warn_sink,
int warn_mask,
const char* source,
int offset);
561 DLLEXPORT
const AbstractQoreZoneInfo *
currentTZ()
const;
564 DLLEXPORT
void setTZ(
const AbstractQoreZoneInfo *n_TZ);
597 DLLEXPORT
void parseDefine(
const char* str,
const char* val);
617 DLLLOCAL
QoreProgram(QoreProgram* pgm,
int64 po,
bool ec =
false,
const char* ecn = 0);
619 DLLLOCAL LocalVar *createLocalVar(
const char* name,
const QoreTypeInfo *typeInfo);
625 DLLLOCAL
void depRef();
627 DLLLOCAL
void addFile(
char* f);
629 DLLLOCAL
void parseSetIncludePath(
const char* path);
630 DLLLOCAL
const char* parseGetIncludePath()
const;
637 DLLLOCAL
const LVList* getTopLevelLVList()
const;
645 DLLLOCAL
bool parseExceptionRaised()
const;
675 #endif // _QORE_QOREPROGRAM_H
DLLEXPORT void waitForTermination()
this call blocks until the program's last thread terminates
DLLEXPORT QoreNamespace * getQoreNS() const
returns a pointer to the "Qore" namespace
DLLEXPORT void parseDefine(const char *str, AbstractQoreNode *val)
defines a parse-time variable; call only at parse time (or before parsing)
DLLEXPORT ~QoreProgramHelper()
waits until all background threads in the Qore library have terminated and until the QoreProgram obje...
DLLEXPORT void lockOptions()
locks parse options so they may not be changed
DLLEXPORT QoreProgram * programRefSelf() const
references "this" and returns a non-const pointer to itself
DLLEXPORT RootQoreNamespace * getRootNS() const
returns a pointer to the root namespace
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
DLLEXPORT void addFeature(const char *name)
manually add the feature to the program
DLLEXPORT int getParseOptions() const
returns the parse options currently set for this program; DEPRECATED; use getParseOptions64() instead...
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:49
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...
virtual DLLLOCAL ~QoreProgram()
the destructor is private in order to prohibit the object from being allocated on the stack ...
DLLEXPORT void waitForTerminationAndDeref(ExceptionSink *xsink)
this call blocks until the program's last thread terminates, and then calls QoreProgram::deref() ...
DLLEXPORT void disableParseOptions(int po, ExceptionSink *xsink)
turns off the parse options given in the passed mask and adds Qore-language exception information if ...
the base class for all data to be used as private data of Qore objects
Definition: AbstractPrivateData.h:44
DLLEXPORT AbstractQoreNode * 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...
DLLEXPORT void setExecClass(const char *ecn=0)
sets the name of the application class to be executed (instantiated) instead of top-level code ...
DLLEXPORT AbstractQoreNode * runTopLevel(ExceptionSink *xsink)
tuns the top level code and returns any return value
DLLEXPORT bool checkWarning(int code) const
returns true if the warning code is set
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:55
contains constants, classes, and subnamespaces in QoreProgram objects
Definition: QoreNamespace.h:58
DLLEXPORT QoreProgram * operator*()
returns the QoreProgram object being managed
DLLEXPORT QoreListNode * getFeatureList() const
returns a list of features in the program object
DLLEXPORT void parseFileAndRun(const char *filename)
parses the given filename and runs the file
base class for call references, reference-counted, dynamically allocated only
Definition: CallReferenceNode.h:39
DLLEXPORT AbstractQoreNode * callFunction(const char *name, const QoreListNode *args, ExceptionSink *xsink)
calls a function from the function name and returns the return value
safely manages QoreProgram objects; note the the destructor will block until all background threads i...
Definition: QoreProgram.h:651
DLLEXPORT void parseSetTimeZone(const char *zone)
sets the time zone during parsing
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:82
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
DLLEXPORT void parseAndRun(FILE *fp, const char *name)
parses the given file and runs the file
DLLEXPORT QoreListNode * getUserFunctionList()
returns a list of all user functions in this program
the root namespace of a QoreProgram object
Definition: QoreNamespace.h:226
DLLEXPORT bool existsFunction(const char *name)
returns true if the given function exists as a user function, false if not
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
DLLEXPORT int enableWarning(int code)
enables a warning by its code
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...
virtual DLLLOCAL void deref()
decrements the reference count of the object without the possibility of throwing a Qore-language exce...
Definition: AbstractPrivateData.h:67
DLLEXPORT void parseCommit(ExceptionSink *xsink, ExceptionSink *warn_sink=0, int warn_mask=QP_WARN_ALL)
commits pending changes to the program
DLLEXPORT int setWarningMask(int wm)
sets the warning mask
DLLEXPORT void setScriptPath(const char *path)
sets the script path
DLLEXPORT QoreStringNode * getScriptPath() const
returns the script path (directory and name), if known (0 if not)
DLLEXPORT int64 getParseOptions64() const
returns the parse options currently set for this program
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only ...
Definition: QoreProgram.h:103
DLLEXPORT void parseRollback()
rolls back changes to the program object that were added with QoreProgram::parsePending() ...
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
DLLEXPORT void parseAndRunClass(FILE *fp, const char *name, const char *classname)
parses the given file and runs the code by instantiating the class given
DLLEXPORT void setParseOptions(int po, ExceptionSink *xsink)
sets the parse options and adds Qore-language exception information if an error occurs ...
DLLEXPORT QoreStringNode * getScriptDir() const
returns the script directory, if known (0 if not)
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:43
DLLEXPORT void runClass(const char *classname, ExceptionSink *xsink)
instantiates the class given and runs its constructor
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:228
DLLEXPORT QoreProgram()
creates the object
DLLEXPORT int disableWarning(int code)
disables a warning by its code
DLLEXPORT void parseSetParseOptions(int po)
adds the parse options given to the parse option mask; DEPRECATED: use parseSetParseOptions(int64) in...
DLLEXPORT void parseDisableParseOptions(int64 po)
disables the parse options given to the parse option mask
DLLEXPORT AbstractQoreNode * run(ExceptionSink *xsink)
runs the program (instantiates the program class if a program class has been set) and returns the ret...
DLLEXPORT QoreProgram * operator->()
returns the QoreProgram object being managed
provides a mutually-exclusive thread lock
Definition: QoreThreadLock.h:49
DLLEXPORT QoreProgramHelper(ExceptionSink &xs)
creates the QoreProgram object: DEPRECATED: use QoreProgramHelper(int64, ExceptionSink&) instead ...
DLLEXPORT bool checkFeature(const char *f) const
returns true if the given feature is present in the program object
DLLEXPORT void replaceParseOptions(int64 po, ExceptionSink *xsink)
replaces the parse options in the program with those given by the argument; adds Qore-language except...
DLLEXPORT int getWarningMask() const
returns the warning mask
DLLEXPORT void parseFileAndRunClass(const char *filename, const char *classname)
parses the given filename and runs the program by instantiating the class given
DLLEXPORT void parseCmdLineDefines(const std::map< std::string, std::string > defmap, ExceptionSink &xs, ExceptionSink &ws, int w)
defines parse-time variables
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
DLLEXPORT QoreStringNode * getScriptName() const
returns the script file name, if known (0 if not)
DLLEXPORT const AbstractQoreZoneInfo * currentTZ()
returns the current local time zone, note that if 0 = UTC