Revision 7
Added by Willibald K. over 8 years ago
OoaSymbolSortVisitor.java | ||
---|---|---|
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 |
*/
|
|
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 | 26 |
|
27 | 27 |
|
28 |
package org.momut.ooas.visitors; |
|
29 |
|
|
30 |
import java.util.Collections; |
|
28 |
package org.momut.ooas.visitors; |
|
31 | 29 |
|
30 |
import java.util.Collections; |
|
31 |
|
|
32 | 32 |
import org.momut.ooas.ast.identifiers.Identifier; |
33 | 33 |
import org.momut.ooas.ast.identifiers.IdentifierKind; |
34 | 34 |
import org.momut.ooas.ast.identifiers.MainModule; |
... | ... | |
38 | 38 |
import org.momut.ooas.ast.types.TypeKind; |
39 | 39 |
import org.momut.ooas.parser.ParserState; |
40 | 40 |
import org.momut.ooas.utils.exceptions.ArgumentException; |
41 |
|
|
42 |
public final class OoaSymbolSortVisitor extends OoaCompleteAstTraversalVisitor |
|
43 |
{ |
|
44 |
/* Sorting of enums is not necessarily a good idea in terms of the user wanting to know what's going on |
|
45 |
* however, we need to do this for the ulysses prolog target - otherwise mutations won't be correct.. |
|
46 |
* (regardeless in what order the enum symbols were declared, the order must be the same - then we can |
|
47 |
* map them to ints) |
|
48 |
*/ |
|
49 |
@Override |
|
50 |
public void visit(EnumType enumType) |
|
51 |
{ |
|
52 |
Collections.sort(enumType.listOfEnumSymbols()); |
|
53 |
super.visit(enumType); |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public void visit(MainModule mainModule) |
|
58 |
{ |
|
59 |
for (Identifier s: mainModule.symbolTable().symbolList()) |
|
60 |
{ |
|
61 |
if (s.kind() == IdentifierKind.TypeIdentifier && |
|
62 |
((TypeIdentifier)s).type().kind() == TypeKind.OoActionSystemType) |
|
63 |
{ |
|
64 |
OoActionSystemType ooa = (OoActionSystemType)((TypeIdentifier)s).type(); |
|
65 |
ooa.symbols().Sort(); |
|
66 |
} |
|
67 |
} |
|
68 |
mainModule.symbolTable().Sort(); |
|
69 |
super.visit(mainModule); |
|
70 |
} |
|
71 |
|
|
72 |
public OoaSymbolSortVisitor(ParserState aState) |
|
73 |
{ |
|
74 |
super(aState, false); |
|
75 |
if (aState == null) |
|
76 |
throw new ArgumentException(); |
|
77 |
} |
|
78 |
} |
|
41 |
|
|
42 |
public final class OoaSymbolSortVisitor extends OoaCompleteAstTraversalVisitor |
|
43 |
{ |
|
44 |
/* Sorting of enums is not necessarily a good idea in terms of the user wanting to know what's going on |
|
45 |
* however, we need to do this for the ulysses prolog target - otherwise mutations won't be correct.. |
|
46 |
* (regardeless in what order the enum symbols were declared, the order must be the same - then we can |
|
47 |
* map them to ints) |
|
48 |
*/ |
|
49 |
@Override |
|
50 |
public void visit(EnumType enumType) |
|
51 |
{ |
|
52 |
Collections.sort(enumType.listOfEnumSymbols()); |
|
53 |
super.visit(enumType); |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public void visit(MainModule mainModule) |
|
58 |
{ |
|
59 |
for (Identifier s: mainModule.symbolTable().symbolList()) |
|
60 |
{ |
|
61 |
if (s.kind() == IdentifierKind.TypeIdentifier && |
|
62 |
((TypeIdentifier)s).type().kind() == TypeKind.OoActionSystemType) |
|
63 |
{ |
|
64 |
OoActionSystemType ooa = (OoActionSystemType)((TypeIdentifier)s).type(); |
|
65 |
ooa.symbols().Sort(); |
|
66 |
} |
|
67 |
} |
|
68 |
mainModule.symbolTable().Sort(); |
|
69 |
super.visit(mainModule); |
|
70 |
} |
|
71 |
|
|
72 |
public OoaSymbolSortVisitor(ParserState aState) |
|
73 |
{ |
|
74 |
super(aState, false); |
|
75 |
if (aState == null) |
|
76 |
throw new ArgumentException(); |
|
77 |
} |
|
78 |
} |
Also available in: Unified diff
changing java, cpp, hpp files to unix line endings