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
d47a5481
Commit
d47a5481
authored
7 months ago
by
Jan Gruteser
Browse files
Options
Downloads
Patches
Plain Diff
replace unifications in visitExprNode
parent
8cd2aa1b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#148679
failed
7 months ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/tla2b/analysis/TypeChecker.java
+14
-50
14 additions, 50 deletions
src/main/java/de/tla2b/analysis/TypeChecker.java
with
14 additions
and
50 deletions
src/main/java/de/tla2b/analysis/TypeChecker.java
+
14
−
50
View file @
d47a5481
...
...
@@ -201,70 +201,34 @@ public class TypeChecker extends BuiltInOPs implements BBuildIns, TranslationGlo
switch
(
exprNode
.
getKind
())
{
case
TLCValueKind:
{
TLCValueNode
valueNode
=
(
TLCValueNode
)
exprNode
;
try
{
return
valueNode
.
getType
().
unify
(
expected
);
}
catch
(
UnificationException
e
)
{
throw
new
TypeErrorException
(
String
.
format
(
"Expected %s, found %s at '%s'(assigned in the configuration file),%n%s "
,
expected
,
valueNode
.
getType
(),
valueNode
.
getValue
(),
exprNode
.
getLocation
()));
}
return
unify
(
valueNode
.
getType
(),
expected
,
valueNode
.
getValue
().
toString
()
+
" (assigned in the configuration file)"
,
exprNode
);
}
case
OpApplKind:
return
visitOpApplNode
((
OpApplNode
)
exprNode
,
expected
);
case
NumeralKind:
try
{
return
IntType
.
getInstance
().
unify
(
expected
);
}
catch
(
UnificationException
e
)
{
throw
new
TypeErrorException
(
String
.
format
(
"Expected %s, found INTEGER at '%s',%n%s "
,
expected
,
((
NumeralNode
)
exprNode
).
val
(),
exprNode
.
getLocation
()));
}
case
DecimalKind:
{
try
{
return
RealType
.
getInstance
().
unify
(
expected
);
}
catch
(
UnificationException
e
)
{
throw
new
TypeErrorException
(
String
.
format
(
"Expected %s, found REAL at '%s',%n%s "
,
expected
,
exprNode
,
exprNode
.
getLocation
()));
}
}
case
StringKind:
{
try
{
return
StringType
.
getInstance
().
unify
(
expected
);
}
catch
(
UnificationException
e
)
{
throw
new
TypeErrorException
(
String
.
format
(
"Expected %s, found STRING at '%s',%n%s "
,
expected
,
((
StringNode
)
exprNode
).
getRep
(),
exprNode
.
getLocation
()));
}
}
return
unify
(
IntType
.
getInstance
(),
expected
,
exprNode
.
toString
(),
exprNode
);
case
DecimalKind:
return
unify
(
RealType
.
getInstance
(),
expected
,
exprNode
.
toString
(),
exprNode
);
case
StringKind:
return
unify
(
StringType
.
getInstance
(),
expected
,
((
StringNode
)
exprNode
).
getRep
().
toString
(),
exprNode
);
case
AtNodeKind:
{
// @
AtNode
a
=
(
AtNode
)
exprNode
;
OpApplNode
pair2
=
a
.
getExceptComponentRef
();
ExprOrOpArgNode
rightside
=
pair2
.
getArgs
()[
1
];
TLAType
type
=
(
TLAType
)
rightside
.
getToolObject
(
TYPE_ID
);
try
{
TLAType
res
=
type
.
unify
(
expected
);
setType
(
exprNode
,
res
);
return
res
;
}
catch
(
UnificationException
e
)
{
throw
new
TypeErrorException
(
String
.
format
(
"Expected %s, found %s at '@',%n%s "
,
expected
,
type
,
exprNode
.
getLocation
()));
}
TLAType
type
=
getType
((((
AtNode
)
exprNode
).
getExceptComponentRef
()).
getArgs
()[
1
]);
// right side
return
unifyAndSetTypeWithFollowers
(
type
,
expected
,
"@"
,
exprNode
);
}
case
LetInKind:
{
LetInNode
l
=
(
LetInNode
)
exprNode
;
for
(
int
i
=
0
;
i
<
l
.
getLets
().
length
;
i
++
)
{
visitOpDefNode
(
l
.
getLets
()[
i
]
);
for
(
OpDefNode
let
:
l
.
getLets
()
)
{
visitOpDefNode
(
l
et
);
}
return
visitExprNode
(
l
.
getBody
(),
expected
);
}
case
SubstInKind:
{
case
SubstInKind:
throw
new
RuntimeException
(
"SubstInKind should never occur after InstanceTransformation"
);
default
:
// should be only LabelKind
throw
new
NotImplementedException
(
"ExprNode not yet supported: "
+
exprNode
.
toString
(
2
));
}
}
throw
new
NotImplementedException
(
exprNode
.
toString
(
2
));
}
private
TLAType
visitOpApplNode
(
OpApplNode
n
,
TLAType
expected
)
throws
TLA2BException
{
...
...
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