PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
Evaluator-es.h
Go to the documentation of this file.
1//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3// Name: src/base/Evaluator.h
4// Purpose: Defines an class that can evaluate PNodes
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2003--2013 Shane T. Mueller <smueller@obereed.net>
7// License: GPL 2
8//
9//
10//
11//
12// This file is part of the PEBL project.
13//
14// PEBL is free software; you can redistribute it and/or modify
15// it under the terms of the GNU General Public License as published by
16// the Free Software Foundation; either version 2 of the License, or
17// (at your option) any later version.
18//
19// PEBL is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22// GNU General Public License for more details.
23//
24// You should have received a copy of the GNU General Public License
25// along with PEBL; if not, write to the Free Software
26// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
29#ifndef __EVALUATOR_H__
30#define __EVALUATOR_H__
31
32#include <stack>
33#include <list>
34//#include "PNode.h"
35#include "Variant.h"
36
37#include "FunctionMap.h"
38#include "../utility/PEBLPath.h"
39#include "VariableMap.h"
40#include "../utility/PError.h"
41//#include "../devices/PEventLoop.h"
42
43
44class PNode;
45class OpNode;
46class DataNode;
47class Variant;
48class FunctionMap;
49class VariableMap;
50class PEventLoop;
51
52
53//
54void EvalWrapper(void * node);
55
56
59{
60 // PEventLoop needs access to scope management internals for event callbacks
61 friend class PEventLoop;
62
63public:
64
65 Evaluator();
66 Evaluator(Variant & stacktop, string scope);
67 ~Evaluator();
68
69 //this is in Evaluator.h, but not here
70
71 void CallFunction(const OpNode * node);
72
73 bool Evaluate1();
74 bool Evaluate1(const PNode * node);
75 bool Evaluate1(const OpNode * node);
76 bool Evaluate1(const DataNode * node);
77
78
79
80 void Push(Variant v);
81 Variant Pop();
82 Variant Peek();
83
84 void NodeStackPush(const PNode * node);
85
86 int GetNodeStackDepth(){return mNodeStack.size();};
87 int GetStackDepth(){return mStack.size();};
88
89
91
92 bool IsVariableName(Variant v);
93
100
105
107
109
110
111
117 static const PNode * gEvalNode;
118
119
121
122
123
124private:
125
126 //This list keeps track of the call sequence
127 //of evaluators, so that when an error is found,
128 //all the calls can be traced back. It is a list
129 //instead of a stack so that we can examine it easily.
130
131
132
134 std::stack<Variant> mStack;
135
136
137
138 std::stack<const PNode*> mNodeStack;
139
143 unsigned int mStackMax;
144
146 VariableMap mLocalVariableMap;
147
148 //this keeps a stack of the local variable maps so
149 //we can have a single async evaluator.
150 std::stack<VariableMap> mVariableMapStack;
151
154 std::string mScope;
155
156 //Keep a scope stack for debugging purposes.
157 std::stack<std::string> mScopeStack;
158};
159
160
161#endif
void EvalWrapper(void *node)
This class has got everything you need to evaluate stuff.
static const PNode * gEvalNode
void NodeStackPush(const PNode *node)
static PEBLPath gPath
bool Evaluate1()
PEventLoop * GetEventLoop()
void Push(Variant v)
static PCallStack gCallStack
static PEventLoop * mEventLoop
int GetNodeStackDepth()
bool IsVariableName(Variant v)
static VariableMap gGlobalVariableMap
Variant Peek()
Variant Pop()
static FunctionMap mFunctionMap
Initiate some static member data.
void CallFunction(const OpNode *node)
int GetStackDepth()
Definition PNode.h:45