Kotlin: Pull Kotlin type for localvars out into its own table

This commit is contained in:
Ian Lynagh
2022-01-27 15:01:31 +00:00
parent 7862229807
commit 76ca0b2776
6 changed files with 19 additions and 13 deletions

View File

@@ -2,6 +2,7 @@ import java
predicate badKotlinType(Element e, int i) {
e = any(Expr expr | count(expr.getKotlinType()) = i) or
e = any(LocalVariableDecl lvd | count(lvd.getKotlinType()) = i) or
e = any(Parameter p | count(p.getKotlinType()) = i) or
e = any(Constructor c | count(c.getReturnKotlinType()) = i) or
e = any(Method m | count(m.getReturnKotlinType()) = i) or

View File

@@ -406,7 +406,7 @@ fields(
fieldsKotlinType(
unique int id: @field ref,
int kttypeid: @kt_type ref
)
);
constrs(
unique int id: @constructor,
@@ -420,7 +420,7 @@ constrs(
constrsKotlinType(
unique int id: @constructor ref,
int kttypeid: @kt_type ref
)
);
methods(
unique int id: @method,
@@ -434,7 +434,7 @@ methods(
methodsKotlinType(
unique int id: @method ref,
int kttypeid: @kt_type ref
)
);
#keyset[parentid,pos]
params(
@@ -448,7 +448,7 @@ params(
paramsKotlinType(
unique int id: @param ref,
int kttypeid: @kt_type ref
)
);
paramName(
unique int id: @param ref,
@@ -644,7 +644,7 @@ exprs(
exprsKotlinType(
unique int id: @expr ref,
int kttypeid: @kt_type ref
)
);
callableEnclosingExpr(
unique int id: @expr ref,
@@ -856,10 +856,14 @@ localvars(
unique int id: @localvar,
string nodeName: string ref,
int typeid: @type ref,
int kttypeid: @kt_type ref,
int parentid: @localvariabledeclexpr ref
);
localvarsKotlinType(
unique int id: @localvar ref,
int kttypeid: @kt_type ref
);
@namedexprorstmt = @breakstmt
| @continuestmt
| @labeledstmt

View File

@@ -34,7 +34,7 @@ predicate hasName(Element e, string name) {
name = "p" + pos
)
or
localvars(e, name, _, _, _)
localvars(e, name, _, _)
or
typeVars(e, name, _, _, _)
or

View File

@@ -1529,7 +1529,7 @@ class LocalVariableDeclExpr extends Expr, @localvariabledeclexpr {
VarAccess getAnAccess() { variableBinding(result, this.getVariable()) }
/** Gets the local variable declared by this local variable declaration expression. */
LocalVariableDecl getVariable() { localvars(result, _, _, _, this) }
LocalVariableDecl getVariable() { localvars(result, _, _, this) }
/** Gets the type access of this local variable declaration expression. */
Expr getTypeAccess() {

View File

@@ -38,16 +38,16 @@ class LocalScopeVariable extends Variable, @localscopevariable {
/** A local variable declaration */
class LocalVariableDecl extends @localvar, LocalScopeVariable {
/** Gets the type of this local variable. */
override Type getType() { localvars(this, _, result, _, _) }
override Type getType() { localvars(this, _, result, _) }
/** Gets the Kotlin type of this local variable. */
override KotlinType getKotlinType() { localvars(this, _, _, result, _) }
override KotlinType getKotlinType() { localvarsKotlinType(this, result) }
/** Gets the expression declaring this variable. */
LocalVariableDeclExpr getDeclExpr() { localvars(this, _, _, _, result) }
LocalVariableDeclExpr getDeclExpr() { localvars(this, _, _, result) }
/** Gets the parent of this declaration. */
Expr getParent() { localvars(this, _, _, _, result) }
Expr getParent() { localvars(this, _, _, result) }
/** Gets the callable in which this declaration occurs. */
override Callable getCallable() { result = this.getParent().getEnclosingCallable() }