adds the TermType enum, which allows exhaustive term type matching;
adds IStrategoTerm.getType(), which returns a member of the TermType enum;
deprecates IStrategoTerm.getTermType(), as it returns an integer value (remnant of C-style 'enums');
deprecates the IStrategoTermAPPL, LIST, INT, REAL, STRING, CTOR, TUPLE, REF, BLOB and PLACEHOLDER integer constants;
replaces many uses of getTermType() with getType().
This PR allows you to write switch on IStrategoTerm.getType() without having to prefix every case with IStrategoTerm, or having to do a static import for each member. In languages that support it (e.g., Kotlin), the compiler can detect that the switch-case is exhaustive. As enums are safely compared using reference equality, this PR will have no performance impact (comparing two pointers is the same as comparing two integers).
This PR:
TermType
enum, which allows exhaustive term type matching;IStrategoTerm.getType()
, which returns a member of theTermType
enum;IStrategoTerm.getTermType()
, as it returns an integer value (remnant of C-style 'enums');IStrategoTerm
APPL
,LIST
,INT
,REAL
,STRING
,CTOR
,TUPLE
,REF
,BLOB
andPLACEHOLDER
integer constants;getTermType()
withgetType()
.This PR allows you to write
switch
onIStrategoTerm.getType()
without having to prefix every case withIStrategoTerm
, or having to do a static import for each member. In languages that support it (e.g., Kotlin), the compiler can detect that the switch-case is exhaustive. As enums are safely compared using reference equality, this PR will have no performance impact (comparing two pointers is the same as comparing two integers).Related: