Method: clone()

1: /*******************************************************************************
2: *
3: *        Copyright (c) 2009 Fujitsu Services Ltd.
4: *
5: *        Author: Nick Battle
6: *
7: *        This file is part of VDMJ.
8: *
9: *        VDMJ is free software: you can redistribute it and/or modify
10: *        it under the terms of the GNU General Public License as published by
11: *        the Free Software Foundation, either version 3 of the License, or
12: *        (at your option) any later version.
13: *
14: *        VDMJ is distributed in the hope that it will be useful,
15: *        but WITHOUT ANY WARRANTY; without even the implied warranty of
16: *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: *        GNU General Public License for more details.
18: *
19: *        You should have received a copy of the GNU General Public License
20: *        along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21: *
22: ******************************************************************************/
23:
24: package org.overture.interpreter.traces;
25:
26: import java.util.Map;
27:
28: import org.overture.ast.analysis.AnalysisException;
29: import org.overture.ast.analysis.intf.IAnalysis;
30: import org.overture.ast.analysis.intf.IAnswer;
31: import org.overture.ast.analysis.intf.IQuestion;
32: import org.overture.ast.analysis.intf.IQuestionAnswer;
33: import org.overture.ast.factory.AstFactoryTC;
34: import org.overture.ast.node.INode;
35: import org.overture.ast.statements.PStm;
36: import org.overture.ast.statements.PStmBase;
37: import org.overture.ast.typechecker.NameScope;
38: import org.overture.interpreter.runtime.Context;
39: import org.overture.interpreter.values.Value;
40: import org.overture.interpreter.values.VoidValue;
41: import org.overture.typechecker.FlatEnvironment;
42:
43: public class TraceVariableStatement extends PStmBase
44: {
45:         private static final long serialVersionUID = 1L;
46:         public final TraceVariable var;
47:
48:         @SuppressWarnings("deprecation")
49:         public TraceVariableStatement(TraceVariable var)
50:         {
51:                 super(var.name.getLocation(), null);
52:                 this.var = var;
53:         }
54:
55:         public void typeCheck(FlatEnvironment env, NameScope scope)
56:         {
57:                 env.add(AstFactoryTC.newALocalDefinition(var.name.getLocation(), var.name, scope, var.type));
58:         }
59:
60:         public static Value eval(TraceVariableStatement stmt, Context ctxt)
61:         {
62:                 stmt.getLocation().hit();
63:                 Value val = stmt.var.value;
64:
65:                 if (stmt.var.clone)
66:                 {
67:                         val = (Value) stmt.var.value.clone(); // To allow updates to objects
68:                 }
69:
70:                 ctxt.put(stmt.var.name, val);
71:                 return new VoidValue();
72:         }
73:
74:         // @Override
75:         public String toString()
76:         {
77:                 return var.toString();
78:         }
79:
80:         @Override
81:         public PStm clone()
82:         {
83:                 return null;
84:         }
85:
86:         @Override
87:         public PStm clone(Map<INode, INode> oldToNewMap)
88:         {
89:                 return null;
90:         }
91:
92:         @Override
93:         public void apply(IAnalysis analysis) throws AnalysisException
94:         {
95:
96:         }
97:
98:         @Override
99:         public <A> A apply(IAnswer<A> caller) throws AnalysisException
100:         {
101:                 return null;
102:         }
103:
104:         @Override
105:         public <Q> void apply(IQuestion<Q> caller, Q question)
106:                         throws AnalysisException
107:         {
108:
109:         }
110:
111:         @Override
112:         public <Q, A> A apply(IQuestionAnswer<Q, A> caller, Q question)
113:                         throws AnalysisException
114:         {
115:                 return null;
116:         }
117:
118: }