1
|
/**
|
2
|
*
|
3
|
* OOAS Compiler (Deprecated)
|
4
|
*
|
5
|
* Copyright 2015, Institute for Software Technology, Graz University of
|
6
|
* Technology. Portions are copyright 2015 by the AIT Austrian Institute
|
7
|
* of Technology. All rights reserved.
|
8
|
*
|
9
|
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
|
10
|
*
|
11
|
* Please notice that this version of the OOAS compiler is considered de-
|
12
|
* precated. Only the Java version is maintained.
|
13
|
*
|
14
|
* Contributors:
|
15
|
* Willibald Krenn (TU Graz/AIT)
|
16
|
* Stefan Tiran (TU Graz/AIT)
|
17
|
*/
|
18
|
|
19
|
using System;
|
20
|
using System.Collections.Generic;
|
21
|
using System.Text;
|
22
|
|
23
|
namespace TUG.Mogentes
|
24
|
{
|
25
|
public sealed class OoaTypeRenameVisitor : OoaCompleteAstTraversalVisitor
|
26
|
{
|
27
|
public override void visit(TypeIdentifier typeIdentifier)
|
28
|
{
|
29
|
if (!typeIdentifier.type.isAnonymousType)
|
30
|
typeIdentifier.prefix = m_ParserState.namesTypePrefix;
|
31
|
|
32
|
base.visit(typeIdentifier);
|
33
|
}
|
34
|
|
35
|
public OoaTypeRenameVisitor(ParserState aState)
|
36
|
: base(aState, false)
|
37
|
{
|
38
|
if (aState == null)
|
39
|
throw new ArgumentException();
|
40
|
if (aState.namesTypePrefix == String.Empty)
|
41
|
throw new ArgumentException();
|
42
|
}
|
43
|
}
|
44
|
|
45
|
public sealed class OoaSymbolSortVisitor : OoaCompleteAstTraversalVisitor
|
46
|
{
|
47
|
/* Sorting of enums is not necessarily a good idea in terms of the user wanting to know what's going on
|
48
|
* however, we need to do this for the ulysses prolog target - otherwise mutations won't be correct..
|
49
|
* (regardeless in what order the enum symbols were declared, the order must be the same - then we can
|
50
|
* map them to ints)
|
51
|
*/
|
52
|
public override void visit(EnumType enumType)
|
53
|
{
|
54
|
enumType.listOfEnumSymbols.Sort();
|
55
|
|
56
|
base.visit(enumType);
|
57
|
}
|
58
|
|
59
|
public override void visit(MainModule mainModule)
|
60
|
{
|
61
|
foreach (var s in mainModule.symbolTable.symbolList)
|
62
|
{
|
63
|
if (s.kind == IdentifierKind.TypeIdentifier &&
|
64
|
((TypeIdentifier)s).type.kind == TypeKind.OoActionSystemType)
|
65
|
{
|
66
|
OoActionSystemType ooa = (OoActionSystemType)((TypeIdentifier)s).type;
|
67
|
ooa.symbols.Sort();
|
68
|
}
|
69
|
}
|
70
|
mainModule.symbolTable.Sort();
|
71
|
base.visit(mainModule);
|
72
|
}
|
73
|
|
74
|
public OoaSymbolSortVisitor(ParserState aState)
|
75
|
: base(aState, false)
|
76
|
{
|
77
|
if (aState == null)
|
78
|
throw new ArgumentException();
|
79
|
}
|
80
|
}
|
81
|
}
|