misc. cleanups and refactoring
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1167 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
44e81fe29f
commit
afc1dc0a59
|
@ -22,63 +22,63 @@ import com.ibm.wala.types.TypeReference;
|
|||
public class JSTypeInference extends AstTypeInference {
|
||||
|
||||
public JSTypeInference(IR ir, ClassHierarchy cha) {
|
||||
super(ir, cha, new PointType(cha.lookupClass(JavaScriptTypes.Boolean), cha), true);
|
||||
super(ir, cha, new PointType(cha.lookupClass(JavaScriptTypes.Boolean)), true);
|
||||
}
|
||||
|
||||
protected void initialize() {
|
||||
class JSTypeOperatorFactory
|
||||
extends AstTypeOperatorFactory
|
||||
implements com.ibm.wala.cast.js.ssa.InstructionVisitor
|
||||
{
|
||||
class JSTypeOperatorFactory extends AstTypeOperatorFactory implements com.ibm.wala.cast.js.ssa.InstructionVisitor {
|
||||
public void visitJavaScriptInvoke(JavaScriptInvoke inst) {
|
||||
result = new DeclaredTypeOperator(new ConeType(cha.getRootClass(), cha));
|
||||
result = new DeclaredTypeOperator(new ConeType(cha.getRootClass()));
|
||||
}
|
||||
|
||||
public void visitJavaScriptPropertyRead(JavaScriptPropertyRead inst) {
|
||||
result = new DeclaredTypeOperator(new ConeType(cha.getRootClass(), cha));
|
||||
result = new DeclaredTypeOperator(new ConeType(cha.getRootClass()));
|
||||
}
|
||||
|
||||
public void visitTypeOf(JavaScriptTypeOfInstruction inst) {
|
||||
result = new DeclaredTypeOperator(new PointType(cha.lookupClass(JavaScriptTypes.String), cha));
|
||||
result = new DeclaredTypeOperator(new PointType(cha.lookupClass(JavaScriptTypes.String)));
|
||||
}
|
||||
|
||||
public void visitJavaScriptPropertyWrite(JavaScriptPropertyWrite inst) {
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
class JSTypeVarFactory extends TypeVarFactory {
|
||||
|
||||
private TypeAbstraction make(TypeReference typeRef) {
|
||||
return new PointType(cha.lookupClass( typeRef ), cha);
|
||||
return new PointType(cha.lookupClass(typeRef));
|
||||
}
|
||||
|
||||
public IVariable makeVariable(int vn) {
|
||||
if (ir.getSymbolTable().isStringConstant( vn )) {
|
||||
return new TypeVariable(make(JavaScriptTypes.String), 1331*vn);
|
||||
} else if (ir.getSymbolTable().isBooleanConstant( vn )) {
|
||||
return new TypeVariable(make(JavaScriptTypes.Boolean), 4197*vn);
|
||||
} else if (ir.getSymbolTable().isNullConstant( vn )) {
|
||||
return new TypeVariable(make(JavaScriptTypes.Null), 4077*vn);
|
||||
} else if (ir.getSymbolTable().isNumberConstant( vn )) {
|
||||
return new TypeVariable(make(JavaScriptTypes.Number), 797*vn);
|
||||
} else {
|
||||
return super.makeVariable( vn );
|
||||
}
|
||||
if (ir.getSymbolTable().isStringConstant(vn)) {
|
||||
return new TypeVariable(make(JavaScriptTypes.String), 1331 * vn);
|
||||
} else if (ir.getSymbolTable().isBooleanConstant(vn)) {
|
||||
return new TypeVariable(make(JavaScriptTypes.Boolean), 4197 * vn);
|
||||
} else if (ir.getSymbolTable().isNullConstant(vn)) {
|
||||
return new TypeVariable(make(JavaScriptTypes.Null), 4077 * vn);
|
||||
} else if (ir.getSymbolTable().isNumberConstant(vn)) {
|
||||
return new TypeVariable(make(JavaScriptTypes.Number), 797 * vn);
|
||||
} else {
|
||||
return super.makeVariable(vn);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
init(ir, new JSTypeVarFactory(), new JSTypeOperatorFactory());
|
||||
}
|
||||
|
||||
public TypeAbstraction getConstantType(int valueNumber) {
|
||||
SymbolTable st = ir.getSymbolTable();
|
||||
if (st.isStringConstant(valueNumber)) {
|
||||
return new PointType(cha.lookupClass(JavaScriptTypes.String), cha);
|
||||
} else if (st.isBooleanConstant( valueNumber )) {
|
||||
return new PointType(cha.lookupClass(JavaScriptTypes.Boolean), cha);
|
||||
} else if (st.isNullConstant(valueNumber)) {
|
||||
return new PointType(cha.lookupClass(JavaScriptTypes.Null), cha);
|
||||
if (st.isStringConstant(valueNumber)) {
|
||||
return new PointType(cha.lookupClass(JavaScriptTypes.String));
|
||||
} else if (st.isBooleanConstant(valueNumber)) {
|
||||
return new PointType(cha.lookupClass(JavaScriptTypes.Boolean));
|
||||
} else if (st.isNullConstant(valueNumber)) {
|
||||
return new PointType(cha.lookupClass(JavaScriptTypes.Null));
|
||||
} else {
|
||||
return new PointType(cha.lookupClass(JavaScriptTypes.Number), cha);
|
||||
return new PointType(cha.lookupClass(JavaScriptTypes.Number));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue