Qore Programming Language 1.19.5
Loading...
Searching...
No Matches
QoreProgram.h
1/* -*- mode: c++; indent-tabs-mode: nil -*- */
2/*
3 QoreProgram.h
4
5 Program Object Definition
6
7 Qore Programming Language
8
9 Copyright (C) 2003 - 2023 Qore Technologies, s.r.o.
10
11 Permission is hereby granted, free of charge, to any person obtaining a
12 copy of this software and associated documentation files (the "Software"),
13 to deal in the Software without restriction, including without limitation
14 the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 and/or sell copies of the Software, and to permit persons to whom the
16 Software is furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28
29 Note that the Qore library is released under a choice of three open-source
30 licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
31 information.
32*/
33
34#ifndef _QORE_QOREPROGRAM_H
35
36#define _QORE_QOREPROGRAM_H
37
38#include <qore/AbstractPrivateData.h>
39#include <qore/Restrictions.h>
40#include <qore/OutputStream.h>
41#include <qore/InputStream.h>
42
43// warnings - must correspond with the string order in QoreProgram.cpp
44// new warnings must also be added as constants
45#define QP_WARN_NONE 0
46#define QP_WARN_WARNING_MASK_UNCHANGED (1 << 0)
47#define QP_WARN_DUPLICATE_LOCAL_VARS (1 << 1)
48#define QP_WARN_UNKNOWN_WARNING (1 << 2)
49#define QP_WARN_UNDECLARED_VAR (1 << 3)
50#define QP_WARN_DUPLICATE_GLOBAL_VARS (1 << 4)
51#define QP_WARN_UNREACHABLE_CODE (1 << 5)
52#define QP_WARN_NONEXISTENT_METHOD_CALL (1 << 6)
53#define QP_WARN_INVALID_OPERATION (1 << 7)
54#define QP_WARN_CALL_WITH_TYPE_ERRORS (1 << 8)
55#define QP_WARN_RETURN_VALUE_IGNORED (1 << 9)
56#define QP_WARN_DEPRECATED (1 << 10)
57#define QP_WARN_EXCESS_ARGS (1 << 11)
58#define QP_WARN_DUPLICATE_HASH_KEY (1 << 12)
59#define QP_WARN_UNREFERENCED_VARIABLE (1 << 13)
60#define QP_WARN_DUPLICATE_BLOCK_VARS (1 << 14)
61#define QP_WARN_MODULE_ONLY (1 << 15)
62#define QP_WARN_BROKEN_LOGIC_PRECEDENCE (1 << 16)
63#define QP_WARN_INVALID_CATCH (1 << 17)
64#define QP_WARN_ALL -1
65
66#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)
67
68#define QP_WARN_DEFAULT (QP_WARN_UNKNOWN_WARNING|QP_WARN_MODULES|QP_WARN_DEPRECATED)
69
70enum BreakpointPolicy : unsigned char {
71 BKP_PO_NONE = 0,
72 BKP_PO_ACCEPT = 1,
73 BKP_PO_REJECT = 2,
74};
75
77DLLEXPORT extern const char** qore_warnings;
78
80DLLEXPORT extern unsigned qore_num_warnings;
81
83DLLEXPORT int get_warning_code(const char* str);
84
85// forward references
87class LocalVar;
88class ExceptionSink;
89class QoreListNode;
90class QoreNamespace;
92class QoreStringNode;
93class QoreHashNode;
94class FunctionCallNode;
95class AbstractStatement;
97class Var;
98class LVList;
99class UserFunctionVariant;
100class QoreParseTypeInfo;
101class ParamList;
102class AbstractQoreZoneInfo;
103class qore_program_private;
105class QoreBreakpoint;
106class AbstractQoreFunctionVariant;
107class QoreRWLock;
108class QoreExternalFunction;
109class QoreExternalGlobalVar;
111
112typedef std::list<QoreBreakpoint*> bkp_list_t;
113
114hashdecl QoreBreakpointList_t : public bkp_list_t {
115 DLLEXPORT QoreBreakpointList_t();
116 // dereferences all breakpoints and clears the list
117 DLLEXPORT ~QoreBreakpointList_t();
118};
119
121
129 friend class qore_program_private_base;
130 friend class qore_program_private;
131 friend class qore_debug_program_private;
132 friend hashdecl ThreadLocalProgramData;
133
134public:
136 DLLEXPORT QoreProgram();
137
139
142 DLLEXPORT QoreProgram(int64 parse_options);
143
145
152 DLLEXPORT QoreValue callFunction(const char* name, const QoreListNode* args, ExceptionSink* xsink);
153
155
163 DLLEXPORT QoreValue run(ExceptionSink* xsink);
164
166
174
176
186 DLLEXPORT void parseFileAndRun(const char* filename);
187
189
198 DLLEXPORT void parseAndRun(FILE *fp, const char* name);
199
201
210 DLLEXPORT void parseAndRun(const char* str, const char* name);
211
213
220 DLLEXPORT void runClass(const char* classname, ExceptionSink* xsink);
221
223
234 DLLEXPORT void parseFileAndRunClass(const char* filename, const char* classname);
235
237
247 DLLEXPORT void parseAndRunClass(FILE *fp, const char* name, const char* classname);
248
250
260 DLLEXPORT void parseAndRunClass(const char* str, const char* name, const char* classname);
261
263
271 DLLEXPORT void parse(FILE *fp, const char* name, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
272
274
282 DLLEXPORT void parse(const QoreString* str, const QoreString* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
283
285
295 DLLEXPORT void parse(const QoreString* str, const QoreString* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink, int warn_mask, const QoreString* source, int offset);
296
298
306 DLLEXPORT void parse(const char* str, const char* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
307
309
319 DLLEXPORT void parse(const char* str, const char* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink, int warn_mask, const char* source, int offset);
320
322
330 DLLEXPORT void parseFile(const char* filename, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL, bool only_first_except = false);
331
333
342 DLLEXPORT void parsePending(const char* code, const char* label, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
343
345
357 DLLEXPORT void parsePending(const char* code, const char* label, ExceptionSink* xsink, ExceptionSink* warn_sink, int warn_mask, const char* source, int offset);
358
360
370 DLLEXPORT void parsePending(const QoreString* str, const QoreString* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
371
373
385 DLLEXPORT void parsePending(const QoreString* str, const QoreString* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink, int warn_mask, const QoreString* source, int offset);
386
388
392 DLLEXPORT void parseCommit(ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
393
395
400 DLLEXPORT int parseRollback(ExceptionSink* xsink);
401
403 DLLEXPORT bool existsFunction(const char* name);
404
406
411 DLLEXPORT virtual void deref(ExceptionSink* xsink);
412
414 DLLEXPORT QoreProgram* programRefSelf() const;
415
417 DLLEXPORT void lockOptions();
418
420
425 DLLEXPORT void setExecClass(const char* ecn = 0);
426
428 DLLEXPORT void parseSetParseOptions(int64 po);
429
431 DLLEXPORT void parseDisableParseOptions(int64 po);
432
434 DLLEXPORT void waitForTermination();
435
437
441
443 DLLEXPORT QoreNamespace* getQoreNS() const;
444
446 DLLEXPORT RootQoreNamespace* getRootNS() const;
447
449
453 DLLEXPORT int setWarningMask(int wm);
454
456
460 DLLEXPORT int enableWarning(int code);
461
463
467 DLLEXPORT int disableWarning(int code);
468
470 DLLEXPORT int getParseOptions() const;
471
473 DLLEXPORT int64 getParseOptions64() const;
474
476
480 DLLEXPORT void setParseOptions(int64 po, ExceptionSink* xsink);
481
483
487 DLLEXPORT void disableParseOptions(int64 po, ExceptionSink* xsink);
488
490
494 DLLEXPORT void replaceParseOptions(int64 po, ExceptionSink* xsink);
495
497
501
503 DLLEXPORT bool checkWarning(int code) const;
504
506 DLLEXPORT int getWarningMask() const;
507
509 DLLEXPORT bool checkFeature(const char* f) const;
510
512 DLLEXPORT QoreListNode* getFeatureList() const;
513
515
517 DLLEXPORT QoreStringNode* getScriptName() const;
518
520
522 DLLEXPORT QoreStringNode* getScriptPath() const;
523
525
527 DLLEXPORT QoreStringNode* getScriptDir() const;
528
530
532 DLLEXPORT void setScriptPath(const char* path);
533
535
539 DLLEXPORT QoreValue getGlobalVariableValue(const char* var, bool &found) const;
540
542
546 DLLEXPORT QoreValue getGlobalVariableVal(const char* var, bool &found) const;
547
548 // retrieves the time zone setting for the program
549 DLLEXPORT const AbstractQoreZoneInfo *currentTZ() const;
550
551 // sets the program's time zone
552 DLLEXPORT void setTZ(const AbstractQoreZoneInfo *n_TZ);
553
555
558 DLLEXPORT void addFeature(const char* name);
559
561
565 DLLEXPORT void parseSetTimeZone(const char* zone);
566
568
573 DLLEXPORT void parseDefine(const char* str, QoreValue val);
574
576
581 DLLEXPORT void parseDefine(const char* str, const char* val);
582
583 // @deprecated use parseCmdLineDefines(ExceptionSink& xs, ExceptionSink& ws, int w, const std::map<std::string, std::string>& defmap) instead
584 DLLEXPORT void parseCmdLineDefines(const std::map<std::string, std::string> defmap, ExceptionSink& xs, ExceptionSink& ws, int w);
585
587
592 DLLEXPORT void parseCmdLineDefines(ExceptionSink& xs, ExceptionSink& ws, int w, const std::map<std::string, std::string>& defmap);
593
595
600 DLLEXPORT void setExternalData(const char* owner, AbstractQoreProgramExternalData* pud);
601
603
609 DLLEXPORT AbstractQoreProgramExternalData* getExternalData(const char* owner) const;
610
612
617
619
623 DLLEXPORT QoreHashNode* getGlobalVars() const;
624
626
634 DLLEXPORT int setGlobalVarValue(const char* name, QoreValue val, ExceptionSink* xsink);
635
636 // finds a function or class method variant if possible
645 DLLEXPORT const AbstractQoreFunctionVariant* runtimeFindCall(const char* name, const QoreListNode* params, ExceptionSink* xsink) const;
646
647 // finds all variants of a function or class method and returns a list of the results
659 DLLEXPORT QoreListNode* runtimeFindCallVariants(const char* name, ExceptionSink* xsink) const;
660
662
666 DLLEXPORT QoreListNode* getThreadList() const;
667
669
671 DLLEXPORT const QoreClass* findClass(const char* path, ExceptionSink* xsink) const;
672
674
676 DLLEXPORT class_vec_t findAllClassesRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
677
679
681 DLLEXPORT hashdecl_vec_t findAllHashDeclsRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
682
684
686 DLLEXPORT func_vec_t findAllFunctionsRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
687
689
691 DLLEXPORT ns_vec_t findAllNamespacesRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
692
694
696 DLLEXPORT gvar_vec_t findAllGlobalVarsRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
697
699
701 DLLEXPORT const_vec_t findAllNamespaceConstantsRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
702
704
706 DLLEXPORT const QoreExternalFunction* findFunction(const char* path) const;
707
709
711 DLLEXPORT const TypedHashDecl* findHashDecl(const char* path, const QoreNamespace*& pns) const;
712
714
719 DLLEXPORT QoreNamespace* findNamespace(const QoreString& path);
720
722
724 DLLEXPORT const QoreNamespace* findNamespace(const QoreString& path) const;
725
727
729 DLLEXPORT const QoreExternalGlobalVar* findGlobalVar(const char* path, const QoreNamespace*& pns) const;
730
732
734 DLLEXPORT const QoreExternalConstant* findNamespaceConstant(const char* path, const QoreNamespace*& pns) const;
735
737
739 DLLEXPORT void depRef();
740
742
744 DLLEXPORT void depDeref();
745
747
752
754
765 DLLEXPORT int issueModuleCmd(const char* module, const char* cmd, ExceptionSink* xsink);
766
767 DLLLOCAL QoreProgram(QoreProgram* pgm, int64 po, bool ec = false, const char* ecn = nullptr);
768
769 DLLLOCAL LocalVar *createLocalVar(const char* name, const QoreTypeInfo *typeInfo);
770
771 // returns 0 if a "requires" exception has already occurred
772 DLLLOCAL ExceptionSink* getParseExceptionSink();
773
774 DLLLOCAL void addFile(char* f);
775 DLLLOCAL QoreListNode* getVarList();
776 DLLLOCAL void parseSetIncludePath(const char* path);
777 DLLLOCAL const char* parseGetIncludePath() const;
778
779 /* for run-time module loading; the parse lock must be grabbed
780 before loading new modules - note this should only be assigned
781 to an AutoLock or SafeLocker object!
782 */
783 DLLLOCAL QoreThreadLock *getParseLock();
784 DLLLOCAL const LVList* getTopLevelLVList() const;
785
787
789 DLLLOCAL const char* parseGetScriptDir() const;
790
791 // can only be called while parsing from the same thread doing the parsing
792 DLLLOCAL bool parseExceptionRaised() const;
793
794 // TODO: implement !
802 DLLEXPORT QoreValue getLocalVariableVal(const char* var, bool &found) const;
803
806 DLLEXPORT void assignBreakpoint(QoreBreakpoint *bkpt, ExceptionSink *xsink);
807
810 DLLEXPORT void deleteAllBreakpoints();
811
814 DLLEXPORT void getBreakpoints(QoreBreakpointList_t &bkptList);
815
818 DLLEXPORT void getStatementBreakpoints(const AbstractStatement* statement, QoreBreakpointList_t &bkptList);
819
822 DLLEXPORT AbstractStatement* findStatement(const char* fileName, int line) const;
823
826 DLLEXPORT AbstractStatement* findFunctionStatement(const char* functionName, const QoreListNode* params, ExceptionSink* xsink) const;
827
829
833 DLLEXPORT unsigned long getStatementId(const AbstractStatement* statement) const;
834
836
841 DLLEXPORT AbstractStatement* resolveStatementId(unsigned long statementId) const;
842
844
849
853
855
858 DLLEXPORT unsigned getProgramId() const;
859
861
866 DLLEXPORT static QoreProgram* resolveProgramId(unsigned programId);
867
869 DLLEXPORT void registerQoreObject(QoreObject *o, ExceptionSink* xsink) const;
870
872 DLLEXPORT void unregisterQoreObject(QoreObject *o, ExceptionSink* xsink) const;
873
875 DLLEXPORT QoreObject* findQoreObject() const;
876
878 DLLEXPORT static QoreObject* getQoreObject(QoreProgram* pgm);
879
882
884 DLLEXPORT bool checkAllowDebugging(ExceptionSink* xsink);
885
886protected:
888
890 DLLLOCAL virtual ~QoreProgram();
891
892private:
894 qore_program_private* priv;
895
897 DLLLOCAL QoreProgram(const QoreProgram&);
898
900 DLLLOCAL QoreProgram& operator=(const QoreProgram&);
901};
902
904
907private:
908 QoreProgram* pgm;
909 ExceptionSink& xsink;
910
911public:
914
916 DLLEXPORT QoreProgramHelper(int64 parse_options, ExceptionSink& xs);
917
919
922
925
927 DLLEXPORT QoreProgram* operator*();
928};
929
931
934public:
937
940
942 DLLEXPORT operator bool() const;
943
944private:
945 bool valid = true;
946
947 // not implemented
949 void* operator new(size_t) = delete;
950};
951
953
956public:
959
962
964 DLLEXPORT operator bool() const;
965
966private:
967 QoreProgram* pgm;
968
969 // not implemented
971 void* operator new(size_t) = delete;
972};
973
975
978public:
983
984private:
985 QoreProgram* old_pgm;
986
987 // not implemented
989 void* operator new(size_t) = delete;
990};
991
993
1002public:
1004
1007
1009
1020
1022
1026 virtual void init();
1027
1029 virtual void doDeref() = 0;
1030};
1031
1032typedef std::list<AbstractStatement*> AbstractStatementList_t;
1033typedef std::list<int> TidList_t;
1034
1036
1041private:
1042 qore_program_private* pgm;
1043 AbstractStatementList_t statementList;
1044 typedef std::map<int/*tid*/, int/*count*/> TidMap_t;
1045 TidMap_t tidMap;
1046 QoreObject* qo; // reference to Qore script object, it's private object but we cannot
1047 static QoreRWLock lck_breakpoint; // to protect breakpoint manipulation
1048 static QoreBreakpointList_t breakpointList;
1049 static volatile unsigned breakpointIdCounter; // to generate breakpointId
1050 unsigned breakpointId;
1051
1052 DLLLOCAL void unassignAllStatements();
1053 DLLLOCAL bool isStatementAssigned(const AbstractStatement *statement) const;
1054 DLLLOCAL bool checkPgm(ExceptionSink* xsink) const;
1055
1056 friend class qore_program_private;
1057 friend class AbstractStatement;
1058
1059protected:
1060 DLLLOCAL virtual ~QoreBreakpoint();
1062 DLLLOCAL virtual bool checkBreak() const;
1063
1064public:
1065 bool enabled;
1069 BreakpointPolicy policy;
1070
1071 DLLEXPORT QoreBreakpoint();
1074 DLLEXPORT QoreBreakpoint& operator=(const QoreBreakpoint& other);
1080 DLLEXPORT void assignProgram(QoreProgram *new_pgm, ExceptionSink* xsink);
1081 /* Get assigned program to breakpoint
1082 */
1083 DLLEXPORT QoreProgram* getProgram() const;
1086 DLLEXPORT void assignStatement(AbstractStatement* statement, ExceptionSink* xsink);
1089 DLLEXPORT void unassignStatement(AbstractStatement* statement, ExceptionSink* xsink);
1092 DLLEXPORT void getStatements(AbstractStatementList_t &statList, ExceptionSink* xsink);
1098 DLLEXPORT AbstractStatement* resolveStatementId(unsigned long statementId, ExceptionSink* xsink) const;
1101 DLLEXPORT void getThreadIds(TidList_t &tidList, ExceptionSink* xsink);
1104 DLLEXPORT void setThreadIds(TidList_t tidList, ExceptionSink* xsink);
1107 DLLEXPORT void addThreadId(int tid, ExceptionSink* xsink);
1110 DLLEXPORT void removeThreadId(int tid, ExceptionSink* xsink);
1113 DLLEXPORT bool isThreadId(int tid, ExceptionSink* xsink);
1116 DLLEXPORT void clearThreadIds(ExceptionSink* xsink);
1117
1119
1122 DLLEXPORT unsigned getBreakpointId() const;
1123
1125
1130 DLLEXPORT static QoreBreakpoint* resolveBreakpointId(unsigned breakpointId);
1131
1132 DLLEXPORT void setQoreObject(QoreObject* n_qo);
1133
1134 DLLEXPORT QoreObject* getQoreObject();
1135};
1136
1138
1141public:
1144
1147
1148private:
1149 class ProgramThreadCountContextHelper* priv;
1150};
1151
1153
1156public:
1159
1162
1163private:
1164 class QoreExternalProgramCallContextHelperPriv* priv;
1165};
1166
1169public:
1170 DLLEXPORT QoreObjectContextHelper(QoreObject* obj, QoreClass* cls);
1171 DLLEXPORT ~QoreObjectContextHelper();
1172
1173private:
1174 class qore_object_context_helper* priv;
1175
1176 DLLLOCAL QoreObjectContextHelper(const QoreObjectContextHelper&) = delete;
1177 DLLLOCAL QoreObjectContextHelper& operator=(const QoreObjectContextHelper&) = delete;
1178 DLLLOCAL void* operator new(size_t) = delete;
1179};
1180
1181#endif // _QORE_QOREPROGRAM_H
base class for call references, reference-counted, dynamically allocated only
Definition: CallReferenceNode.h:39
the base class for all data to be used as private data of Qore objects
Definition: AbstractPrivateData.h:44
virtual DLLLOCAL void deref()
decrements the reference count of the object without the possibility of throwing a Qore-language exce...
Definition: AbstractPrivateData.h:65
an abstract class for program-specific external data
Definition: QoreProgram.h:1001
virtual AbstractQoreProgramExternalData * copy(QoreProgram *pgm) const =0
For reference-counted classes, returns the same object with the reference count incremented.
virtual void init()
Called after copy() on the new object.
virtual void doDeref()=0
For non-reference counted classes, deletes the object immediately.
virtual DLLEXPORT ~AbstractQoreProgramExternalData()
Destroys the object.
allows for the parse lock for the current program to be acquired by binary modules
Definition: QoreProgram.h:933
DLLEXPORT CurrentProgramRuntimeExternalParseContextHelper()
acquires the parse lock; if already acquired by another thread, then this call blocks until the lock ...
DLLEXPORT ~CurrentProgramRuntimeExternalParseContextHelper()
releases the parse lock for the current program
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:50
allows for the parse lock for the current program to be acquired by binary modules
Definition: QoreProgram.h:955
DLLEXPORT ProgramRuntimeExternalParseContextHelper(QoreProgram *pgm)
acquires the parse lock; if already acquired by another thread, then this call blocks until the lock ...
DLLEXPORT ~ProgramRuntimeExternalParseContextHelper()
releases the parse lock for the current program
Class implementing breakpoint for debugging.
Definition: QoreProgram.h:1040
DLLEXPORT void getStatements(AbstractStatementList_t &statList, ExceptionSink *xsink)
DLLEXPORT QoreBreakpoint & operator=(const QoreBreakpoint &other)
DLLEXPORT AbstractStatement * resolveStatementId(unsigned long statementId, ExceptionSink *xsink) const
DLLEXPORT void assignStatement(AbstractStatement *statement, ExceptionSink *xsink)
DLLEXPORT void unassignStatement(AbstractStatement *statement, ExceptionSink *xsink)
virtual DLLLOCAL bool checkBreak() const
check if program flow should be interrupted
DLLEXPORT void getThreadIds(TidList_t &tidList, ExceptionSink *xsink)
DLLEXPORT void removeThreadId(int tid, ExceptionSink *xsink)
DLLEXPORT void setThreadIds(TidList_t tidList, ExceptionSink *xsink)
DLLEXPORT void clearThreadIds(ExceptionSink *xsink)
DLLEXPORT unsigned getBreakpointId() const
get the breakpoint id
BreakpointPolicy policy
Definition: QoreProgram.h:1069
DLLEXPORT QoreListNode * getStatementIds(ExceptionSink *xsink)
DLLEXPORT void assignProgram(QoreProgram *new_pgm, ExceptionSink *xsink)
static DLLEXPORT QoreBreakpoint * resolveBreakpointId(unsigned breakpointId)
get the breakpoint from breakpoint id
DLLEXPORT void addThreadId(int tid, ExceptionSink *xsink)
DLLEXPORT bool isThreadId(int tid, ExceptionSink *xsink)
defines a Qore-language class
Definition: QoreClass.h:257
external wrapper class for constants
Definition: QoreReflection.h:200
allows the program call context to be set by external modules
Definition: QoreProgram.h:1155
DLLEXPORT ~QoreExternalProgramCallContextHelper()
resets the call context to the original state
DLLEXPORT QoreExternalProgramCallContextHelper(QoreProgram *pgm)
sets the call context to the given program
allows a program to be used and guarantees that it will stay valid until the destructor is run if suc...
Definition: QoreProgram.h:1140
DLLEXPORT ~QoreExternalProgramContextHelper()
destroys the object and releases the program to be destroyed if it was successfully acquired in the c...
DLLEXPORT QoreExternalProgramContextHelper(ExceptionSink *xsink, QoreProgram *pgm)
try to attach to the given program, if not possible, then a Qore-language exception is thrown
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:52
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
contains constants, classes, and subnamespaces in QoreProgram objects
Definition: QoreNamespace.h:65
Allows binary code to set the current object and class context.
Definition: QoreProgram.h:1168
the implementation of Qore's object data type, reference counted, dynamically-allocated only
Definition: QoreObject.h:62
allows for external modules to set the current Program context explicitly
Definition: QoreProgram.h:977
DLLEXPORT QoreProgramContextHelper(QoreProgram *pgm)
sets the current Program context
DLLEXPORT ~QoreProgramContextHelper()
restores the previous Program context
safely manages QoreProgram objects; note the the destructor will block until all background threads i...
Definition: QoreProgram.h:906
DLLEXPORT QoreProgram * operator*()
returns the QoreProgram object being managed
DLLEXPORT QoreProgramHelper(int64 parse_options, ExceptionSink &xs)
creates the QoreProgram object and sets the parse options
DLLEXPORT QoreProgram * operator->()
returns the QoreProgram object being managed
DLLEXPORT QoreProgramHelper(ExceptionSink &xs)
creates the QoreProgram object: DEPRECATED: use QoreProgramHelper(int64, ExceptionSink&) instead
DLLEXPORT ~QoreProgramHelper()
waits until all background threads in the Qore library have terminated and until the QoreProgram obje...
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition: QoreProgram.h:128
DLLEXPORT QoreListNode * getUserFunctionList()
returns a list of all user functions in this program
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 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...
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 bool checkAllowDebugging(ExceptionSink *xsink)
check if program can provide debugging stuff
DLLEXPORT int getParseOptions() const
returns the parse options currently set for this program; DEPRECATED; use getParseOptions64() instead
DLLEXPORT void parseAndRun(const char *str, const char *name)
parses the given string and runs the 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...
DLLEXPORT AbstractQoreProgramExternalData * getExternalData(const char *owner) const
retrieves the external data pointer
DLLEXPORT QoreProgram(int64 parse_options)
creates the object and sets the parse options
DLLEXPORT class_vec_t findAllClassesRegex(const QoreString &pattern, int re_opts, ExceptionSink *xsink) const
returns a list of all classes that match the pattern
DLLEXPORT const AbstractQoreFunctionVariant * runtimeFindCall(const char *name, const QoreListNode *params, ExceptionSink *xsink) const
DLLEXPORT QoreStringNode * getScriptName() const
returns the script file name, if known (0 if not)
DLLEXPORT void setScriptPath(const char *path)
sets the script path
DLLEXPORT QoreObject * findQoreObject() const
find Qore script object related to QoreProgram instance
DLLEXPORT void parseCommit(ExceptionSink *xsink, ExceptionSink *warn_sink=0, int warn_mask=QP_WARN_ALL)
commits pending changes to the program
DLLEXPORT AbstractStatement * findFunctionStatement(const char *functionName, const QoreListNode *params, ExceptionSink *xsink) const
DLLEXPORT void disableParseOptions(int64 po, ExceptionSink *xsink)
turns off the parse options given in the passed mask and adds Qore-language exception information if ...
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...
DLLEXPORT void parseSetTimeZone(const char *zone)
sets the time zone during parsing
DLLEXPORT void parse(const QoreString *str, const QoreString *lstr, ExceptionSink *xsink, ExceptionSink *warn_sink=0, int warn_mask=QP_WARN_ALL)
parses code from the given string and commits changes to the QoreProgram
DLLEXPORT QoreValue run(ExceptionSink *xsink)
runs the program (instantiates the program class if a program class has been set) and returns the ret...
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...
DLLEXPORT void waitForTerminationAndDeref(ExceptionSink *xsink)
this call blocks until the program's last thread terminates, and then calls QoreProgram::deref()
DLLEXPORT int setGlobalVarValue(const char *name, QoreValue val, ExceptionSink *xsink)
sets the value of the given global variable
DLLEXPORT func_vec_t findAllFunctionsRegex(const QoreString &pattern, int re_opts, ExceptionSink *xsink) const
returns a list of all functions that match the pattern
DLLEXPORT AbstractQoreProgramExternalData * removeExternalData(const char *owner)
removes a pointer to external data in the Program; does not dereference the data
DLLEXPORT const QoreNamespace * findNamespace(const QoreString &path) const
search for the given namespace in the program; can be a simple namespace name or a namespace-prefixed...
DLLEXPORT QoreValue getLocalVariableVal(const char *var, bool &found) const
DLLEXPORT void parseAndRun(FILE *fp, const char *name)
parses the given file and runs the file
DLLEXPORT int enableWarning(int code)
enables a warning by its code
DLLEXPORT int64 getParseOptions64() const
returns the parse options currently set for this program
DLLEXPORT int disableWarning(int code)
disables a warning by its code
DLLEXPORT void addFeature(const char *name)
manually add the feature to the program
DLLEXPORT void depRef()
incremements the weak reference count for the program object
static DLLEXPORT QoreObject * getQoreObject(QoreProgram *pgm)
get QoreObject of QoreProgram
DLLEXPORT void parseDefine(const char *str, const char *val)
defines a parse-time variable; call only at parse time (or before parsing)
DLLEXPORT QoreHashNode * getSourceFileNames(ExceptionSink *xsink) const
get list of files which appears in a statement
DLLEXPORT void parsePending(const char *code, const char *label, ExceptionSink *xsink, ExceptionSink *warn_sink, int warn_mask, const char *source, int offset)
parses code from the given string but does not commit changes to the QoreProgram
DLLEXPORT QoreValue callFunction(const char *name, const QoreListNode *args, ExceptionSink *xsink)
calls a function from the function name and returns the return value
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...
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
DLLEXPORT RootQoreNamespace * getRootNS() const
returns a pointer to the root namespace
DLLEXPORT unsigned getProgramId() const
get the program id
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
DLLEXPORT void deleteAllBreakpoints()
DLLEXPORT void setExecClass(const char *ecn=0)
sets the name of the application class to be executed (instantiated) instead of top-level code
DLLEXPORT void parseFileAndRunClass(const char *filename, const char *classname)
parses the given filename and runs the program by instantiating the class given
DLLEXPORT int getWarningMask() const
returns the warning mask
DLLEXPORT ns_vec_t findAllNamespacesRegex(const QoreString &pattern, int re_opts, ExceptionSink *xsink) const
returns a list of all namespaces that match the pattern
DLLEXPORT void registerQoreObject(QoreObject *o, ExceptionSink *xsink) const
register link to Qore script object
DLLEXPORT QoreStringNode * getScriptDir() const
returns the script directory, if known (0 if not)
DLLEXPORT void runClass(const char *classname, ExceptionSink *xsink)
instantiates the class given and runs its constructor
DLLEXPORT void lockOptions()
locks parse options so they may not be changed
DLLEXPORT QoreValue runTopLevel(ExceptionSink *xsink)
tuns the top level code and returns any return value
DLLEXPORT void parseCmdLineDefines(ExceptionSink &xs, ExceptionSink &ws, int w, const std::map< std::string, std::string > &defmap)
defines parse-time variables
DLLEXPORT void parseDefine(const char *str, QoreValue val)
defines a parse-time variable; call only at parse time (or before parsing)
DLLEXPORT bool existsFunction(const char *name)
returns true if the given function exists as a user function, false if not
DLLEXPORT AbstractStatement * findStatement(const char *fileName, int line) const
virtual DLLLOCAL ~QoreProgram()
the destructor is private in order to prohibit the object from being allocated on the stack
DLLEXPORT QoreHashNode * getGlobalVars() const
retrieves a hash of global variables and their values
DLLEXPORT int parseRollback(ExceptionSink *xsink)
rolls back changes to the program object that were added with QoreProgram::parsePending()
DLLEXPORT void parseSetParseOptions(int64 po)
adds the parse options given to the parse option mask
DLLEXPORT bool checkWarning(int code) const
returns true if the warning code is set
static DLLEXPORT QoreListNode * getAllQoreObjects(ExceptionSink *xsink)
list all programs as QoreObject list
DLLEXPORT void parsePending(const QoreString *str, const QoreString *lstr, ExceptionSink *xsink, ExceptionSink *warn_sink, int warn_mask, const QoreString *source, int offset)
parses code from the given string but does not commit changes to the QoreProgram
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...
DLLEXPORT void parsePending(const QoreString *str, const QoreString *lstr, 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 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 void getBreakpoints(QoreBreakpointList_t &bkptList)
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-...
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 QoreStringNode * getScriptPath() const
returns the script path (directory and name), if known (0 if not)
DLLEXPORT QoreListNode * runtimeFindCallVariants(const char *name, ExceptionSink *xsink) const
DLLEXPORT QoreListNode * getThreadList() const
returns a list of threads active in this Program object
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...
DLLEXPORT int setWarningMask(int wm)
sets the warning mask
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
DLLEXPORT void parse(const char *str, const char *lstr, ExceptionSink *xsink, ExceptionSink *warn_sink=0, int warn_mask=QP_WARN_ALL)
parses code from the given string and commits changes to the QoreProgram
DLLEXPORT void parseAndRunClass(const char *str, const char *name, const char *classname)
parses the given string and runs the code by instantiating the class given
DLLEXPORT QoreHashNode * getThreadData()
returns the thread-local data for the current thread and the Program object
DLLEXPORT QoreHashNode * getSourceLabels(ExceptionSink *xsink) const
get list of labels which appears in a statement
DLLEXPORT unsigned long getStatementId(const AbstractStatement *statement) const
get the statement id
static DLLEXPORT QoreProgram * resolveProgramId(unsigned programId)
get the program from program id
DLLEXPORT void getStatementBreakpoints(const AbstractStatement *statement, QoreBreakpointList_t &bkptList)
DLLEXPORT void unregisterQoreObject(QoreObject *o, ExceptionSink *xsink) const
unregister link to Qore script object
DLLEXPORT void assignBreakpoint(QoreBreakpoint *bkpt, ExceptionSink *xsink)
DLLEXPORT QoreListNode * getFeatureList() const
returns a list of features in the program object
DLLEXPORT QoreNamespace * findNamespace(const QoreString &path)
search for the given namespace in the program; can be a simple namespace name or a namespace-prefixed...
DLLEXPORT void setExternalData(const char *owner, AbstractQoreProgramExternalData *pud)
sets a pointer to external data in the Program
DLLEXPORT void waitForTermination()
this call blocks until the program's last thread terminates
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 parseDisableParseOptions(int64 po)
disables the parse options given to the parse option mask
DLLEXPORT void parse(const char *str, const char *lstr, ExceptionSink *xsink, ExceptionSink *warn_sink, int warn_mask, const char *source, int offset)
parses code from the given string and commits changes to the QoreProgram
virtual DLLEXPORT void deref(ExceptionSink *xsink)
decrements the reference count of the object
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...
DLLEXPORT QoreNamespace * getQoreNS() const
returns a pointer to the "Qore" namespace
DLLEXPORT QoreProgram * programRefSelf() const
references "this" and returns a non-const pointer to itself
DLLEXPORT bool checkFeature(const char *f) const
returns true if the given feature is present in the program object
DLLEXPORT AbstractStatement * resolveStatementId(unsigned long statementId) const
get the statement from statement id
DLLEXPORT void parseFileAndRun(const char *filename)
parses the given filename and runs the file
DLLEXPORT void parse(const QoreString *str, const QoreString *lstr, ExceptionSink *xsink, ExceptionSink *warn_sink, int warn_mask, const QoreString *source, int offset)
parses code from the given string and commits changes to the QoreProgram
DLLEXPORT void depDeref()
dereferences a weak reference for the program object
DLLEXPORT void setParseOptions(int64 po, ExceptionSink *xsink)
sets the parse options and adds Qore-language exception information if an error occurs
DLLEXPORT QoreProgram()
creates the object
provides a simple POSIX-threads-based read-write lock
Definition: QoreRWLock.h:47
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
provides a mutually-exclusive thread lock
Definition: QoreThreadLock.h:49
the root namespace of a QoreProgram object
Definition: QoreNamespace.h:397
typed hash declaration
Definition: TypedHashDecl.h:44
an unresolved call reference, only present temporarily in the parse tree
Definition: CallReferenceNode.h:68
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
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:279