@@ -208,8 +208,7 @@ class QueryDoc extends QLDoc {
208208 this = any ( TopLevel t ) .getQLDoc ( )
209209 }
210210
211- override string getAPrimaryQlClass ( ) { result = "QueryDoc" }
212-
211+ // override string getAPrimaryQlClass() { result = "QueryDoc" } // WORKAROUND: can't override this
213212 /** Gets the @kind for the query */
214213 string getQueryKind ( ) {
215214 result = this .getContents ( ) .regexpCapture ( "(?s).*@kind ([\\w-]+)\\s.*" , 1 )
@@ -1138,7 +1137,7 @@ final new class NewTypeBranch extends QlNode, Predicate, TypeDeclaration {
11381137 * or a member call `foo.bar()`,
11391138 * or a special call to `none()` or `any()`.
11401139 */
1141- abstract new class Call extends TCall , Expr , Formula {
1140+ abstract new class Call extends Expr , Formula {
11421141 /** Gets the `i`th argument of this call. */
11431142 Expr getArgument ( int i ) {
11441143 none ( ) // overridden in subclasses.
@@ -1756,18 +1755,19 @@ final new class HigherOrderFormula extends QlNode, Formula {
17561755 }
17571756}
17581757
1759- abstract new class Aggregate extends Expr {
1758+ abstract new class Aggregate extends QlNode , Expr {
1759+ override QL:: Aggregate qlNode ;
1760+
17601761 string getKind ( ) { none ( ) }
17611762
1762- QL:: Aggregate getAggregate ( ) { none ( ) }
1763+ QL:: Aggregate getAggregate ( ) { result = qlNode }
17631764}
17641765
17651766/**
17661767 * An aggregate containing an expression.
17671768 * E.g. `min(getAPredicate().getArity())`.
17681769 */
1769- class ExprAggregate extends QlNode , Aggregate {
1770- override QL:: Aggregate qlNode ;
1770+ final new class ExprAggregate extends Aggregate {
17711771 QL:: ExprAggregateBody body ;
17721772 string kind ;
17731773
@@ -1782,8 +1782,6 @@ class ExprAggregate extends QlNode, Aggregate {
17821782 */
17831783 override string getKind ( ) { result = kind }
17841784
1785- override QL:: Aggregate getAggregate ( ) { result = qlNode }
1786-
17871785 /**
17881786 * Gets the ith "as" expression of this aggregate, if any.
17891787 */
@@ -1828,10 +1826,9 @@ class ExprAggregate extends QlNode, Aggregate {
18281826}
18291827
18301828/** An aggregate expression, such as `count` or `sum`. */
1831- final new class FullAggregate extends QlNode , Aggregate {
1832- override QL:: Aggregate qlNode ;
1833- string kind ;
1829+ final new class FullAggregate extends Aggregate {
18341830 QL:: FullAggregateBody body ;
1831+ string kind ;
18351832
18361833 FullAggregate ( ) {
18371834 kind = qlNode .getChild ( 0 ) .( QL:: AggId ) .getValue ( ) and
@@ -1914,14 +1911,13 @@ final new class FullAggregate extends QlNode, Aggregate {
19141911// TODO: hm these don't very neatly fit into the IPA heirarchy
19151912class Any extends FullAggregate {
19161913 Any ( ) { this .getKind ( ) = "any" }
1917-
1918- override string getAPrimaryQlClass ( ) { result = "Any" }
1914+ // override string getAPrimaryQlClass() { result = "Any" } // WORKAROUND: can't overrride this
19191915}
19201916
19211917/**
19221918 * A "rank" expression, such as `rank[4](int i | i = [5 .. 15] | i)`.
19231919 */
1924- // this doesn't even give an error since it's extending an abstract class? hm
1920+ // TODO: needs rewrite? extends abstract class!
19251921class Rank extends Aggregate {
19261922 Rank ( ) { this .getKind ( ) = "rank" }
19271923
@@ -1935,7 +1931,7 @@ class Rank extends Aggregate {
19351931 override AstNode getAChild ( string pred ) {
19361932 result = super .getAChild ( pred )
19371933 or
1938- pred = directMember ( "getRankExpr" ) and result = this .getRankExpr ( )
1934+ pred = directMember ( "getRankExpr" ) and result = this .getRankExpr ( ) // WORKAROUND: move this to other thingys
19391935 }
19401936}
19411937
@@ -1975,7 +1971,7 @@ final new class AsExpr extends QlNode, VarDef, Expr {
19751971/**
19761972 * An identifier, such as `foo`.
19771973 */
1978- final new class Identifier extends QlNode , Expr {
1974+ abstract new class Identifier extends QlNode , Expr {
19791975 override QL:: Variable qlNode ;
19801976
19811977 string getName ( ) { none ( ) }
@@ -1985,41 +1981,46 @@ final new class Identifier extends QlNode, Expr {
19851981 override string getAPrimaryQlClass ( ) { result = "Identifier" }
19861982}
19871983
1984+ final new class FieldOrVarAccess extends Identifier {
1985+ QL:: VarName varName ;
1986+
1987+ FieldOrVarAccess ( ) { varName = qlNode .getChild ( ) }
1988+
1989+ override string getName ( ) { result = qlNode .getChild ( ) .( QL:: VarName ) .getChild ( ) .getValue ( ) }
1990+
1991+ override Type getType ( ) {
1992+ result = this .( VarAccess ) .getDeclaration ( ) .getType ( )
1993+ or
1994+ result = this .( FieldAccess ) .getDeclaration ( ) .getVarDecl ( ) .getType ( ) // WORKAROUND: push these definitions to here to not have charpreds for the IPA heirarchy depend on type resolution
1995+ }
1996+
1997+ override string getAPrimaryQlClass ( ) { result = "FieldOrVarAccess" }
1998+ }
1999+
19882000/** An access to a variable. */
1989- // TODO: can't handle this? breaks monotonicity to make this final and Identifier abstract!
1990- class VarAccess extends Identifier {
2001+ class VarAccess extends FieldOrVarAccess {
19912002 private VarDef decl ;
19922003
19932004 VarAccess ( ) { resolveVariable ( this , decl ) }
19942005
19952006 /** Gets the accessed variable. */
19962007 VarDef getDeclaration ( ) { result = decl }
1997-
1998- override string getName ( ) { result = qlNode .getChild ( ) .( QL:: VarName ) .getChild ( ) .getValue ( ) }
1999-
2000- override Type getType ( ) { result = this .getDeclaration ( ) .getType ( ) }
2001-
2002- override string getAPrimaryQlClass ( ) { result = "VarAccess" }
2008+ //override string getAPrimaryQlClass() { result = "VarAccess" }
20032009}
20042010
20052011/** An access to a field. */
2006- class FieldAccess extends Identifier {
2012+ class FieldAccess extends FieldOrVarAccess {
20072013 private VarDecl decl ;
20082014
20092015 FieldAccess ( ) { resolveField ( this , decl ) }
20102016
20112017 /** Gets the accessed field. */
20122018 FieldDecl getDeclaration ( ) { result .getVarDecl ( ) = decl }
2013-
2014- override string getName ( ) { result = id .getChild ( ) .( QL:: VarName ) .getChild ( ) .getValue ( ) }
2015-
2016- override Type getType ( ) { result = decl .getType ( ) }
2017-
2018- override string getAPrimaryQlClass ( ) { result = "FieldAccess" }
2019+ //override string getAPrimaryQlClass() { result = "FieldAccess" }
20192020}
20202021
20212022/** An access to `this`. */
2022- class ThisAccess extends Identifier {
2023+ final new class ThisAccess extends Identifier {
20232024 ThisAccess ( ) { any ( QL:: This t ) .getParent ( ) = qlNode }
20242025
20252026 override Type getType ( ) { result = this .getParent + ( ) .( Class ) .getType ( ) }
@@ -2041,7 +2042,7 @@ final new class Super extends QlNode, Expr {
20412042}
20422043
20432044/** An access to `result`. */
2044- class ResultAccess extends Identifier {
2045+ final new class ResultAccess extends Identifier {
20452046 ResultAccess ( ) { any ( QL:: Result r ) .getParent ( ) = qlNode }
20462047
20472048 override Type getType ( ) { result = this .getParent + ( ) .( Predicate ) .getReturnType ( ) }
@@ -2515,7 +2516,12 @@ private class MonotonicAggregatesArg extends AnnotationArg {
25152516final new class Annotation extends QlNode , AstNode {
25162517 override QL:: Annotation qlNode ;
25172518
2518- override string toString ( ) { result = "annotation" }
2519+ override string toString ( ) {
2520+ // WORKAROUND: can't oerride toString on subclasses
2521+ if exists ( this .getArgs ( 0 ) .getValue ( ) )
2522+ then result = this .getArgs ( 0 ) .getValue ( )
2523+ else result = "annotation"
2524+ }
25192525
25202526 override string getAPrimaryQlClass ( ) { result = "Annotation" }
25212527
@@ -2540,36 +2546,31 @@ final new class Annotation extends QlNode, AstNode {
25402546// TODO: does this need to be `new`
25412547class NoInline extends Annotation {
25422548 NoInline ( ) { this .getArgs ( 0 ) instanceof NoInlineArg }
2543-
2544- override string toString ( ) { result = "noinline" }
2549+ // override string toString() { result = "noinline" }
25452550}
25462551
25472552/** A `pragma[inline]` annotation. */
25482553class Inline extends Annotation {
25492554 Inline ( ) { this .getArgs ( 0 ) instanceof InlineArg }
2550-
2551- override string toString ( ) { result = "inline" }
2555+ // override string toString() { result = "inline" }
25522556}
25532557
25542558/** A `pragma[nomagic]` annotation. */
25552559class NoMagic extends Annotation {
25562560 NoMagic ( ) { this .getArgs ( 0 ) instanceof NoMagicArg }
2557-
2558- override string toString ( ) { result = "nomagic" }
2561+ // override string toString() { result = "nomagic" }
25592562}
25602563
25612564/** A `pragma[noopt]` annotation. */
25622565class NoOpt extends Annotation {
25632566 NoOpt ( ) { this .getArgs ( 0 ) instanceof NoOptArg }
2564-
2565- override string toString ( ) { result = "noopt" }
2567+ // override string toString() { result = "noopt" }
25662568}
25672569
25682570/** A `language[monotonicAggregates]` annotation. */
25692571class MonotonicAggregates extends Annotation {
25702572 MonotonicAggregates ( ) { this .getArgs ( 0 ) instanceof MonotonicAggregatesArg }
2571-
2572- override string toString ( ) { result = "monotonicaggregates" }
2573+ // override string toString() { result = "monotonicaggregates" }
25732574}
25742575
25752576/** A `bindingset` annotation. */
0 commit comments