2007-02-02 17:25:09 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* Copyright (c) 2002 - 2006 IBM Corporation.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* IBM Corporation - initial API and implementation
|
|
|
|
*****************************************************************************/
|
|
|
|
package com.ibm.wala.cast.js.loader;
|
|
|
|
|
2010-09-14 20:29:05 +00:00
|
|
|
import java.io.UnsupportedEncodingException;
|
2007-02-08 19:07:30 +00:00
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
2007-02-02 17:25:09 +00:00
|
|
|
|
2009-06-03 18:26:29 +00:00
|
|
|
import com.ibm.wala.analysis.typeInference.PrimitiveType;
|
2009-04-10 19:48:32 +00:00
|
|
|
import com.ibm.wala.cast.ir.ssa.AssignInstruction;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstAssertInstruction;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstEchoInstruction;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstGlobalRead;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstGlobalWrite;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstIsDefinedInstruction;
|
2011-04-03 04:08:05 +00:00
|
|
|
import com.ibm.wala.cast.ir.ssa.AstLexicalAccess.Access;
|
2009-04-10 19:48:32 +00:00
|
|
|
import com.ibm.wala.cast.ir.ssa.AstLexicalRead;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstLexicalWrite;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction;
|
2011-04-03 04:08:05 +00:00
|
|
|
import com.ibm.wala.cast.ir.translator.AstTranslator.AstLexicalInformation;
|
2012-01-27 20:15:33 +00:00
|
|
|
import com.ibm.wala.cast.ir.translator.AstTranslator.WalkContext;
|
2009-04-15 12:52:40 +00:00
|
|
|
import com.ibm.wala.cast.ir.translator.TranslatorToCAst;
|
|
|
|
import com.ibm.wala.cast.ir.translator.TranslatorToIR;
|
2009-06-03 18:26:29 +00:00
|
|
|
import com.ibm.wala.cast.js.analysis.typeInference.JSPrimitiveType;
|
2018-02-05 23:18:37 +00:00
|
|
|
import com.ibm.wala.cast.js.ipa.callgraph.JSCallGraph.JSFakeRoot;
|
2009-04-10 19:48:32 +00:00
|
|
|
import com.ibm.wala.cast.js.ssa.JSInstructionFactory;
|
|
|
|
import com.ibm.wala.cast.js.ssa.JavaScriptCheckReference;
|
|
|
|
import com.ibm.wala.cast.js.ssa.JavaScriptInstanceOf;
|
|
|
|
import com.ibm.wala.cast.js.ssa.JavaScriptInvoke;
|
|
|
|
import com.ibm.wala.cast.js.ssa.JavaScriptPropertyRead;
|
|
|
|
import com.ibm.wala.cast.js.ssa.JavaScriptPropertyWrite;
|
|
|
|
import com.ibm.wala.cast.js.ssa.JavaScriptTypeOfInstruction;
|
|
|
|
import com.ibm.wala.cast.js.ssa.JavaScriptWithRegion;
|
2012-03-01 02:45:51 +00:00
|
|
|
import com.ibm.wala.cast.js.ssa.PrototypeLookup;
|
|
|
|
import com.ibm.wala.cast.js.ssa.SetPrototype;
|
2009-04-15 12:52:40 +00:00
|
|
|
import com.ibm.wala.cast.js.translator.JSAstTranslator;
|
2007-02-08 19:07:30 +00:00
|
|
|
import com.ibm.wala.cast.js.translator.JavaScriptTranslatorFactory;
|
|
|
|
import com.ibm.wala.cast.js.types.JavaScriptTypes;
|
2007-02-02 17:25:09 +00:00
|
|
|
import com.ibm.wala.cast.loader.AstMethod.DebuggingInformation;
|
2011-04-03 04:08:05 +00:00
|
|
|
import com.ibm.wala.cast.loader.CAstAbstractModuleLoader;
|
2009-04-15 12:52:40 +00:00
|
|
|
import com.ibm.wala.cast.tree.CAst;
|
|
|
|
import com.ibm.wala.cast.tree.CAstEntity;
|
2007-02-08 19:07:30 +00:00
|
|
|
import com.ibm.wala.cast.tree.CAstQualifier;
|
|
|
|
import com.ibm.wala.cast.tree.CAstSourcePositionMap;
|
2012-10-03 14:53:04 +00:00
|
|
|
import com.ibm.wala.cast.tree.rewrite.CAstRewriterFactory;
|
2018-01-30 19:08:25 +00:00
|
|
|
import com.ibm.wala.cast.types.AstTypeReference;
|
2007-02-02 17:25:09 +00:00
|
|
|
import com.ibm.wala.cfg.AbstractCFG;
|
2013-04-11 01:09:10 +00:00
|
|
|
import com.ibm.wala.cfg.IBasicBlock;
|
2009-04-10 18:33:07 +00:00
|
|
|
import com.ibm.wala.classLoader.CallSiteReference;
|
2007-07-06 22:09:08 +00:00
|
|
|
import com.ibm.wala.classLoader.IClass;
|
|
|
|
import com.ibm.wala.classLoader.IMethod;
|
|
|
|
import com.ibm.wala.classLoader.Language;
|
2007-12-06 14:57:33 +00:00
|
|
|
import com.ibm.wala.classLoader.LanguageImpl;
|
2017-01-12 17:25:37 +00:00
|
|
|
import com.ibm.wala.classLoader.ModuleEntry;
|
2009-04-10 18:33:07 +00:00
|
|
|
import com.ibm.wala.classLoader.NewSiteReference;
|
2018-02-05 23:18:37 +00:00
|
|
|
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
|
|
|
import com.ibm.wala.ipa.callgraph.IAnalysisCacheView;
|
|
|
|
import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod;
|
2007-07-06 22:09:08 +00:00
|
|
|
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
2009-04-10 18:33:07 +00:00
|
|
|
import com.ibm.wala.shrikeBT.IBinaryOpInstruction.IOperator;
|
|
|
|
import com.ibm.wala.shrikeBT.IComparisonInstruction.Operator;
|
2014-10-06 19:34:16 +00:00
|
|
|
import com.ibm.wala.shrikeCT.BootstrapMethodsReader.BootstrapMethod;
|
2009-04-10 18:33:07 +00:00
|
|
|
import com.ibm.wala.shrikeCT.InvalidClassFileException;
|
2015-07-25 02:44:10 +00:00
|
|
|
import com.ibm.wala.ssa.SSAAbstractBinaryInstruction;
|
2009-05-20 18:56:23 +00:00
|
|
|
import com.ibm.wala.ssa.SSAAddressOfInstruction;
|
2009-04-10 18:33:07 +00:00
|
|
|
import com.ibm.wala.ssa.SSAArrayLengthInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAArrayLoadInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAArrayStoreInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSABinaryOpInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSACheckCastInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAComparisonInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAConditionalBranchInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAConversionInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAGetCaughtExceptionInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAGetInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAGotoInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAInstanceofInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAInstructionFactory;
|
|
|
|
import com.ibm.wala.ssa.SSAInvokeInstruction;
|
2009-05-20 18:56:23 +00:00
|
|
|
import com.ibm.wala.ssa.SSALoadIndirectInstruction;
|
2009-04-10 18:33:07 +00:00
|
|
|
import com.ibm.wala.ssa.SSALoadMetadataInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAMonitorInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSANewInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAPhiInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAPiInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAPutInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAReturnInstruction;
|
2009-05-20 18:56:23 +00:00
|
|
|
import com.ibm.wala.ssa.SSAStoreIndirectInstruction;
|
2009-04-10 18:33:07 +00:00
|
|
|
import com.ibm.wala.ssa.SSASwitchInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAThrowInstruction;
|
|
|
|
import com.ibm.wala.ssa.SSAUnaryOpInstruction;
|
2007-02-02 17:25:09 +00:00
|
|
|
import com.ibm.wala.ssa.SymbolTable;
|
2007-02-08 19:07:30 +00:00
|
|
|
import com.ibm.wala.types.ClassLoaderReference;
|
2009-04-10 18:33:07 +00:00
|
|
|
import com.ibm.wala.types.FieldReference;
|
|
|
|
import com.ibm.wala.types.MethodReference;
|
2007-02-08 19:07:30 +00:00
|
|
|
import com.ibm.wala.types.TypeName;
|
|
|
|
import com.ibm.wala.types.TypeReference;
|
2007-07-11 21:08:21 +00:00
|
|
|
import com.ibm.wala.util.collections.HashSetFactory;
|
2007-02-08 19:07:30 +00:00
|
|
|
import com.ibm.wala.util.debug.Assertions;
|
2008-01-24 22:06:02 +00:00
|
|
|
import com.ibm.wala.util.strings.Atom;
|
2007-02-02 17:25:09 +00:00
|
|
|
|
2009-04-15 12:52:40 +00:00
|
|
|
public class JavaScriptLoader extends CAstAbstractModuleLoader {
|
2007-06-01 03:32:56 +00:00
|
|
|
|
2007-12-06 14:57:33 +00:00
|
|
|
public final static Language JS = new LanguageImpl() {
|
2007-06-01 03:32:56 +00:00
|
|
|
|
2009-06-03 18:26:29 +00:00
|
|
|
{
|
|
|
|
JSPrimitiveType.init();
|
|
|
|
}
|
2011-04-20 23:08:47 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-06-01 03:32:56 +00:00
|
|
|
public Atom getName() {
|
|
|
|
return Atom.findOrCreateUnicodeAtom("JavaScript");
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-06-01 03:32:56 +00:00
|
|
|
public TypeReference getRootType() {
|
|
|
|
return JavaScriptTypes.Root;
|
2008-06-30 14:09:43 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2008-06-30 14:09:43 +00:00
|
|
|
public TypeReference getThrowableType() {
|
|
|
|
return JavaScriptTypes.Root;
|
2007-06-01 03:32:56 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-06-01 03:32:56 +00:00
|
|
|
public TypeReference getConstantType(Object o) {
|
|
|
|
if (o == null) {
|
2009-05-07 13:51:24 +00:00
|
|
|
return JavaScriptTypes.Null;
|
2007-06-01 03:32:56 +00:00
|
|
|
} else {
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
Class<?> c = o.getClass();
|
2009-05-07 13:51:24 +00:00
|
|
|
if (c == Boolean.class) {
|
|
|
|
return JavaScriptTypes.Boolean;
|
|
|
|
} else if (c == String.class) {
|
|
|
|
return JavaScriptTypes.String;
|
|
|
|
} else if (c == Integer.class) {
|
|
|
|
return JavaScriptTypes.Number;
|
|
|
|
} else if (c == Float.class) {
|
|
|
|
return JavaScriptTypes.Number;
|
|
|
|
} else if (c == Double.class) {
|
|
|
|
return JavaScriptTypes.Number;
|
|
|
|
} else {
|
|
|
|
assert false : "cannot determine type for " + o + " of class " + c;
|
|
|
|
return null;
|
|
|
|
}
|
2007-06-01 03:32:56 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-28 14:32:15 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-06-28 14:32:15 +00:00
|
|
|
public boolean isNullType(TypeReference type) {
|
2009-05-07 13:51:24 +00:00
|
|
|
return type.equals(JavaScriptTypes.Undefined) || type.equals(JavaScriptTypes.Null);
|
2007-06-28 14:32:15 +00:00
|
|
|
}
|
2009-02-19 15:59:55 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-02-19 15:59:55 +00:00
|
|
|
public TypeReference[] getArrayInterfaces() {
|
2009-05-07 13:51:24 +00:00
|
|
|
return new TypeReference[0];
|
2009-02-19 15:59:55 +00:00
|
|
|
}
|
2009-03-26 15:11:45 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-03-26 15:11:45 +00:00
|
|
|
public TypeName lookupPrimitiveType(String name) {
|
2009-04-10 18:33:07 +00:00
|
|
|
if ("Boolean".equals(name)) {
|
|
|
|
return JavaScriptTypes.Boolean.getName();
|
|
|
|
} else if ("Number".equals(name)) {
|
|
|
|
return JavaScriptTypes.Number.getName();
|
|
|
|
} else if ("String".equals(name)) {
|
|
|
|
return JavaScriptTypes.String.getName();
|
|
|
|
} else if ("Date".equals(name)) {
|
|
|
|
return JavaScriptTypes.Date.getName();
|
|
|
|
} else {
|
|
|
|
assert "RegExp".equals(name);
|
|
|
|
return JavaScriptTypes.RegExp.getName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public Collection<TypeReference> inferInvokeExceptions(MethodReference target, IClassHierarchy cha)
|
|
|
|
throws InvalidClassFileException {
|
|
|
|
return Collections.singleton(JavaScriptTypes.Root);
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public Object getMetadataToken(Object value) {
|
|
|
|
assert false;
|
2009-03-26 15:11:45 +00:00
|
|
|
return null;
|
|
|
|
}
|
2009-04-10 18:33:07 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-05-20 18:56:23 +00:00
|
|
|
public TypeReference getPointerType(TypeReference pointee) throws UnsupportedOperationException {
|
|
|
|
throw new UnsupportedOperationException("JavaScript does not permit explicit pointers");
|
|
|
|
}
|
|
|
|
|
2016-09-19 17:51:18 +00:00
|
|
|
@Override
|
|
|
|
public boolean methodsHaveDeclaredParameterTypes() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public JSInstructionFactory instructionFactory() {
|
|
|
|
return new JSInstructionFactory() {
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public JavaScriptCheckReference CheckReference(int iindex, int ref) {
|
|
|
|
return new JavaScriptCheckReference(iindex, ref);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAGetInstruction GetInstruction(int iindex, int result, int ref, String field) {
|
2014-04-09 15:33:57 +00:00
|
|
|
return GetInstruction(iindex, result, ref,
|
2011-04-20 23:08:47 +00:00
|
|
|
FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom(field), JavaScriptTypes.Root));
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public JavaScriptInstanceOf InstanceOf(int iindex, int result, int objVal, int typeVal) {
|
|
|
|
return new JavaScriptInstanceOf(iindex, result, objVal, typeVal);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public JavaScriptInvoke Invoke(int iindex, int function, int[] results, int[] params, int exception, CallSiteReference site) {
|
|
|
|
return new JavaScriptInvoke(iindex, function, results, params, exception, site);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public JavaScriptInvoke Invoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site) {
|
|
|
|
return new JavaScriptInvoke(iindex, function, result, params, exception, site);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public JavaScriptInvoke Invoke(int iindex, int function, int[] params, int exception, CallSiteReference site) {
|
|
|
|
return new JavaScriptInvoke(iindex, function, params, exception, site);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public JavaScriptPropertyRead PropertyRead(int iindex, int result, int objectRef, int memberRef) {
|
|
|
|
return new JavaScriptPropertyRead(iindex, result, objectRef, memberRef);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public JavaScriptPropertyWrite PropertyWrite(int iindex, int objectRef, int memberRef, int value) {
|
|
|
|
return new JavaScriptPropertyWrite(iindex, objectRef, memberRef, value);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAPutInstruction PutInstruction(int iindex, int ref, int value, String field) {
|
2010-09-14 20:29:05 +00:00
|
|
|
try {
|
|
|
|
byte[] utf8 = field.getBytes("UTF-8");
|
2014-04-09 11:34:16 +00:00
|
|
|
return PutInstruction(iindex, ref, value,
|
2011-04-20 23:08:47 +00:00
|
|
|
FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreate(utf8, 0, utf8.length), JavaScriptTypes.Root));
|
2017-03-23 21:32:00 +00:00
|
|
|
} catch (UnsupportedEncodingException e) {
|
2010-09-14 20:29:05 +00:00
|
|
|
Assertions.UNREACHABLE();
|
|
|
|
return null;
|
|
|
|
}
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public JavaScriptTypeOfInstruction TypeOfInstruction(int iindex, int lval, int object) {
|
|
|
|
return new JavaScriptTypeOfInstruction(iindex, lval, object);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public JavaScriptWithRegion WithRegion(int iindex, int expr, boolean isEnter) {
|
|
|
|
return new JavaScriptWithRegion(iindex, expr, isEnter);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public AstAssertInstruction AssertInstruction(int iindex, int value, boolean fromSpecification) {
|
|
|
|
return new AstAssertInstruction(iindex, value, fromSpecification);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int iindex, int result, int val) {
|
|
|
|
return new AssignInstruction(iindex, result, val);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2015-07-25 02:44:10 +00:00
|
|
|
public com.ibm.wala.cast.ir.ssa.EachElementGetInstruction EachElementGetInstruction(int iindex, int value, int objectRef, int prevProp) {
|
|
|
|
return new EachElementGetInstruction(iindex, value, objectRef, prevProp);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2015-07-25 02:44:10 +00:00
|
|
|
public com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction EachElementHasNextInstruction(int iindex, int value, int objectRef, int prop) {
|
|
|
|
return new EachElementHasNextInstruction(iindex, value, objectRef, prop);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public AstEchoInstruction EchoInstruction(int iindex, int[] rvals) {
|
|
|
|
return new AstEchoInstruction(iindex, rvals);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public AstGlobalRead GlobalRead(int iindex, int lhs, FieldReference global) {
|
|
|
|
return new AstGlobalRead(iindex, lhs, global);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public AstGlobalWrite GlobalWrite(int iindex, FieldReference global, int rhs) {
|
|
|
|
return new AstGlobalWrite(iindex, global, rhs);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal, FieldReference fieldRef) {
|
|
|
|
return new AstIsDefinedInstruction(iindex, lval, rval, fieldVal, fieldRef);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, FieldReference fieldRef) {
|
|
|
|
return new AstIsDefinedInstruction(iindex, lval, rval, fieldRef);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal) {
|
|
|
|
return new AstIsDefinedInstruction(iindex, lval, rval, fieldVal);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval) {
|
|
|
|
return new AstIsDefinedInstruction(iindex, lval, rval);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public AstLexicalRead LexicalRead(int iindex, Access[] accesses) {
|
|
|
|
return new AstLexicalRead(iindex, accesses);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public AstLexicalRead LexicalRead(int iindex, Access access) {
|
|
|
|
return new AstLexicalRead(iindex, access);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2014-05-20 15:59:16 +00:00
|
|
|
public AstLexicalRead LexicalRead(int iindex, int lhs, String definer, String globalName, TypeReference type) {
|
|
|
|
return new AstLexicalRead(iindex, lhs, definer, globalName, type);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public AstLexicalWrite LexicalWrite(int iindex, Access[] accesses) {
|
|
|
|
return new AstLexicalWrite(iindex, accesses);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public AstLexicalWrite LexicalWrite(int iindex, Access access) {
|
|
|
|
return new AstLexicalWrite(iindex, access);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2014-05-20 15:59:16 +00:00
|
|
|
public AstLexicalWrite LexicalWrite(int iindex, String definer, String globalName, TypeReference type, int rhs) {
|
|
|
|
return new AstLexicalWrite(iindex, definer, globalName, type, rhs);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAArrayLengthInstruction ArrayLengthInstruction(int iindex, int result, int arrayref) {
|
2009-04-10 18:33:07 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAArrayLoadInstruction ArrayLoadInstruction(int iindex, int result, int arrayref, int index, TypeReference declaredType) {
|
2009-04-10 18:33:07 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAArrayStoreInstruction ArrayStoreInstruction(int iindex, int arrayref, int index, int value, TypeReference declaredType) {
|
2009-04-10 18:33:07 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2015-07-25 02:44:10 +00:00
|
|
|
public SSAAbstractBinaryInstruction BinaryOpInstruction(int iindex, IOperator operator, boolean overflow, boolean unsigned, int result,
|
2009-04-10 18:33:07 +00:00
|
|
|
int val1, int val2, boolean mayBeInteger) {
|
2011-04-13 10:56:36 +00:00
|
|
|
return new SSABinaryOpInstruction(iindex, operator, result, val1, val2, mayBeInteger) {
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public boolean isPEI() {
|
|
|
|
return false;
|
|
|
|
}
|
2009-05-07 13:51:24 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
2011-04-13 10:56:36 +00:00
|
|
|
return insts.BinaryOpInstruction(iindex, getOperator(), false, false, defs == null || defs.length == 0 ? getDef(0) : defs[0],
|
2009-05-07 13:51:24 +00:00
|
|
|
uses == null ? getUse(0) : uses[0], uses == null ? getUse(1) : uses[1], mayBeIntegerOp());
|
|
|
|
}
|
2009-04-10 18:33:07 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2014-04-09 14:29:47 +00:00
|
|
|
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference[] types, boolean isPEI) {
|
2009-04-10 18:33:07 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2014-04-09 14:29:47 +00:00
|
|
|
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int[] typeValues, boolean isPEI) {
|
2010-04-28 19:38:28 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2014-04-09 14:29:47 +00:00
|
|
|
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int typeValue, boolean isPEI) {
|
2011-12-28 17:03:27 +00:00
|
|
|
assert isPEI;
|
2014-04-09 14:29:47 +00:00
|
|
|
return CheckCastInstruction(iindex, result, val, new int[]{ typeValue }, true);
|
2010-04-28 19:38:28 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2014-04-09 14:29:47 +00:00
|
|
|
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference type, boolean isPEI) {
|
2011-12-28 17:03:27 +00:00
|
|
|
assert isPEI;
|
2014-04-09 14:29:47 +00:00
|
|
|
return CheckCastInstruction(iindex, result, val, new TypeReference[]{ type }, true);
|
2010-04-28 19:38:28 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAComparisonInstruction ComparisonInstruction(int iindex, Operator operator, int result, int val1, int val2) {
|
|
|
|
return new SSAComparisonInstruction(iindex, operator, result, val1, val2);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2014-07-28 15:09:02 +00:00
|
|
|
public SSAConditionalBranchInstruction ConditionalBranchInstruction(int iindex,
|
2014-07-08 18:44:06 +00:00
|
|
|
com.ibm.wala.shrikeBT.IConditionalBranchInstruction.IOperator operator, TypeReference type, int val1, int val2, int target) {
|
2014-07-28 15:09:02 +00:00
|
|
|
return new SSAConditionalBranchInstruction(iindex, operator, type, val1, val2, target);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAConversionInstruction ConversionInstruction(int iindex, int result, int val, TypeReference fromType, TypeReference toType,
|
2009-04-10 18:33:07 +00:00
|
|
|
boolean overflow) {
|
|
|
|
assert !overflow;
|
2011-04-13 10:56:36 +00:00
|
|
|
return new SSAConversionInstruction(iindex, result, val, fromType, toType) {
|
2009-04-10 18:33:07 +00:00
|
|
|
@Override
|
|
|
|
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) throws IllegalArgumentException {
|
|
|
|
if (uses != null && uses.length == 0) {
|
|
|
|
throw new IllegalArgumentException("(uses != null) and (uses.length == 0)");
|
|
|
|
}
|
2011-04-13 10:56:36 +00:00
|
|
|
return insts.ConversionInstruction(iindex, defs == null || defs.length == 0 ? getDef(0) : defs[0], uses == null ? getUse(0)
|
2009-05-07 13:51:24 +00:00
|
|
|
: uses[0], getFromType(), getToType(), false);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAGetCaughtExceptionInstruction GetCaughtExceptionInstruction(int iindex, int bbNumber, int exceptionValueNumber) {
|
|
|
|
return new SSAGetCaughtExceptionInstruction(iindex, bbNumber, exceptionValueNumber);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAGetInstruction GetInstruction(int iindex, int result, FieldReference field) {
|
2009-04-10 18:33:07 +00:00
|
|
|
throw new UnsupportedOperationException();
|
2009-05-07 13:51:24 +00:00
|
|
|
}
|
2009-04-10 18:33:07 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAGetInstruction GetInstruction(int iindex, int result, int ref, FieldReference field) {
|
|
|
|
return new SSAGetInstruction(iindex, result, ref, field) {
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public boolean isPEI() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2014-07-28 15:09:02 +00:00
|
|
|
public SSAGotoInstruction GotoInstruction(int iindex, int target) {
|
|
|
|
return new SSAGotoInstruction(iindex, target);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAInstanceofInstruction InstanceofInstruction(int iindex, int result, int ref, TypeReference checkedType) {
|
2009-04-10 18:33:07 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2015-08-12 19:20:21 +00:00
|
|
|
public SSAInvokeInstruction InvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site, BootstrapMethod bootstrap) {
|
2009-04-10 18:33:07 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2015-08-12 19:20:21 +00:00
|
|
|
public SSAInvokeInstruction InvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site, BootstrapMethod bootstrap) {
|
2009-04-10 18:33:07 +00:00
|
|
|
throw new UnsupportedOperationException();
|
2009-05-07 13:51:24 +00:00
|
|
|
}
|
2009-04-10 18:33:07 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSALoadMetadataInstruction LoadMetadataInstruction(int iindex, int lval, TypeReference entityType, Object token) {
|
2009-04-10 18:33:07 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAMonitorInstruction MonitorInstruction(int iindex, int ref, boolean isEnter) {
|
2009-04-10 18:33:07 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site) {
|
|
|
|
return new SSANewInstruction(iindex, result, site) {
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public boolean isPEI() {
|
|
|
|
return true;
|
|
|
|
}
|
2009-05-07 13:51:24 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public Collection<TypeReference> getExceptionTypes() {
|
|
|
|
return Collections.singleton(JavaScriptTypes.TypeError);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site, int[] params) {
|
2009-04-10 18:33:07 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAPhiInstruction PhiInstruction(int iindex, int result, int[] params) {
|
|
|
|
return new SSAPhiInstruction(iindex, result, params);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAPiInstruction PiInstruction(int iindex, int result, int val, int piBlock, int successorBlock, SSAInstruction cause) {
|
|
|
|
return new SSAPiInstruction(iindex, result, val, piBlock, successorBlock, cause);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAPutInstruction PutInstruction(int iindex, int ref, int value, FieldReference field) {
|
|
|
|
return new SSAPutInstruction(iindex, ref, value, field) {
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public boolean isPEI() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAPutInstruction PutInstruction(int iindex, int value, FieldReference field) {
|
2009-04-10 18:33:07 +00:00
|
|
|
throw new UnsupportedOperationException();
|
2009-05-07 13:51:24 +00:00
|
|
|
}
|
2009-04-10 18:33:07 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAReturnInstruction ReturnInstruction(int iindex) {
|
|
|
|
return new SSAReturnInstruction(iindex);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAReturnInstruction ReturnInstruction(int iindex, int result, boolean isPrimitive) {
|
|
|
|
return new SSAReturnInstruction(iindex, result, isPrimitive);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSASwitchInstruction SwitchInstruction(int iindex, int val, int defaultLabel, int[] casesAndLabels) {
|
|
|
|
return new SSASwitchInstruction(iindex, val, defaultLabel, casesAndLabels);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAThrowInstruction ThrowInstruction(int iindex, int exception) {
|
|
|
|
return new SSAThrowInstruction(iindex, exception) {
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public boolean isPEI() {
|
|
|
|
return true;
|
|
|
|
}
|
2009-05-07 13:51:24 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public Collection<TypeReference> getExceptionTypes() {
|
|
|
|
return Collections.emptySet();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAUnaryOpInstruction UnaryOpInstruction(int iindex, com.ibm.wala.shrikeBT.IUnaryOpInstruction.IOperator operator, int result,
|
2009-04-10 18:33:07 +00:00
|
|
|
int val) {
|
2011-04-13 10:56:36 +00:00
|
|
|
return new SSAUnaryOpInstruction(iindex, operator, result, val);
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
2009-05-07 13:51:24 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, TypeReference pointeeType) {
|
2009-05-20 18:56:23 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, int indexVal, TypeReference pointeeType) {
|
2009-05-20 18:56:23 +00:00
|
|
|
throw new UnsupportedOperationException();
|
2011-04-20 23:08:47 +00:00
|
|
|
}
|
2009-05-20 18:56:23 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, FieldReference field, TypeReference pointeeType) {
|
2009-05-20 18:56:23 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSALoadIndirectInstruction LoadIndirectInstruction(int iindex, int lval, TypeReference t, int addressVal) {
|
2009-05-20 18:56:23 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2011-04-13 10:56:36 +00:00
|
|
|
public SSAStoreIndirectInstruction StoreIndirectInstruction(int iindex, int addressVal, int rval, TypeReference t) {
|
2009-05-20 18:56:23 +00:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2012-03-01 02:45:51 +00:00
|
|
|
@Override
|
2014-04-09 14:29:47 +00:00
|
|
|
public PrototypeLookup PrototypeLookup(int iindex, int lval, int object) {
|
|
|
|
return new PrototypeLookup(iindex, lval, object);
|
2012-03-01 02:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-04-09 14:29:47 +00:00
|
|
|
public SetPrototype SetPrototype(int iindex, int object, int prototype) {
|
|
|
|
return new SetPrototype(iindex, object, prototype);
|
2012-03-01 02:45:51 +00:00
|
|
|
}
|
|
|
|
|
2009-04-10 18:33:07 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public boolean isDoubleType(TypeReference type) {
|
|
|
|
return type == JavaScriptTypes.Number || type == JavaScriptTypes.NumberObject;
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public boolean isFloatType(TypeReference type) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public boolean isIntType(TypeReference type) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public boolean isLongType(TypeReference type) {
|
2009-05-07 13:51:24 +00:00
|
|
|
return false;
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public boolean isMetadataType(TypeReference type) {
|
2009-05-07 13:51:24 +00:00
|
|
|
return false;
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public boolean isStringType(TypeReference type) {
|
2009-05-07 13:51:24 +00:00
|
|
|
return type == JavaScriptTypes.String || type == JavaScriptTypes.StringObject;
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-05-07 13:51:24 +00:00
|
|
|
public boolean isVoidType(TypeReference type) {
|
|
|
|
return false;
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
2009-05-20 18:56:23 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-05-20 18:56:23 +00:00
|
|
|
public TypeReference getStringType() {
|
|
|
|
return JavaScriptTypes.String;
|
|
|
|
}
|
2009-06-03 16:58:55 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-06-03 18:26:29 +00:00
|
|
|
public PrimitiveType getPrimitive(TypeReference reference) {
|
2014-04-09 15:33:57 +00:00
|
|
|
return PrimitiveType.getPrimitive(reference);
|
2009-06-03 18:26:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-06-03 16:58:55 +00:00
|
|
|
public boolean isBooleanType(TypeReference type) {
|
2011-04-20 23:08:47 +00:00
|
|
|
return JavaScriptTypes.Boolean.equals(type);
|
2009-06-03 16:58:55 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-06-03 16:58:55 +00:00
|
|
|
public boolean isCharType(TypeReference type) {
|
2011-04-20 23:08:47 +00:00
|
|
|
return false;
|
2009-06-03 16:58:55 +00:00
|
|
|
}
|
2009-06-03 18:26:29 +00:00
|
|
|
|
2018-02-05 23:18:37 +00:00
|
|
|
@Override
|
|
|
|
public AbstractRootMethod getFakeRootMethod(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) {
|
|
|
|
return new JSFakeRoot(cha, options, cache);
|
|
|
|
}
|
|
|
|
|
2007-06-01 03:32:56 +00:00
|
|
|
};
|
|
|
|
|
2007-02-02 17:25:09 +00:00
|
|
|
private final JavaScriptTranslatorFactory translatorFactory;
|
2012-01-06 21:17:39 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final CAstRewriterFactory<?, ?> preprocessor;
|
2012-01-06 21:17:39 +00:00
|
|
|
|
2007-06-01 03:32:56 +00:00
|
|
|
public JavaScriptLoader(IClassHierarchy cha, JavaScriptTranslatorFactory translatorFactory) {
|
2012-01-06 21:17:39 +00:00
|
|
|
this(cha, translatorFactory, null);
|
|
|
|
}
|
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
public JavaScriptLoader(IClassHierarchy cha, JavaScriptTranslatorFactory translatorFactory, CAstRewriterFactory<?, ?> preprocessor) {
|
2007-11-16 01:54:39 +00:00
|
|
|
super(cha);
|
2007-02-02 17:25:09 +00:00
|
|
|
this.translatorFactory = translatorFactory;
|
2012-01-06 21:17:39 +00:00
|
|
|
this.preprocessor = preprocessor;
|
2007-02-02 17:25:09 +00:00
|
|
|
}
|
|
|
|
|
2009-04-15 12:52:40 +00:00
|
|
|
private static final Set<CAstQualifier> functionQualifiers;
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2009-04-15 12:52:40 +00:00
|
|
|
static {
|
2007-07-11 21:08:21 +00:00
|
|
|
functionQualifiers = HashSetFactory.make();
|
2007-02-02 17:25:09 +00:00
|
|
|
functionQualifiers.add(CAstQualifier.PUBLIC);
|
|
|
|
functionQualifiers.add(CAstQualifier.FINAL);
|
|
|
|
}
|
|
|
|
|
2012-01-27 20:15:33 +00:00
|
|
|
public IClass makeCodeBodyType(String name, TypeReference P, CAstSourcePositionMap.Position sourcePosition, CAstEntity entity, WalkContext context) {
|
2018-01-30 19:08:25 +00:00
|
|
|
return new DynamicCodeBody(TypeReference.findOrCreate(JavaScriptTypes.jsLoader, TypeName.string2TypeName(name)), P, this,
|
2012-01-27 20:15:33 +00:00
|
|
|
sourcePosition, entity, context);
|
2007-02-02 17:25:09 +00:00
|
|
|
}
|
|
|
|
|
2012-01-27 20:15:33 +00:00
|
|
|
public IClass defineFunctionType(String name, CAstSourcePositionMap.Position pos, CAstEntity entity, WalkContext context) {
|
|
|
|
return makeCodeBodyType(name, JavaScriptTypes.Function, pos, entity, context);
|
2007-02-02 17:25:09 +00:00
|
|
|
}
|
|
|
|
|
2012-01-27 20:15:33 +00:00
|
|
|
public IClass defineScriptType(String name, CAstSourcePositionMap.Position pos, CAstEntity entity, WalkContext context) {
|
|
|
|
return makeCodeBodyType(name, JavaScriptTypes.Script, pos, entity, context);
|
2007-02-02 17:25:09 +00:00
|
|
|
}
|
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
public IMethod defineCodeBodyCode(String clsName, AbstractCFG<?, ?> cfg, SymbolTable symtab, boolean hasCatchBlock,
|
2017-02-23 15:15:59 +00:00
|
|
|
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
|
2018-01-30 19:08:25 +00:00
|
|
|
DynamicCodeBody C = (DynamicCodeBody) lookupClass(clsName, cha);
|
2009-04-30 13:16:52 +00:00
|
|
|
assert C != null : clsName;
|
2012-01-27 20:15:33 +00:00
|
|
|
return C.setCodeBody(makeCodeBodyCode(cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo, C));
|
|
|
|
}
|
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
public DynamicMethodObject makeCodeBodyCode(AbstractCFG<?, ?> cfg, SymbolTable symtab, boolean hasCatchBlock,
|
2017-02-23 15:15:59 +00:00
|
|
|
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo,
|
2012-01-27 20:15:33 +00:00
|
|
|
IClass C) {
|
2018-01-30 19:08:25 +00:00
|
|
|
return new DynamicMethodObject(C, functionQualifiers, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo,
|
2012-01-27 20:15:33 +00:00
|
|
|
debugInfo);
|
2007-02-02 17:25:09 +00:00
|
|
|
}
|
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass ROOT = new CoreClass(AstTypeReference.rootTypeName, null, this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass UNDEFINED = new CoreClass(JavaScriptTypes.Undefined.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass PRIMITIVES = new CoreClass(JavaScriptTypes.Primitives.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass FAKEROOT = new CoreClass(JavaScriptTypes.FakeRoot.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-06-01 03:32:56 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass STRING = new CoreClass(JavaScriptTypes.String.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass NULL = new CoreClass(JavaScriptTypes.Null.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass ARRAY = new CoreClass(JavaScriptTypes.Array.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-04-19 13:53:31 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass OBJECT = new CoreClass(JavaScriptTypes.Object.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-04-19 13:53:31 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass TYPE_ERROR = new CoreClass(JavaScriptTypes.TypeError.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-04-19 13:53:31 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass CODE_BODY = new CoreClass(JavaScriptTypes.CodeBody.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-04-19 13:53:31 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass FUNCTION = new CoreClass(JavaScriptTypes.Function.getName(), JavaScriptTypes.CodeBody.getName(), this, null);
|
2007-04-19 13:53:31 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass SCRIPT = new CoreClass(JavaScriptTypes.Script.getName(), JavaScriptTypes.CodeBody.getName(), this, null);
|
2007-04-19 13:53:31 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass BOOLEAN = new CoreClass(JavaScriptTypes.Boolean.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass NUMBER = new CoreClass(JavaScriptTypes.Number.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass DATE = new CoreClass(JavaScriptTypes.Date.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass REGEXP = new CoreClass(JavaScriptTypes.RegExp.getName(), JavaScriptTypes.Root.getName(), this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass BOOLEAN_OBJECT = new CoreClass(JavaScriptTypes.BooleanObject.getName(), JavaScriptTypes.Object.getName(), this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass NUMBER_OBJECT = new CoreClass(JavaScriptTypes.NumberObject.getName(), JavaScriptTypes.Object.getName(), this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass DATE_OBJECT = new CoreClass(JavaScriptTypes.DateObject.getName(), JavaScriptTypes.Object.getName(), this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass REGEXP_OBJECT = new CoreClass(JavaScriptTypes.RegExpObject.getName(), JavaScriptTypes.Object.getName(), this, null);
|
2007-02-09 15:34:25 +00:00
|
|
|
|
2018-01-30 19:08:25 +00:00
|
|
|
final CoreClass STRING_OBJECT = new CoreClass(JavaScriptTypes.StringObject.getName(), JavaScriptTypes.Object.getName(), this, null);
|
2007-02-02 17:25:09 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-06-01 03:32:56 +00:00
|
|
|
public Language getLanguage() {
|
|
|
|
return JS;
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-11-16 01:54:39 +00:00
|
|
|
public ClassLoaderReference getReference() {
|
|
|
|
return JavaScriptTypes.jsLoader;
|
2007-02-02 17:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2009-04-10 18:33:07 +00:00
|
|
|
public SSAInstructionFactory getInstructionFactory() {
|
2009-05-07 13:51:24 +00:00
|
|
|
return JS.instructionFactory();
|
2009-04-10 18:33:07 +00:00
|
|
|
}
|
|
|
|
|
2011-04-20 23:08:47 +00:00
|
|
|
/**
|
|
|
|
* JavaScript files with code to model various aspects of the language
|
|
|
|
* semantics. See com.ibm.wala.cast.js/dat/prologue.js.
|
|
|
|
*/
|
2009-04-15 12:52:40 +00:00
|
|
|
public static final Set<String> bootstrapFileNames;
|
|
|
|
|
|
|
|
private static String prologueFileName = "prologue.js";
|
|
|
|
|
|
|
|
public static void resetPrologueFile() {
|
|
|
|
prologueFileName = "prologue.js";
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setPrologueFile(String name) {
|
|
|
|
prologueFileName = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void addBootstrapFile(String fileName) {
|
|
|
|
bootstrapFileNames.add(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
static {
|
|
|
|
bootstrapFileNames = HashSetFactory.make();
|
|
|
|
bootstrapFileNames.add(prologueFileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-01-12 17:25:37 +00:00
|
|
|
protected TranslatorToCAst getTranslatorToCAst(final CAst ast, ModuleEntry module) {
|
2017-02-03 01:33:27 +00:00
|
|
|
TranslatorToCAst translator = translatorFactory.make(ast, module);
|
2012-01-06 21:49:48 +00:00
|
|
|
if(preprocessor != null)
|
|
|
|
translator.addRewriter(preprocessor, true);
|
|
|
|
return translator;
|
2009-04-15 12:52:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected TranslatorToIR initTranslator() {
|
|
|
|
return new JSAstTranslator(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean shouldTranslate(CAstEntity entity) {
|
|
|
|
return true;
|
2007-02-02 17:25:09 +00:00
|
|
|
}
|
|
|
|
}
|