OpenASIP  2.0
ExpressionScript.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file ExpressionScript.cc
26  *
27  * Definition of ExpressionScript class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  */
31 
32 #include <string>
33 using std::string;
34 #include <vector>
35 using std::vector;
36 
37 #include "ExpressionScript.hh"
38 
39 /**
40  * Constructor.
41  *
42  * @param interpreter The interpreter for the script.
43  * @param scriptLine A line of script.
44  */
46  ScriptInterpreter* interpreter,
47  std::string scriptLine) : Script(interpreter, scriptLine) {
48 }
49 
50 /**
51  * Constructor.
52  *
53  * @param interpreter The interpreter for the script.
54  * @param script The script.
55  */
57  ScriptInterpreter* interpreter,
58  std::vector<std::string>& script) : Script(interpreter, script) {
59 }
60 
61 /**
62  * Destructor.
63  */
65 }
66 
67 /**
68  * Returns true, if the result of the script has changed.
69  *
70  * @return True, if the result of the script has changed, otherwise false.
71  * @exception ScriptExecutionFailure If the execution of the script fails.
72  * @exception NumberFormatException If DataObject operation fails.
73  */
74 bool
76  DataObject obj;
77  try {
78  obj = lastResult();
79  } catch (const InvalidData& i) {
80  return false;
81  }
82 
83  DataObject exec = execute();
84 
86 
87  if (obj != exec) {
88  return true;
89  }
90  return false;
91 }
Script::lastResult
DataObject lastResult()
Script::execute
virtual DataObject execute()
Definition: Script.cc:82
ExpressionScript::~ExpressionScript
virtual ~ExpressionScript()
Definition: ExpressionScript.cc:64
DataObject
Definition: DataObject.hh:50
ExpressionScript::ExpressionScript
ExpressionScript(ScriptInterpreter *interpreter, std::string scriptLine)
Definition: ExpressionScript.cc:45
InvalidData
Definition: Exception.hh:149
Script::interpreter_
ScriptInterpreter * interpreter_
Interpreter executing the commands.
Definition: Script.hh:58
Script
Definition: Script.hh:47
ScriptInterpreter::setResult
virtual void setResult(DataObject *result)
Definition: ScriptInterpreter.cc:128
ScriptInterpreter
Definition: ScriptInterpreter.hh:55
ExpressionScript::resultChanged
bool resultChanged()
Definition: ExpressionScript.cc:75
ExpressionScript.hh