Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tla2bAST
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
tla2bAST
Commits
6633e58d
Commit
6633e58d
authored
9 months ago
by
dgelessus
Browse files
Options
Downloads
Patches
Plain Diff
Update for simplified AST for record field identifiers
parent
1953744e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/tla2b/types/StructType.java
+1
-2
1 addition, 2 deletions
src/main/java/de/tla2b/types/StructType.java
src/main/java/de/tla2bAst/BAstCreator.java
+10
-13
10 additions, 13 deletions
src/main/java/de/tla2bAst/BAstCreator.java
with
11 additions
and
15 deletions
src/main/java/de/tla2b/types/StructType.java
+
1
−
2
View file @
6633e58d
...
...
@@ -3,7 +3,6 @@ package de.tla2b.types;
import
de.be4.classicalb.core.parser.node.*
;
import
de.tla2b.exceptions.UnificationException
;
import
de.tla2b.output.TypeVisitorInterface
;
import
de.tla2bAst.BAstCreator
;
import
java.util.*
;
import
java.util.Map.Entry
;
...
...
@@ -189,7 +188,7 @@ public class StructType extends AbstractHasFollowers {
List
<
PRecEntry
>
recList
=
new
ArrayList
<>();
for
(
Entry
<
String
,
TLAType
>
entry
:
types
.
entrySet
())
{
ARecEntry
rec
=
new
ARecEntry
();
rec
.
setIdentifier
(
BAstCreator
.
create
Identifier
Node
(
entry
.
getKey
()));
rec
.
setIdentifier
(
new
T
Identifier
Literal
(
entry
.
getKey
()));
if
(
extensible
)
{
AMultOrCartExpression
cart
=
new
AMultOrCartExpression
();
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/tla2bAst/BAstCreator.java
+
10
−
13
View file @
6633e58d
...
...
@@ -676,7 +676,7 @@ public class BAstCreator extends BuiltInOPs
StringNode
stringNode
=
(
StringNode
)
list
.
poll
();
// TODO rename field name
String
fieldName
=
stringNode
.
getRep
().
toString
();
select
.
setIdentifier
(
create
Identifier
Node
(
fieldName
));
select
.
setIdentifier
(
new
T
Identifier
Literal
(
fieldName
));
return
evalAtNode
(
list
,
structType
.
getType
(
fieldName
),
select
);
}
}
...
...
@@ -1531,9 +1531,8 @@ public class BAstCreator extends BuiltInOPs
if
(
struct
.
isExtensible
())
{
for
(
int
i
=
0
;
i
<
struct
.
getFields
().
size
();
i
++)
{
String
fieldName
=
struct
.
getFields
().
get
(
i
);
// name
AIdentifierExpression
field
=
createIdentifierNode
(
fieldName
);
ARecEntry
rec
=
new
ARecEntry
();
rec
.
setIdentifier
(
field
);
rec
.
setIdentifier
(
new
TIdentifierLiteral
(
fieldName
)
);
AMultOrCartExpression
cart
=
new
AMultOrCartExpression
();
cart
.
setLeft
(
new
ABoolSetExpression
());
if
(
pairTable
.
containsKey
(
fieldName
))
{
...
...
@@ -1547,9 +1546,8 @@ public class BAstCreator extends BuiltInOPs
}
else
{
for
(
int
i
=
0
;
i
<
struct
.
getFields
().
size
();
i
++)
{
String
fieldName
=
struct
.
getFields
().
get
(
i
);
AIdentifierExpression
field
=
createIdentifierNode
(
fieldName
);
ARecEntry
rec
=
new
ARecEntry
();
rec
.
setIdentifier
(
field
);
rec
.
setIdentifier
(
new
TIdentifierLiteral
(
fieldName
)
);
if
(
pairTable
.
containsKey
(
fieldName
))
{
rec
.
setValue
(
pairTable
.
get
(
fieldName
));
}
else
{
...
...
@@ -1576,7 +1574,7 @@ public class BAstCreator extends BuiltInOPs
for
(
int
i
=
0
;
i
<
struct
.
getFields
().
size
();
i
++)
{
String
fieldName
=
struct
.
getFields
().
get
(
i
);
ARecEntry
rec
=
new
ARecEntry
();
rec
.
setIdentifier
(
create
Identifier
Node
(
fieldName
));
rec
.
setIdentifier
(
new
T
Identifier
Literal
(
fieldName
));
if
(
pairTable
.
containsKey
(
fieldName
))
{
ACoupleExpression
couple
=
new
ACoupleExpression
(
Arrays
.
asList
(
new
ABooleanTrueExpression
(),
pairTable
.
get
(
fieldName
)));
...
...
@@ -1600,9 +1598,8 @@ public class BAstCreator extends BuiltInOPs
List
<
PRecEntry
>
recList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
struct
.
getFields
().
size
();
i
++)
{
String
fieldName
=
struct
.
getFields
().
get
(
i
);
AIdentifierExpression
field
=
createIdentifierNode
(
fieldName
);
ARecEntry
rec
=
new
ARecEntry
();
rec
.
setIdentifier
(
field
);
rec
.
setIdentifier
(
new
TIdentifierLiteral
(
fieldName
)
);
if
(
pairTable
.
containsKey
(
fieldName
))
{
rec
.
setValue
(
pairTable
.
get
(
fieldName
));
}
else
{
...
...
@@ -1622,7 +1619,7 @@ public class BAstCreator extends BuiltInOPs
ARecordFieldExpression
rcdSelect
=
new
ARecordFieldExpression
();
rcdSelect
.
setRecord
(
visitExprOrOpArgNodeExpression
(
n
.
getArgs
()[
0
]));
StringNode
stringNode
=
(
StringNode
)
n
.
getArgs
()[
1
];
rcdSelect
.
setIdentifier
(
create
Identifier
Node
(
stringNode
.
getRep
().
toString
()));
rcdSelect
.
setIdentifier
(
new
T
Identifier
Literal
(
stringNode
.
getRep
().
toString
()));
AFunctionExpression
funcCall
=
new
AFunctionExpression
();
funcCall
.
setIdentifier
(
rcdSelect
);
funcCall
.
setParameters
(
Collections
.
singletonList
(
new
ABooleanTrueExpression
()));
...
...
@@ -1631,7 +1628,7 @@ public class BAstCreator extends BuiltInOPs
ARecordFieldExpression
rcdSelect
=
new
ARecordFieldExpression
();
rcdSelect
.
setRecord
(
visitExprOrOpArgNodeExpression
(
n
.
getArgs
()[
0
]));
StringNode
stringNode
=
(
StringNode
)
n
.
getArgs
()[
1
];
rcdSelect
.
setIdentifier
(
create
Identifier
Node
(
stringNode
.
getRep
().
toString
()));
rcdSelect
.
setIdentifier
(
new
T
Identifier
Literal
(
stringNode
.
getRep
().
toString
()));
return
rcdSelect
;
}
}
...
...
@@ -1801,12 +1798,12 @@ public class BAstCreator extends BuiltInOPs
for
(
int
i
=
0
;
i
<
structType
.
getFields
().
size
();
i
++)
{
ARecEntry
entry
=
new
ARecEntry
();
String
fieldName
=
structType
.
getFields
().
get
(
i
);
entry
.
setIdentifier
(
create
Identifier
Node
(
fieldName
));
entry
.
setIdentifier
(
new
T
Identifier
Literal
(
fieldName
));
PExpression
value
;
ARecordFieldExpression
select
=
new
ARecordFieldExpression
();
select
.
setRecord
(
prefix
.
clone
());
select
.
setIdentifier
(
create
Identifier
Node
(
fieldName
));
select
.
setIdentifier
(
new
T
Identifier
Literal
(
fieldName
));
if
(
fieldName
.
equals
(
field
))
{
value
=
evalExceptValue
(
select
,
seqList
,
structType
.
getType
(
fieldName
),
val
);
}
else
{
...
...
@@ -2119,7 +2116,7 @@ public class BAstCreator extends BuiltInOPs
ARecordFieldExpression
rcdSelect
=
new
ARecordFieldExpression
();
rcdSelect
.
setRecord
(
visitExprOrOpArgNodeExpression
(
n
.
getArgs
()[
0
]));
StringNode
stringNode
=
(
StringNode
)
n
.
getArgs
()[
1
];
rcdSelect
.
setIdentifier
(
create
Identifier
Node
(
stringNode
.
getRep
().
toString
()));
rcdSelect
.
setIdentifier
(
new
T
Identifier
Literal
(
stringNode
.
getRep
().
toString
()));
returnNode
=
new
AEqualPredicate
(
rcdSelect
,
new
ABooleanTrueExpression
());
break
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment