All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CallReferenceNode.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
CallReferenceNode.h
Qore Programming Language
Copyright 2003 - 2013 David Nichols
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _QORE_FUNCTIONREFERENCENODE_H
#define _QORE_FUNCTIONREFERENCENODE_H
class AbstractCallReferenceNode : public AbstractQoreNode {
private:
DLLLOCAL virtual AbstractQoreNode *realCopy() const;
DLLLOCAL virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
DLLLOCAL virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
protected:
DLLLOCAL virtual AbstractQoreNode *evalImpl(ExceptionSink *xsink) const;
DLLLOCAL virtual AbstractQoreNode *evalImpl(bool &needs_deref, ExceptionSink *xsink) const;
DLLLOCAL virtual int64 bigIntEvalImpl(ExceptionSink *xsink) const;
DLLLOCAL virtual int integerEvalImpl(ExceptionSink *xsink) const;
DLLLOCAL virtual bool boolEvalImpl(ExceptionSink *xsink) const;
DLLLOCAL virtual double floatEvalImpl(ExceptionSink *xsink) const;
DLLLOCAL AbstractCallReferenceNode(bool n_needs_eval, bool n_there_can_be_only_one, qore_type_t n_type = NT_FUNCREF);
public:
DLLLOCAL AbstractCallReferenceNode(bool n_needs_eval = false, qore_type_t n_type = NT_FUNCREF);
DLLLOCAL virtual ~AbstractCallReferenceNode();
DLLEXPORT virtual bool getAsBoolImpl() const;
DLLLOCAL virtual int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const;
DLLLOCAL virtual QoreString *getAsString(bool &del, int foff, ExceptionSink *xsink) const;
DLLLOCAL virtual const char *getTypeName() const;
DLLLOCAL static const char *getStaticTypeName() {
return "call reference";
}
};
class ResolvedCallReferenceNode : public AbstractCallReferenceNode {
public:
DLLLOCAL ResolvedCallReferenceNode(bool n_needs_eval = false, qore_type_t n_type = NT_FUNCREF);
DLLLOCAL virtual AbstractQoreNode *exec(const QoreListNode *args, ExceptionSink *xsink) const = 0;
DLLLOCAL virtual int64 bigIntExec(const QoreListNode *args, ExceptionSink *xsink) const {
ReferenceHolder<AbstractQoreNode> rv(exec(args, xsink), xsink);
return rv ? rv->getAsBigInt() : 0;
}
DLLLOCAL virtual int intExec(const QoreListNode *args, ExceptionSink *xsink) const {
ReferenceHolder<AbstractQoreNode> rv(exec(args, xsink), xsink);
return rv ? rv->getAsInt() : 0;
}
DLLLOCAL virtual bool boolExec(const QoreListNode *args, ExceptionSink *xsink) const {
ReferenceHolder<AbstractQoreNode> rv(exec(args, xsink), xsink);
return rv ? rv->getAsBool() : false;
}
DLLLOCAL virtual double floatExec(const QoreListNode *args, ExceptionSink *xsink) const {
ReferenceHolder<AbstractQoreNode> rv(exec(args, xsink), xsink);
return rv ? rv->getAsFloat() : 0.0;
}
DLLLOCAL virtual QoreProgram *getProgram() const;
DLLLOCAL virtual class QoreFunction *getFunction() = 0;
DLLLOCAL ResolvedCallReferenceNode *refRefSelf() const {
ref();
return const_cast<ResolvedCallReferenceNode *>(this);
}
};
#endif