root / trunk / compiler / ooasCompiler / src / org / momut / ooas / ast / statements / QualitativeConstraintStatement.java @ 7
1 |
/**
|
---|---|
2 |
*
|
3 |
* OOAS Compiler
|
4 |
*
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology.
|
6 |
* This code is based on the C# Version of the OOAS Compiler, which is
|
7 |
* copyright 2015 by the Institute of Software Technology, Graz University
|
8 |
* of Technology with portions copyright by the AIT Austrian Institute of
|
9 |
* Technology. All rights reserved.
|
10 |
*
|
11 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
|
12 |
*
|
13 |
* If you modify the file please update the list of contributors below to in-
|
14 |
* clude your name. Please also stick to the coding convention of using TABs
|
15 |
* to do the basic (block-level) indentation and spaces for anything after
|
16 |
* that. (Enable the display of special chars and it should be pretty obvious
|
17 |
* what this means.) Also, remove all trailing whitespace.
|
18 |
*
|
19 |
* Contributors:
|
20 |
* Willibald Krenn (AIT)
|
21 |
* Stephan Zimmerer (AIT)
|
22 |
* Markus Demetz (AIT)
|
23 |
* Christoph Czurda (AIT)
|
24 |
*
|
25 |
*/
|
26 |
|
27 |
|
28 |
package org.momut.ooas.ast.statements; |
29 |
|
30 |
import org.momut.ooas.ast.IAstVisitor; |
31 |
import org.momut.ooas.ast.identifiers.Identifier; |
32 |
import org.momut.ooas.utils.exceptions.ArgumentException; |
33 |
|
34 |
///////////////////////////////////////////////
|
35 |
/// Qualitative Constraints
|
36 |
///
|
37 |
public final class QualitativeConstraintStatement extends Statement |
38 |
{ |
39 |
public enum QualitativeConstraintOperation { Equal, Deriv, Sum, Prod, Diff } |
40 |
|
41 |
private Identifier m_variable0;
|
42 |
private Identifier m_variable1;
|
43 |
private Identifier m_variable2;
|
44 |
private final QualitativeConstraintOperation m_operation; |
45 |
public boolean tag = false; // says that this is an obs assignment (important for prolog code target) |
46 |
|
47 |
public Identifier variable0() { return m_variable0; } |
48 |
public Identifier variable1() { return m_variable1; } |
49 |
public Identifier variable2() { return m_variable2; } |
50 |
public QualitativeConstraintOperation operation() { return m_operation; } |
51 |
|
52 |
public QualitativeConstraintStatement(Identifier var0, Identifier var1, QualitativeConstraintOperation op, int aline, int apos) |
53 |
{ |
54 |
super (StatementKind.QualConstraint, aline, apos);
|
55 |
if (op == QualitativeConstraintOperation.Diff
|
56 |
|| op == QualitativeConstraintOperation.Prod |
57 |
|| op == QualitativeConstraintOperation.Sum) |
58 |
throw new ArgumentException(); |
59 |
m_variable0 = var0; |
60 |
m_variable1 = var1; |
61 |
m_variable2 = null;
|
62 |
m_operation = op; |
63 |
} |
64 |
|
65 |
public QualitativeConstraintStatement(QualitativeConstraintStatement toCopy)
|
66 |
{ |
67 |
super (toCopy);
|
68 |
m_variable0 = toCopy.m_variable0; |
69 |
m_variable1 = toCopy.m_variable1; |
70 |
m_variable2 = toCopy.m_variable2; |
71 |
m_operation = toCopy.m_operation; |
72 |
tag = toCopy.tag; |
73 |
} |
74 |
|
75 |
|
76 |
public QualitativeConstraintStatement(Identifier var0, Identifier var1, Identifier var2, QualitativeConstraintOperation op, int aline, int apos) |
77 |
{ |
78 |
super (StatementKind.QualConstraint, aline, apos);
|
79 |
if (op == QualitativeConstraintOperation.Deriv
|
80 |
|| op == QualitativeConstraintOperation.Equal) |
81 |
throw new ArgumentException(); |
82 |
m_variable0 = var0; |
83 |
m_variable1 = var1; |
84 |
m_variable2 = var2; |
85 |
m_operation = op; |
86 |
} |
87 |
|
88 |
@Override
|
89 |
public /*override*/ void Accept(IAstVisitor visitor) |
90 |
{ |
91 |
visitor.visit(this);
|
92 |
} |
93 |
|
94 |
@Override
|
95 |
public /*override*/ Statement Clone() |
96 |
{ |
97 |
return new QualitativeConstraintStatement(this); |
98 |
} |
99 |
|
100 |
public void SetVariable0(Identifier newVal) |
101 |
{ |
102 |
m_variable0 = newVal; |
103 |
} |
104 |
|
105 |
public void SetVariable1(Identifier newVal) |
106 |
{ |
107 |
m_variable1 = newVal; |
108 |
} |
109 |
|
110 |
public void SetVariable2(Identifier newVal) |
111 |
{ |
112 |
m_variable2 = newVal; |
113 |
} |
114 |
} |