Qore Programming Language  0.8.11.1
CallReferenceNode.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  CallReferenceNode.h
4 
5  Qore Programming Language
6 
7  Copyright (C) 2003 - 2014 David Nichols
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_FUNCTIONREFERENCENODE_H
33 
34 #define _QORE_FUNCTIONREFERENCENODE_H
35 
37 
40 private:
42 
44  DLLLOCAL virtual AbstractQoreNode *realCopy() const;
45 
47 
49  DLLLOCAL virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
50 
52 
54  DLLLOCAL virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
55 
56 protected:
58 
60  DLLLOCAL virtual AbstractQoreNode *evalImpl(ExceptionSink *xsink) const;
61 
63 
65  DLLLOCAL virtual AbstractQoreNode *evalImpl(bool &needs_deref, ExceptionSink *xsink) const;
66 
68 
70  DLLLOCAL virtual int64 bigIntEvalImpl(ExceptionSink *xsink) const;
71 
73 
75  DLLLOCAL virtual int integerEvalImpl(ExceptionSink *xsink) const;
76 
78 
80  DLLLOCAL virtual bool boolEvalImpl(ExceptionSink *xsink) const;
81 
83 
85  DLLLOCAL virtual double floatEvalImpl(ExceptionSink *xsink) const;
86 
88  DLLLOCAL AbstractCallReferenceNode(bool n_needs_eval, bool n_there_can_be_only_one, qore_type_t n_type = NT_FUNCREF);
89 
90 public:
91  DLLLOCAL AbstractCallReferenceNode(bool n_needs_eval = false, qore_type_t n_type = NT_FUNCREF);
92 
93  DLLLOCAL virtual ~AbstractCallReferenceNode();
94 
96 
98  DLLEXPORT virtual bool getAsBoolImpl() const;
99 
101 
107  DLLLOCAL virtual int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const;
108 
110 
117  DLLLOCAL virtual QoreString *getAsString(bool &del, int foff, ExceptionSink *xsink) const;
118 
120  DLLLOCAL virtual const char *getTypeName() const;
121 
122  DLLLOCAL static const char *getStaticTypeName() {
123  return "call reference";
124  }
125 };
126 
129 public:
131  DLLLOCAL ResolvedCallReferenceNode(bool n_needs_eval = false, qore_type_t n_type = NT_FUNCREF);
132 
134 
139  DLLLOCAL virtual AbstractQoreNode *exec(const QoreListNode *args, ExceptionSink *xsink) const = 0;
140 
141  DLLLOCAL virtual int64 bigIntExec(const QoreListNode *args, ExceptionSink *xsink) const {
142  ReferenceHolder<AbstractQoreNode> rv(exec(args, xsink), xsink);
143  return rv ? rv->getAsBigInt() : 0;
144  }
145 
146  DLLLOCAL virtual int intExec(const QoreListNode *args, ExceptionSink *xsink) const {
147  ReferenceHolder<AbstractQoreNode> rv(exec(args, xsink), xsink);
148  return rv ? rv->getAsInt() : 0;
149  }
150 
151  DLLLOCAL virtual bool boolExec(const QoreListNode *args, ExceptionSink *xsink) const {
152  ReferenceHolder<AbstractQoreNode> rv(exec(args, xsink), xsink);
153  return rv ? rv->getAsBool() : false;
154  }
155 
156  DLLLOCAL virtual double floatExec(const QoreListNode *args, ExceptionSink *xsink) const {
157  ReferenceHolder<AbstractQoreNode> rv(exec(args, xsink), xsink);
158  return rv ? rv->getAsFloat() : 0.0;
159  }
160 
162 
165  DLLLOCAL virtual QoreProgram *getProgram() const;
166 
167  DLLLOCAL virtual class QoreFunction *getFunction() = 0;
168 
169  DLLLOCAL ResolvedCallReferenceNode *refRefSelf() const {
170  ref();
171  return const_cast<ResolvedCallReferenceNode *>(this);
172  }
173 };
174 
175 #endif
virtual DLLLOCAL QoreProgram * getProgram() const
returns a pointer to the QoreProgram object associated with this reference (can be 0) ...
virtual DLLLOCAL int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const
concatenate the verbose string representation of the value to an existing QoreString ...
DLLEXPORT bool getAsBool() const
returns the boolean value of the object
virtual DLLLOCAL AbstractQoreNode * exec(const QoreListNode *args, ExceptionSink *xsink) const =0
pure virtual function for executing the function reference
virtual DLLLOCAL const char * getTypeName() const
returns the type name as a c string
DLLEXPORT double getAsFloat() const
returns the float value of the object
virtual DLLLOCAL AbstractQoreNode * evalImpl(ExceptionSink *xsink) const
this function should never be called for function references; this function should never be called di...
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:55
DLLLOCAL AbstractCallReferenceNode(bool n_needs_eval, bool n_there_can_be_only_one, qore_type_t n_type=NT_FUNCREF)
protected constructor for subclasses that are not reference-counted
const qore_type_t NT_FUNCREF
type value for AbstractCallReferenceNode
Definition: node_types.h:71
virtual DLLEXPORT bool getAsBoolImpl() const
returns false unless perl-boolean-evaluation is enabled, in which case it returns true ...
base class for call references, reference-counted, dynamically allocated only
Definition: CallReferenceNode.h:39
virtual DLLLOCAL int integerEvalImpl(ExceptionSink *xsink) const
this function should never be called for function references; this function should never be called di...
DLLEXPORT int getAsInt() const
returns the integer value of the object
DLLEXPORT int64 getAsBigInt() const
returns the 64-bit integer value of the object
signed short qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:67
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:50
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
DLLLOCAL ResolvedCallReferenceNode(bool n_needs_eval=false, qore_type_t n_type=NT_FUNCREF)
constructor is not exported outside the library
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only ...
Definition: QoreProgram.h:103
DLLEXPORT void ref() const
increments the reference count
virtual DLLLOCAL double floatEvalImpl(ExceptionSink *xsink) const
this function should never be called for function references; this function should never be called di...
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:43
base class for resolved call references
Definition: CallReferenceNode.h:128
virtual DLLLOCAL bool boolEvalImpl(ExceptionSink *xsink) const
this function should never be called for function references; this function should never be called di...
virtual DLLLOCAL int64 bigIntEvalImpl(ExceptionSink *xsink) const
this function should never be called for function references; this function should never be called di...
a templated class to manage a reference count of an object that can throw a Qore-language exception w...
Definition: ReferenceHolder.h:51