| Qore Programming Language - C/C++ Library 1.12.2

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 - 2022 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/intern/qore_program_private.h>
41
42 // warnings - must correspond with the string order in QoreProgram.cpp
43 // new warnings must also be added as constants
44 #define QP_WARN_NONE 0
45 #define QP_WARN_WARNING_MASK_UNCHANGED (1 << 0)
46 #define QP_WARN_DUPLICATE_LOCAL_VARS (1 << 1)
47 #define QP_WARN_UNKNOWN_WARNING (1 << 2)
48 #define QP_WARN_UNDECLARED_VAR (1 << 3)
49 #define QP_WARN_DUPLICATE_GLOBAL_VARS (1 << 4)
50 #define QP_WARN_UNREACHABLE_CODE (1 << 5)
51 #define QP_WARN_NONEXISTENT_METHOD_CALL (1 << 6)
52 #define QP_WARN_INVALID_OPERATION (1 << 7)
53 #define QP_WARN_CALL_WITH_TYPE_ERRORS (1 << 8)
54 #define QP_WARN_RETURN_VALUE_IGNORED (1 << 9)
55 #define QP_WARN_DEPRECATED (1 << 10)
56 #define QP_WARN_EXCESS_ARGS (1 << 11)
57 #define QP_WARN_DUPLICATE_HASH_KEY (1 << 12)
58 #define QP_WARN_UNREFERENCED_VARIABLE (1 << 13)
59 #define QP_WARN_DUPLICATE_BLOCK_VARS (1 << 14)
60 #define QP_WARN_MODULE_ONLY (1 << 15)
61 #define QP_WARN_BROKEN_LOGIC_PRECEDENCE (1 << 16)
62 #define QP_WARN_INVALID_CATCH (1 << 17)
63 #define QP_WARN_ALL -1
64
65 #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)
66
67 #define QP_WARN_DEFAULT (QP_WARN_UNKNOWN_WARNING|QP_WARN_MODULES|QP_WARN_DEPRECATED)
68
69 enum BreakpointPolicy : unsigned char {
70 BKP_PO_NONE = 0,
71 BKP_PO_ACCEPT = 1,
72 BKP_PO_REJECT = 2,
73 };
74
76 DLLEXPORT extern const char** qore_warnings;
77
79 DLLEXPORT extern unsigned qore_num_warnings;
80
82 DLLEXPORT int get_warning_code(const char* str);
83
84 // forward references
85 class AbstractCallReferenceNode;
86 class LocalVar;
87 class ExceptionSink;
88 class QoreListNode;
89 class QoreNamespace;
90 class RootQoreNamespace;
91 class QoreStringNode;
92 class QoreHashNode;
93 class FunctionCallNode;
94 class AbstractStatement;
95 class UnresolvedProgramCallReferenceNode;
96 class Var;
97 class LVList;
98 class UserFunctionVariant;
99 class QoreParseTypeInfo;
100 class ParamList;
101 class AbstractQoreZoneInfo;
102 class qore_program_private;
103 class AbstractQoreProgramExternalData;
104 class QoreBreakpoint;
105 class AbstractQoreFunctionVariant;
106 class QoreRWLock;
107 class QoreExternalFunction;
108 class QoreExternalGlobalVar;
109 class QoreExternalConstant;
110
111 typedef std::list<QoreBreakpoint*> bkp_list_t;
112
113 struct QoreBreakpointList_t : public bkp_list_t {
114 DLLEXPORT QoreBreakpointList_t();
115 // dereferences all breakpoints and clears the list
116 DLLEXPORT ~QoreBreakpointList_t();
117 };
118
120
127 class QoreProgram : public AbstractPrivateData {
128 friend class qore_program_private_base;
129 friend class qore_program_private;
130 friend class qore_debug_program_private;
131 friend struct ThreadLocalProgramData;
132 private:
134 qore_program_private* priv;
135
137 DLLLOCAL QoreProgram(const QoreProgram&);
138
140 DLLLOCAL QoreProgram& operator=(const QoreProgram&);
141
142 protected:
144
146 DLLLOCAL virtual ~QoreProgram();
147
148 public:
150 DLLEXPORT QoreProgram();
151
153
156 DLLEXPORT QoreProgram(int64 parse_options);
157
159
166 DLLEXPORT QoreValue callFunction(const char* name, const QoreListNode* args, ExceptionSink* xsink);
167
169
177 DLLEXPORT QoreValue run(ExceptionSink* xsink);
178
180
187 DLLEXPORT QoreValue runTopLevel(ExceptionSink* xsink);
188
190
200 DLLEXPORT void parseFileAndRun(const char* filename);
201
203
212 DLLEXPORT void parseAndRun(FILE *fp, const char* name);
213
215
224 DLLEXPORT void parseAndRun(const char* str, const char* name);
225
227
234 DLLEXPORT void runClass(const char* classname, ExceptionSink* xsink);
235
237
248 DLLEXPORT void parseFileAndRunClass(const char* filename, const char* classname);
249
251
261 DLLEXPORT void parseAndRunClass(FILE *fp, const char* name, const char* classname);
262
264
274 DLLEXPORT void parseAndRunClass(const char* str, const char* name, const char* classname);
275
277
285 DLLEXPORT void parse(FILE *fp, const char* name, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
286
288
296 DLLEXPORT void parse(const QoreString* str, const QoreString* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
297
299
309 DLLEXPORT void parse(const QoreString* str, const QoreString* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink, int warn_mask, const QoreString* source, int offset);
310
312
320 DLLEXPORT void parse(const char* str, const char* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
321
323
333 DLLEXPORT void parse(const char* str, const char* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink, int warn_mask, const char* source, int offset);
334
336
344 DLLEXPORT void parseFile(const char* filename, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL, bool only_first_except = false);
345
347
356 DLLEXPORT void parsePending(const char* code, const char* label, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
357
359
371 DLLEXPORT void parsePending(const char* code, const char* label, ExceptionSink* xsink, ExceptionSink* warn_sink, int warn_mask, const char* source, int offset);
372
374
384 DLLEXPORT void parsePending(const QoreString* str, const QoreString* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
385
387
399 DLLEXPORT void parsePending(const QoreString* str, const QoreString* lstr, ExceptionSink* xsink, ExceptionSink* warn_sink, int warn_mask, const QoreString* source, int offset);
400
402
406 DLLEXPORT void parseCommit(ExceptionSink* xsink, ExceptionSink* warn_sink = 0, int warn_mask = QP_WARN_ALL);
407
409
414 DLLEXPORT int parseRollback(ExceptionSink* xsink);
415
417 DLLEXPORT bool existsFunction(const char* name);
418
420
424 using AbstractPrivateData::deref;
425 DLLEXPORT virtual void deref(ExceptionSink* xsink);
426
428 DLLEXPORT QoreProgram* programRefSelf() const;
429
431 DLLEXPORT void lockOptions();
432
434
439 DLLEXPORT void setExecClass(const char* ecn = 0);
440
442 DLLEXPORT void parseSetParseOptions(int64 po);
443
445 DLLEXPORT void parseDisableParseOptions(int64 po);
446
448 DLLEXPORT void waitForTermination();
449
451
454 DLLEXPORT void waitForTerminationAndDeref(ExceptionSink* xsink);
455
457 DLLEXPORT QoreNamespace* getQoreNS() const;
458
460 DLLEXPORT RootQoreNamespace* getRootNS() const;
461
463
467 DLLEXPORT int setWarningMask(int wm);
468
470
474 DLLEXPORT int enableWarning(int code);
475
477
481 DLLEXPORT int disableWarning(int code);
482
484 DLLEXPORT int getParseOptions() const;
485
487 DLLEXPORT int64 getParseOptions64() const;
488
490
494 DLLEXPORT void setParseOptions(int64 po, ExceptionSink* xsink);
495
497
501 DLLEXPORT void disableParseOptions(int64 po, ExceptionSink* xsink);
502
504
508 DLLEXPORT void replaceParseOptions(int64 po, ExceptionSink* xsink);
509
511
514 DLLEXPORT QoreListNode* getUserFunctionList();
515
517 DLLEXPORT bool checkWarning(int code) const;
518
520 DLLEXPORT int getWarningMask() const;
521
523 DLLEXPORT bool checkFeature(const char* f) const;
524
526 DLLEXPORT QoreListNode* getFeatureList() const;
527
529
531 DLLEXPORT QoreStringNode* getScriptName() const;
532
534
536 DLLEXPORT QoreStringNode* getScriptPath() const;
537
539
541 DLLEXPORT QoreStringNode* getScriptDir() const;
542
544
546 DLLEXPORT void setScriptPath(const char* path);
547
549
553 DLLEXPORT QoreValue getGlobalVariableValue(const char* var, bool &found) const;
554
556
560 DLLEXPORT QoreValue getGlobalVariableVal(const char* var, bool &found) const;
561
562 // retrieves the time zone setting for the program
563 DLLEXPORT const AbstractQoreZoneInfo *currentTZ() const;
564
565 // sets the program's time zone
566 DLLEXPORT void setTZ(const AbstractQoreZoneInfo *n_TZ);
567
569
572 DLLEXPORT void addFeature(const char* name);
573
575
579 DLLEXPORT void parseSetTimeZone(const char* zone);
580
582
587 DLLEXPORT void parseDefine(const char* str, QoreValue val);
588
590
595 DLLEXPORT void parseDefine(const char* str, const char* val);
596
597 // @deprecated use parseCmdLineDefines(ExceptionSink& xs, ExceptionSink& ws, int w, const std::map<std::string, std::string>& defmap) instead
598 DLLEXPORT void parseCmdLineDefines(const std::map<std::string, std::string> defmap, ExceptionSink& xs, ExceptionSink& ws, int w);
599
601
606 DLLEXPORT void parseCmdLineDefines(ExceptionSink& xs, ExceptionSink& ws, int w, const std::map<std::string, std::string>& defmap);
607
609
614 DLLEXPORT void setExternalData(const char* owner, AbstractQoreProgramExternalData* pud);
615
617
623 DLLEXPORT AbstractQoreProgramExternalData* getExternalData(const char* owner) const;
624
626
630 DLLEXPORT AbstractQoreProgramExternalData* removeExternalData(const char* owner);
631
633
637 DLLEXPORT QoreHashNode* getGlobalVars() const;
638
640
648 DLLEXPORT int setGlobalVarValue(const char* name, QoreValue val, ExceptionSink* xsink);
649
650 // finds a function or class method variant if possible
659 DLLEXPORT const AbstractQoreFunctionVariant* runtimeFindCall(const char* name, const QoreListNode* params, ExceptionSink* xsink) const;
660
661 // finds all variants of a function or class method and returns a list of the results
673 DLLEXPORT QoreListNode* runtimeFindCallVariants(const char* name, ExceptionSink* xsink) const;
674
676
680 DLLEXPORT QoreListNode* getThreadList() const;
681
683
685 DLLEXPORT const QoreClass* findClass(const char* path, ExceptionSink* xsink) const;
686
688
690 DLLEXPORT class_vec_t findAllClassesRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
691
693
695 DLLEXPORT hashdecl_vec_t findAllHashDeclsRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
696
698
700 DLLEXPORT func_vec_t findAllFunctionsRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
701
703
705 DLLEXPORT ns_vec_t findAllNamespacesRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
706
708
710 DLLEXPORT gvar_vec_t findAllGlobalVarsRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
711
713
715 DLLEXPORT const_vec_t findAllNamespaceConstantsRegex(const QoreString& pattern, int re_opts, ExceptionSink* xsink) const;
716
718
720 DLLEXPORT const QoreExternalFunction* findFunction(const char* path) const;
721
723
725 DLLEXPORT const TypedHashDecl* findHashDecl(const char* path, const QoreNamespace*& pns) const;
726
728
733 DLLEXPORT QoreNamespace* findNamespace(const QoreString& path);
734
736
738 DLLEXPORT const QoreNamespace* findNamespace(const QoreString& path) const;
739
741
743 DLLEXPORT const QoreExternalGlobalVar* findGlobalVar(const char* path, const QoreNamespace*& pns) const;
744
746
748 DLLEXPORT const QoreExternalConstant* findNamespaceConstant(const char* path, const QoreNamespace*& pns) const;
749
751
753 DLLEXPORT void depRef();
754
756
758 DLLEXPORT void depDeref();
759
761
765 DLLEXPORT QoreHashNode* getThreadData();
766
768
779 DLLEXPORT int issueModuleCmd(const char* module, const char* cmd, ExceptionSink* xsink);
780
781 DLLLOCAL QoreProgram(QoreProgram* pgm, int64 po, bool ec = false, const char* ecn = nullptr);
782
783 DLLLOCAL LocalVar *createLocalVar(const char* name, const QoreTypeInfo *typeInfo);
784
785 // returns 0 if a "requires" exception has already occurred
786 DLLLOCAL ExceptionSink* getParseExceptionSink();
787
788 DLLLOCAL void addFile(char* f);
789 DLLLOCAL QoreListNode* getVarList();
790 DLLLOCAL void parseSetIncludePath(const char* path);
791 DLLLOCAL const char* parseGetIncludePath() const;
792
793 /* for run-time module loading; the parse lock must be grabbed
794 before loading new modules - note this should only be assigned
795 to an AutoLock or SafeLocker object!
796 */
797 DLLLOCAL QoreThreadLock *getParseLock();
798 DLLLOCAL const LVList* getTopLevelLVList() const;
799
801
803 DLLLOCAL const char* parseGetScriptDir() const;
804
805 // can only be called while parsing from the same thread doing the parsing
806 DLLLOCAL bool parseExceptionRaised() const;
807
808 // TODO: implement !
816 DLLEXPORT QoreValue getLocalVariableVal(const char* var, bool &found) const;
817
820 DLLEXPORT void assignBreakpoint(QoreBreakpoint *bkpt, ExceptionSink *xsink);
821
824 DLLEXPORT void deleteAllBreakpoints();
825
828 DLLEXPORT void getBreakpoints(QoreBreakpointList_t &bkptList);
829
832 DLLEXPORT void getStatementBreakpoints(const AbstractStatement* statement, QoreBreakpointList_t &bkptList);
833
836 DLLEXPORT AbstractStatement* findStatement(const char* fileName, int line) const;
837
840 DLLEXPORT AbstractStatement* findFunctionStatement(const char* functionName, const QoreListNode* params, ExceptionSink* xsink) const;
841
843
847 DLLEXPORT unsigned long getStatementId(const AbstractStatement* statement) const;
848
850
855 DLLEXPORT AbstractStatement* resolveStatementId(unsigned long statementId) const;
856
858
861 DLLEXPORT QoreHashNode* getSourceFileNames(ExceptionSink* xsink) const;
863
866 DLLEXPORT QoreHashNode* getSourceLabels(ExceptionSink* xsink) const;
867
869
872 DLLEXPORT unsigned getProgramId() const;
873
875
880 DLLEXPORT static QoreProgram* resolveProgramId(unsigned programId);
881
883 DLLEXPORT void registerQoreObject(QoreObject *o, ExceptionSink* xsink) const;
884
886 DLLEXPORT void unregisterQoreObject(QoreObject *o, ExceptionSink* xsink) const;
887
889 DLLEXPORT QoreObject* findQoreObject() const;
890
892 DLLEXPORT static QoreObject* getQoreObject(QoreProgram* pgm);
893
895 DLLEXPORT static QoreListNode* getAllQoreObjects(ExceptionSink* xsink);
896
898 DLLEXPORT bool checkAllowDebugging(ExceptionSink* xsink);
899 };
900
902
904 class QoreProgramHelper {
905 private:
906 QoreProgram* pgm;
907 ExceptionSink& xsink;
908
909 public:
911 DLLEXPORT QoreProgramHelper(ExceptionSink& xs);
912
914 DLLEXPORT QoreProgramHelper(int64 parse_options, ExceptionSink& xs);
915
917
919 DLLEXPORT ~QoreProgramHelper();
920
922 DLLEXPORT QoreProgram* operator->();
923
925 DLLEXPORT QoreProgram* operator*();
926 };
927
929
931 class CurrentProgramRuntimeExternalParseContextHelper {
932 public:
934 DLLEXPORT CurrentProgramRuntimeExternalParseContextHelper();
935
937 DLLEXPORT ~CurrentProgramRuntimeExternalParseContextHelper();
938
940 DLLEXPORT operator bool() const;
941
942 private:
943 bool valid = true;
944
945 // not implemented
946 CurrentProgramRuntimeExternalParseContextHelper(const CurrentProgramRuntimeExternalParseContextHelper&) = delete;
947 void* operator new(size_t) = delete;
948 };
949
951
953 class ProgramRuntimeExternalParseContextHelper {
954 public:
956 DLLEXPORT ProgramRuntimeExternalParseContextHelper(QoreProgram* pgm);
957
959 DLLEXPORT ~ProgramRuntimeExternalParseContextHelper();
960
962 DLLEXPORT operator bool() const;
963
964 private:
965 QoreProgram* pgm;
966
967 // not implemented
968 ProgramRuntimeExternalParseContextHelper(const ProgramRuntimeExternalParseContextHelper&) = delete;
969 void* operator new(size_t) = delete;
970 };
971
973
975 class QoreProgramContextHelper {
976 public:
978 DLLEXPORT QoreProgramContextHelper(QoreProgram* pgm);
980 DLLEXPORT ~QoreProgramContextHelper();
981
982 private:
983 QoreProgram* old_pgm;
984
985 // not implemented
986 QoreProgramContextHelper(const QoreProgramContextHelper&) = delete;
987 void* operator new(size_t) = delete;
988 };
989
991
999 class AbstractQoreProgramExternalData {
1000 public:
1002
1004 DLLEXPORT virtual ~AbstractQoreProgramExternalData();
1005
1007
1017 virtual AbstractQoreProgramExternalData* copy(QoreProgram* pgm) const = 0;
1018
1020
1024 virtual void init();
1025
1027 virtual void doDeref() = 0;
1028 };
1029
1030 typedef std::list<AbstractStatement*> AbstractStatementList_t;
1031 typedef std::list<int> TidList_t;
1032
1034
1038 class QoreBreakpoint : public AbstractPrivateData {
1039 private:
1040 qore_program_private* pgm;
1041 AbstractStatementList_t statementList;
1042 typedef std::map<int/*tid*/, int/*count*/> TidMap_t;
1043 TidMap_t tidMap;
1044 QoreObject* qo; // reference to Qore script object, it's private object but we cannot
1045 static QoreRWLock lck_breakpoint; // to protect breakpoint manipulation
1046 static QoreBreakpointList_t breakpointList;
1047 static volatile unsigned breakpointIdCounter; // to generate breakpointId
1048 unsigned breakpointId;
1049
1050 DLLLOCAL void unassignAllStatements();
1051 DLLLOCAL bool isStatementAssigned(const AbstractStatement *statement) const;
1052 DLLLOCAL bool checkPgm(ExceptionSink* xsink) const;
1053
1054 friend class qore_program_private;
1055 friend class AbstractStatement;
1056
1057 protected:
1058 DLLLOCAL virtual ~QoreBreakpoint();
1060 DLLLOCAL virtual bool checkBreak() const;
1061
1062 public:
1063 bool enabled;
1067 BreakpointPolicy policy;
1068
1069 DLLEXPORT QoreBreakpoint();
1072 DLLEXPORT QoreBreakpoint& operator=(const QoreBreakpoint& other);
1078 DLLEXPORT void assignProgram(QoreProgram *new_pgm, ExceptionSink* xsink);
1079 /* Get assigned program to breakpoint
1080 */
1081 DLLEXPORT QoreProgram* getProgram() const;
1084 DLLEXPORT void assignStatement(AbstractStatement* statement, ExceptionSink* xsink);
1087 DLLEXPORT void unassignStatement(AbstractStatement* statement, ExceptionSink* xsink);
1090 DLLEXPORT void getStatements(AbstractStatementList_t &statList, ExceptionSink* xsink);
1093 DLLEXPORT QoreListNode* getStatementIds(ExceptionSink* xsink);
1096 DLLEXPORT AbstractStatement* resolveStatementId(unsigned long statementId, ExceptionSink* xsink) const;
1099 DLLEXPORT void getThreadIds(TidList_t &tidList, ExceptionSink* xsink);
1102 DLLEXPORT void setThreadIds(TidList_t tidList, ExceptionSink* xsink);
1105 DLLEXPORT void addThreadId(int tid, ExceptionSink* xsink);
1108 DLLEXPORT void removeThreadId(int tid, ExceptionSink* xsink);
1111 DLLEXPORT bool isThreadId(int tid, ExceptionSink* xsink);
1114 DLLEXPORT void clearThreadIds(ExceptionSink* xsink);
1115
1117
1120 DLLEXPORT unsigned getBreakpointId() const;
1121
1123
1128 DLLEXPORT static QoreBreakpoint* resolveBreakpointId(unsigned breakpointId);
1129
1130 DLLEXPORT void setQoreObject(QoreObject* n_qo);
1131
1132 DLLEXPORT QoreObject* getQoreObject();
1133 };
1134
1136
1138 class QoreExternalProgramContextHelper {
1139 public:
1141 DLLEXPORT QoreExternalProgramContextHelper(ExceptionSink* xsink, QoreProgram* pgm);
1142
1144 DLLEXPORT ~QoreExternalProgramContextHelper();
1145
1146 private:
1147 class ProgramThreadCountContextHelper* priv;
1148 };
1149
1151
1153 class QoreExternalProgramCallContextHelper {
1154 public:
1156 DLLEXPORT QoreExternalProgramCallContextHelper(QoreProgram* pgm);
1157
1159 DLLEXPORT ~QoreExternalProgramCallContextHelper();
1160
1161 private:
1162 class QoreExternalProgramCallContextHelperPriv* priv;
1163 };
1164
1165 #endif // _QORE_QOREPROGRAM_H
Restrictions.h
AbstractCallReferenceNode
base class for call references, reference-counted, dynamically allocated only
Definition: CallReferenceNode.h:39
AbstractPrivateData
the base class for all data to be used as private data of Qore objects
Definition: AbstractPrivateData.h:44
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
AbstractQoreProgramExternalData
an abstract class for program-specific external data
Definition: QoreProgram.h:999
AbstractQoreProgramExternalData::init
virtual void init()
Called after copy() on the new object.
AbstractQoreProgramExternalData::doDeref
virtual void doDeref()=0
For non-reference counted classes, deletes the object immediately.
AbstractQoreProgramExternalData::~AbstractQoreProgramExternalData
virtual DLLEXPORT ~AbstractQoreProgramExternalData()
Destroys the object.
AbstractQoreProgramExternalData::copy
virtual AbstractQoreProgramExternalData * copy(QoreProgram *pgm) const =0
For reference-counted classes, returns the same object with the reference count incremented.
CurrentProgramRuntimeExternalParseContextHelper
allows for the parse lock for the current program to be acquired by binary modules
Definition: QoreProgram.h:931
CurrentProgramRuntimeExternalParseContextHelper::CurrentProgramRuntimeExternalParseContextHelper
DLLEXPORT CurrentProgramRuntimeExternalParseContextHelper()
acquires the parse lock; if already acquired by another thread, then this call blocks until the lock ...
CurrentProgramRuntimeExternalParseContextHelper::~CurrentProgramRuntimeExternalParseContextHelper
DLLEXPORT ~CurrentProgramRuntimeExternalParseContextHelper()
releases the parse lock for the current program
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
ProgramRuntimeExternalParseContextHelper
allows for the parse lock for the current program to be acquired by binary modules
Definition: QoreProgram.h:953
ProgramRuntimeExternalParseContextHelper::ProgramRuntimeExternalParseContextHelper
DLLEXPORT ProgramRuntimeExternalParseContextHelper(QoreProgram *pgm)
acquires the parse lock; if already acquired by another thread, then this call blocks until the lock ...
ProgramRuntimeExternalParseContextHelper::~ProgramRuntimeExternalParseContextHelper
DLLEXPORT ~ProgramRuntimeExternalParseContextHelper()
releases the parse lock for the current program
QoreBreakpoint
Class implementing breakpoint for debugging.
Definition: QoreProgram.h:1038
QoreBreakpoint::getStatements
DLLEXPORT void getStatements(AbstractStatementList_t &statList, ExceptionSink *xsink)
QoreBreakpoint::resolveStatementId
DLLEXPORT AbstractStatement * resolveStatementId(unsigned long statementId, ExceptionSink *xsink) const
QoreBreakpoint::assignStatement
DLLEXPORT void assignStatement(AbstractStatement *statement, ExceptionSink *xsink)
QoreBreakpoint::getStatementIds
DLLEXPORT QoreListNode * getStatementIds(ExceptionSink *xsink)
QoreBreakpoint::unassignStatement
DLLEXPORT void unassignStatement(AbstractStatement *statement, ExceptionSink *xsink)
QoreBreakpoint::checkBreak
virtual DLLLOCAL bool checkBreak() const
check if program flow should be interrupted
QoreBreakpoint::getThreadIds
DLLEXPORT void getThreadIds(TidList_t &tidList, ExceptionSink *xsink)
QoreBreakpoint::resolveBreakpointId
static DLLEXPORT QoreBreakpoint * resolveBreakpointId(unsigned breakpointId)
get the breakpoint from breakpoint id
QoreBreakpoint::removeThreadId
DLLEXPORT void removeThreadId(int tid, ExceptionSink *xsink)
QoreBreakpoint::setThreadIds
DLLEXPORT void setThreadIds(TidList_t tidList, ExceptionSink *xsink)
QoreBreakpoint::clearThreadIds
DLLEXPORT void clearThreadIds(ExceptionSink *xsink)
QoreBreakpoint::getBreakpointId
DLLEXPORT unsigned getBreakpointId() const
get the breakpoint id
QoreBreakpoint::operator=
DLLEXPORT QoreBreakpoint & operator=(const QoreBreakpoint &other)
QoreBreakpoint::policy
BreakpointPolicy policy
Definition: QoreProgram.h:1067
QoreBreakpoint::assignProgram
DLLEXPORT void assignProgram(QoreProgram *new_pgm, ExceptionSink *xsink)
QoreBreakpoint::addThreadId
DLLEXPORT void addThreadId(int tid, ExceptionSink *xsink)
QoreBreakpoint::isThreadId
DLLEXPORT bool isThreadId(int tid, ExceptionSink *xsink)
QoreClass
defines a Qore-language class
Definition: QoreClass.h:249
QoreExternalConstant
external wrapper class for constants
Definition: QoreReflection.h:200
QoreExternalProgramCallContextHelper
allows the program call context to be set by external modules
Definition: QoreProgram.h:1153
QoreExternalProgramCallContextHelper::~QoreExternalProgramCallContextHelper
DLLEXPORT ~QoreExternalProgramCallContextHelper()
resets the call context to the original state
QoreExternalProgramCallContextHelper::QoreExternalProgramCallContextHelper
DLLEXPORT QoreExternalProgramCallContextHelper(QoreProgram *pgm)
sets the call context to the given program
QoreExternalProgramContextHelper
allows a program to be used and guarantees that it will stay valid until the destructor is run if suc...
Definition: QoreProgram.h:1138
QoreExternalProgramContextHelper::~QoreExternalProgramContextHelper
DLLEXPORT ~QoreExternalProgramContextHelper()
destroys the object and releases the program to be destroyed if it was successfully acquired in the c...
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
QoreListNode
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
QoreNamespace
contains constants, classes, and subnamespaces in QoreProgram objects
Definition: QoreNamespace.h:65
QoreObject
the implementation of Qore's object data type, reference counted, dynamically-allocated only
Definition: QoreObject.h:60
QoreProgramContextHelper
allows for external modules to set the current Program context explicitly
Definition: QoreProgram.h:975
QoreProgramContextHelper::QoreProgramContextHelper
DLLEXPORT QoreProgramContextHelper(QoreProgram *pgm)
sets the current Program context
QoreProgramContextHelper::~QoreProgramContextHelper
DLLEXPORT ~QoreProgramContextHelper()
restores the previous Program context
QoreProgramHelper
safely manages QoreProgram objects; note the the destructor will block until all background threads i...
Definition: QoreProgram.h:904
QoreProgramHelper::operator->
DLLEXPORT QoreProgram * operator->()
returns the QoreProgram object being managed
QoreProgramHelper::operator*
DLLEXPORT QoreProgram * operator*()
returns the QoreProgram object being managed
QoreProgramHelper::QoreProgramHelper
DLLEXPORT QoreProgramHelper(ExceptionSink &xs)
creates the QoreProgram object: DEPRECATED: use QoreProgramHelper(int64, ExceptionSink&) instead
QoreProgramHelper::~QoreProgramHelper
DLLEXPORT ~QoreProgramHelper()
waits until all background threads in the Qore library have terminated and until the QoreProgram obje...
QoreProgram
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition: QoreProgram.h:127
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::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...
QoreProgram::getScriptName
DLLEXPORT QoreStringNode * getScriptName() const
returns the script file name, if known (0 if not)
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...
QoreProgram::getThreadList
DLLEXPORT QoreListNode * getThreadList() const
returns a list of threads active in this Program object
QoreProgram::checkAllowDebugging
DLLEXPORT bool checkAllowDebugging(ExceptionSink *xsink)
check if program can provide debugging stuff
QoreProgram::getParseOptions
DLLEXPORT int getParseOptions() const
returns the parse options currently set for this program; DEPRECATED; use getParseOptions64() instead
QoreProgram::getUserFunctionList
DLLEXPORT QoreListNode * getUserFunctionList()
returns a list of all user functions in this program
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...
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
QoreProgram::setScriptPath
DLLEXPORT void setScriptPath(const char *path)
sets the script path
QoreProgram::getSourceFileNames
DLLEXPORT QoreHashNode * getSourceFileNames(ExceptionSink *xsink) const
get list of files which appears in a statement
QoreProgram::resolveProgramId
static DLLEXPORT QoreProgram * resolveProgramId(unsigned programId)
get the program from program id
QoreProgram::parseCommit
DLLEXPORT void parseCommit(ExceptionSink *xsink, ExceptionSink *warn_sink=0, int warn_mask=QP_WARN_ALL)
commits pending changes to the program
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::parseSetTimeZone
DLLEXPORT void parseSetTimeZone(const char *zone)
sets the time zone during parsing
QoreProgram::getScriptDir
DLLEXPORT QoreStringNode * getScriptDir() const
returns the script directory, if known (0 if not)
QoreProgram::getScriptPath
DLLEXPORT QoreStringNode * getScriptPath() const
returns the script path (directory and name), if known (0 if not)
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::findStatement
DLLEXPORT AbstractStatement * findStatement(const char *fileName, int line) const
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::waitForTerminationAndDeref
DLLEXPORT void waitForTerminationAndDeref(ExceptionSink *xsink)
this call blocks until the program's last thread terminates, and then calls QoreProgram::deref()
QoreProgram::setGlobalVarValue
DLLEXPORT int setGlobalVarValue(const char *name, QoreValue val, ExceptionSink *xsink)
sets the value of the given global variable
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::runtimeFindCall
DLLEXPORT const AbstractQoreFunctionVariant * runtimeFindCall(const char *name, const QoreListNode *params, ExceptionSink *xsink) const
QoreProgram::getQoreObject
static DLLEXPORT QoreObject * getQoreObject(QoreProgram *pgm)
get QoreObject of QoreProgram
QoreProgram::getLocalVariableVal
DLLEXPORT QoreValue getLocalVariableVal(const char *var, bool &found) const
QoreProgram::parseAndRun
DLLEXPORT void parseAndRun(FILE *fp, const char *name)
parses the given file and runs the file
QoreProgram::enableWarning
DLLEXPORT int enableWarning(int code)
enables a warning by its code
QoreProgram::getParseOptions64
DLLEXPORT int64 getParseOptions64() const
returns the parse options currently set for this program
QoreProgram::disableWarning
DLLEXPORT int disableWarning(int code)
disables a warning by its code
QoreProgram::addFeature
DLLEXPORT void addFeature(const char *name)
manually add the feature to the program
QoreProgram::depRef
DLLEXPORT void depRef()
incremements the weak reference count for the program object
QoreProgram::getExternalData
DLLEXPORT AbstractQoreProgramExternalData * getExternalData(const char *owner) const
retrieves the external data pointer
QoreProgram::removeExternalData
DLLEXPORT AbstractQoreProgramExternalData * removeExternalData(const char *owner)
removes a pointer to external data in the Program; does not dereference the data
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::getFeatureList
DLLEXPORT QoreListNode * getFeatureList() const
returns a list of features in the program object
QoreProgram::deref
virtual DLLLOCAL void deref(ExceptionSink *xsink)
dereferences the object and deletes it if the reference count reaches zero
Definition: AbstractPrivateData.h:59
QoreProgram::getGlobalVars
DLLEXPORT QoreHashNode * getGlobalVars() const
retrieves a hash of global variables and their values
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::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::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::findQoreObject
DLLEXPORT QoreObject * findQoreObject() const
find Qore script object related to QoreProgram instance
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::getThreadData
DLLEXPORT QoreHashNode * getThreadData()
returns the thread-local data for the current thread and the Program object
QoreProgram::getProgramId
DLLEXPORT unsigned getProgramId() const
get the program id
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
QoreProgram::deleteAllBreakpoints
DLLEXPORT void deleteAllBreakpoints()
QoreProgram::runtimeFindCallVariants
DLLEXPORT QoreListNode * runtimeFindCallVariants(const char *name, ExceptionSink *xsink) const
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
QoreProgram::programRefSelf
DLLEXPORT QoreProgram * programRefSelf() const
references "this" and returns a non-const pointer to itself
QoreProgram::parseFileAndRunClass
DLLEXPORT void parseFileAndRunClass(const char *filename, const char *classname)
parses the given filename and runs the program by instantiating the class given
QoreProgram::getWarningMask
DLLEXPORT int getWarningMask() const
returns the warning mask
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::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
QoreProgram::getRootNS
DLLEXPORT RootQoreNamespace * getRootNS() const
returns a pointer to the root namespace
QoreProgram::registerQoreObject
DLLEXPORT void registerQoreObject(QoreObject *o, ExceptionSink *xsink) const
register link to Qore script object
QoreProgram::runClass
DLLEXPORT void runClass(const char *classname, ExceptionSink *xsink)
instantiates the class given and runs its constructor
QoreProgram::lockOptions
DLLEXPORT void lockOptions()
locks parse options so they may not be changed
QoreProgram::runTopLevel
DLLEXPORT QoreValue runTopLevel(ExceptionSink *xsink)
tuns the top level code and returns any return value
QoreProgram::parseDefine
DLLEXPORT void parseDefine(const char *str, QoreValue val)
defines a parse-time variable; call only at parse time (or before parsing)
QoreProgram::existsFunction
DLLEXPORT bool existsFunction(const char *name)
returns true if the given function exists as a user function, false if not
QoreProgram::~QoreProgram
virtual DLLLOCAL ~QoreProgram()
the destructor is private in order to prohibit the object from being allocated on the stack
QoreProgram::parseRollback
DLLEXPORT int parseRollback(ExceptionSink *xsink)
rolls back changes to the program object that were added with QoreProgram::parsePending()
QoreProgram::parseSetParseOptions
DLLEXPORT void parseSetParseOptions(int64 po)
adds the parse options given to the parse option mask
QoreProgram::checkWarning
DLLEXPORT bool checkWarning(int code) const
returns true if the warning code is set
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-...
QoreProgram::findFunctionStatement
DLLEXPORT AbstractStatement * findFunctionStatement(const char *functionName, const QoreListNode *params, ExceptionSink *xsink) const
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::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::getBreakpoints
DLLEXPORT void getBreakpoints(QoreBreakpointList_t &bkptList)
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::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::setWarningMask
DLLEXPORT int setWarningMask(int wm)
sets the warning mask
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
QoreProgram::getStatementId
DLLEXPORT unsigned long getStatementId(const AbstractStatement *statement) const
get the statement id
QoreProgram::getAllQoreObjects
static DLLEXPORT QoreListNode * getAllQoreObjects(ExceptionSink *xsink)
list all programs as QoreObject list
QoreProgram::getStatementBreakpoints
DLLEXPORT void getStatementBreakpoints(const AbstractStatement *statement, QoreBreakpointList_t &bkptList)
QoreProgram::resolveStatementId
DLLEXPORT AbstractStatement * resolveStatementId(unsigned long statementId) const
get the statement from statement id
QoreProgram::unregisterQoreObject
DLLEXPORT void unregisterQoreObject(QoreObject *o, ExceptionSink *xsink) const
unregister link to Qore script object
QoreProgram::assignBreakpoint
DLLEXPORT void assignBreakpoint(QoreBreakpoint *bkpt, ExceptionSink *xsink)
QoreProgram::getSourceLabels
DLLEXPORT QoreHashNode * getSourceLabels(ExceptionSink *xsink) const
get list of labels which appears in a statement
QoreProgram::setExternalData
DLLEXPORT void setExternalData(const char *owner, AbstractQoreProgramExternalData *pud)
sets a pointer to external data in the Program
QoreProgram::waitForTermination
DLLEXPORT void waitForTermination()
this call blocks until the program's last thread terminates
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::parseDisableParseOptions
DLLEXPORT void parseDisableParseOptions(int64 po)
disables the parse options given to the parse option mask
QoreProgram::checkFeature
DLLEXPORT bool checkFeature(const char *f) const
returns true if the given feature is present in the program object
QoreProgram::getQoreNS
DLLEXPORT QoreNamespace * getQoreNS() const
returns a pointer to the "Qore" namespace
QoreProgram::parseFileAndRun
DLLEXPORT void parseFileAndRun(const char *filename)
parses the given filename and runs the file
QoreProgram::depDeref
DLLEXPORT void depDeref()
dereferences a weak reference for the program object
QoreProgram::setParseOptions
DLLEXPORT void setParseOptions(int64 po, ExceptionSink *xsink)
sets the parse options and adds Qore-language exception information if an error occurs
QoreProgram::QoreProgram
DLLEXPORT QoreProgram()
creates the object
QoreRWLock
provides a simple POSIX-threads-based read-write lock
Definition: QoreRWLock.h:47
QoreString
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
QoreStringNode
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
QoreThreadLock
provides a mutually-exclusive thread lock
Definition: QoreThreadLock.h:49
RootQoreNamespace
the root namespace of a QoreProgram object
Definition: QoreNamespace.h:397
TypedHashDecl
typed hash declaration
Definition: TypedHashDecl.h:44
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
getProgram
DLLEXPORT QoreProgram * getProgram()
returns the current QoreProgram
currentTZ
DLLEXPORT const AbstractQoreZoneInfo * currentTZ()
returns the current local time zone, note that if 0 = UTC
QoreValue
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:275