Qore Programming Language 2.3.0
Loading...
Searching...
No Matches
RuntimeConfig.h
1/* -*- indent-tabs-mode: nil -*- */
2/*
3 RuntimeConfig.h
4
5 Qore Programming Language
6
7 Copyright (C) 2003 - 2026 Qore Technologies, s.r.o.
8
9 Permission is hereby granted, free of charge, to any person obtaining a
10 copy of this software and associated documentation files (the "Software"),
11 to deal in the Software without restriction, including without limitation
12 the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so, subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26
27 Note that the Qore library is released under a choice of three open-source
28 licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
29 information.
30*/
31
32#ifndef _QORE_RUNTIMECONFIG_H
33#define _QORE_RUNTIMECONFIG_H
34
35#include <qore/common.h>
36#include <cstdint>
37
38class QoreProgram;
39class QoreObject;
40class AbstractStatement;
41hashdecl QoreProgramLocation;
42hashdecl ThreadLocalProgramData;
43class QoreClosureBase;
44class qore_class_private;
45class QoreTypeInfo;
47
50public:
51 class Impl;
52
53 DLLEXPORT RuntimeConfig();
54 DLLEXPORT RuntimeConfig(const RuntimeConfig& other);
55 DLLEXPORT RuntimeConfig(RuntimeConfig&& other) noexcept;
56 DLLEXPORT RuntimeConfig& operator=(const RuntimeConfig& other);
57 DLLEXPORT RuntimeConfig& operator=(RuntimeConfig&& other) noexcept;
58 DLLEXPORT ~RuntimeConfig();
59
60 DLLEXPORT QoreProgram* getProgram() const;
61 DLLEXPORT void setProgram(QoreProgram* pgm);
62
63 DLLEXPORT const QoreProgramLocation* getLocation() const;
64 DLLEXPORT void setLocation(const QoreProgramLocation* loc);
65
66 DLLEXPORT const AbstractStatement* getStatement() const;
67 DLLEXPORT void setStatement(const AbstractStatement* stmt);
68
69 DLLEXPORT int64_t getParseOptions() const;
70 DLLEXPORT void setParseOptions(int64_t po);
71
72 DLLEXPORT ThreadLocalProgramData* getThreadLocalProgramData() const;
73 DLLEXPORT void setThreadLocalProgramData(ThreadLocalProgramData* tlpd);
74
75 DLLEXPORT QoreObject* getObject() const;
76 DLLEXPORT void setObject(QoreObject* obj);
77
78 DLLEXPORT const qore_class_private* getClass() const;
79 DLLEXPORT void setClass(const qore_class_private* cls);
80
81 DLLEXPORT const QoreStackLocation* getStackLocation() const;
82 DLLEXPORT void setStackLocation(const QoreStackLocation* stack_loc);
83
84 DLLEXPORT const QoreTypeInfo* getReturnTypeInfo() const;
85 DLLEXPORT void setReturnTypeInfo(const QoreTypeInfo* return_type_info);
86
87 DLLEXPORT q_rt_flags_t getRuntimeFlags() const;
88 DLLEXPORT void setRuntimeFlags(q_rt_flags_t flags);
89
90 DLLEXPORT int getElement() const;
91 DLLEXPORT void setElement(int element);
92
93 DLLEXPORT const QoreClosureBase* getClosureEnv() const;
94 DLLEXPORT void setClosureEnv(const QoreClosureBase* closure_env);
95
96 DLLEXPORT bool hasThreadLocalData() const;
97 DLLEXPORT bool isValid() const;
98
99private:
100 Impl* impl;
101 bool owned;
102
103 DLLEXPORT explicit RuntimeConfig(Impl* impl, bool owned);
104 DLLEXPORT Impl& implRef();
105 DLLEXPORT const Impl& implRef() const;
106
111 friend void rc_sync_to_thread(const RuntimeConfig& rc);
112 friend class RuntimeConfigHelper;
113 friend class RuntimeConfigLocationHelper;
114 friend class RuntimeConfigObjectHelper;
115 friend class RuntimeConfigClosureHelper;
116 friend class RuntimeConfigElementHelper;
117 friend class RuntimeConfigStackHelper;
118};
119
120#endif // _QORE_RUNTIMECONFIG_H
the implementation of Qore's object data type, reference counted, dynamically-allocated only
Definition QoreObject.h:61
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition QoreProgram.h:133
Stack location element abstract class.
Definition ExceptionSink.h:426
RAII helper to temporarily change closure environment in RuntimeConfig.
Definition RuntimeConfig.h:225
RAII helper to temporarily change implicit element in RuntimeConfig.
Definition RuntimeConfig.h:244
RAII helper to manage RuntimeConfig and sync on destruction.
Definition RuntimeConfig.h:165
Runtime configuration passed through the evaluation call chain.
Definition RuntimeConfig.h:49
friend RuntimeConfig & rc_get_tls_ref()
Get a direct reference to the thread-local RuntimeConfig.
friend RuntimeConfig rc_get_current()
Get the current runtime configuration from thread-local storage.
friend RuntimeConfig rc_get_parse_time()
Get a minimal RuntimeConfig for parse-time constant folding.
friend void rc_sync_to_thread(const RuntimeConfig &rc)
Sync runtime config changes back to thread-local storage.
friend RuntimeConfig & rc_get_current_ref()
Get a reference to the thread-local RuntimeConfig updated with current values.
RAII helper to temporarily change location in RuntimeConfig.
Definition RuntimeConfig.h:184
RAII helper to temporarily change object/class context in RuntimeConfig.
Definition RuntimeConfig.h:209
RAII helper to push/pop stack location in RuntimeConfig and sync to TLS.
Definition RuntimeConfig.h:265
uint64_t q_rt_flags_t
runtime code execution flags
Definition common.h:270
DLLEXPORT QoreProgram * getProgram()
returns the current QoreProgram