OpenASIP
2.0
src
applibs
Interpreter
ConditionScript.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 ConditionScript.cc
26
*
27
* Definition of ConditionScript class.
28
*
29
* @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30
* @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
31
*/
32
33
#include <string>
34
using
std::string;
35
#include <vector>
36
using
std::vector;
37
38
#include "
ConditionScript.hh
"
39
40
/**
41
* Constructor.
42
*
43
* @param interpreter Interpreter for the script.
44
* @param scriptLine A line of script.
45
*/
46
ConditionScript::ConditionScript
(
47
ScriptInterpreter
* interpreter,
48
std::string scriptLine) :
Script
(interpreter, scriptLine) {
49
}
50
51
/**
52
* Constructor.
53
*
54
* @param interpreter Interpreter for the script.
55
* @param script The script.
56
*/
57
ConditionScript::ConditionScript
(
58
ScriptInterpreter
* interpreter,
59
std::vector<std::string>& script) :
Script
(interpreter, script) {
60
}
61
62
/**
63
* Destructor.
64
*/
65
ConditionScript::~ConditionScript
() {
66
}
67
68
/**
69
* Tests if condition is true of false.
70
*
71
* @return True, if condition is true, false otherwise.
72
* @exception NumberFormatException If DataObject operation fails.
73
* @exception ScriptExecutionFailure If script execution fails.
74
*/
75
bool
76
ConditionScript::conditionOk
() {
77
vector<string> scripts =
script
();
78
if
(scripts.size() == 1 && scripts[0] ==
""
) {
79
return
true
;
80
}
81
82
DataObject
obj =
execute
();
83
if
(obj.
stringValue
() ==
"0"
) {
84
interpreter_
->
setResult
(
""
);
85
return
false
;
86
}
87
interpreter_
->
setResult
(
""
);
88
return
true
;
89
}
90
91
/**
92
* Copies the condition script.
93
*
94
* Allows dynamically bound copy.
95
*
96
* @return a new instance which is identical to this.
97
*/
98
ConditionScript
*
99
ConditionScript::copy
()
const
{
100
return
new
ConditionScript
(*
this
);
101
}
102
Script::execute
virtual DataObject execute()
Definition:
Script.cc:82
Script::script
virtual std::vector< std::string > script() const
Definition:
Script.cc:106
DataObject
Definition:
DataObject.hh:50
DataObject::stringValue
virtual std::string stringValue() const
Definition:
DataObject.cc:344
ConditionScript::copy
virtual ConditionScript * copy() const
Definition:
ConditionScript.cc:99
ConditionScript::~ConditionScript
virtual ~ConditionScript()
Definition:
ConditionScript.cc:65
ConditionScript.hh
ConditionScript::conditionOk
virtual bool conditionOk()
Definition:
ConditionScript.cc:76
ConditionScript
Definition:
ConditionScript.hh:45
ConditionScript::ConditionScript
ConditionScript(ScriptInterpreter *interpreter, std::string scriptLine)
Definition:
ConditionScript.cc:46
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
Generated by
1.8.17