This commit is contained in:
Michael Bebenita 2014-11-18 18:20:20 -08:00
Родитель 5ba82d9738
Коммит 9cbb5aa1b2
2 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -8,6 +8,7 @@ module J2ME {
export function printResults() {
counter.trace(new IndentingWriter());
consoleWriter.writeLn(JSON.stringify(staticCallGraph, null, 2));
}
import Block = Bytecode.Block;
@ -45,6 +46,8 @@ module J2ME {
}
var staticCallGraph = Object.create(null);
declare var CLASSES: any;
declare var Long: any;
declare var VM: any;
@ -1162,6 +1165,12 @@ module J2ME {
}
genInvoke(methodInfo: MethodInfo, opcode: Bytecodes, nextBCI: number) {
var callees = staticCallGraph[this.methodInfo.implKey];
if (!callees) {
callees = staticCallGraph[this.methodInfo.implKey] = [];
}
ArrayUtilities.pushUnique(callees, methodInfo.implKey);
var signature = SignatureDescriptor.makeSignatureDescriptor(methodInfo.signature);
var types = signature.typeDescriptors;
var args: Value [] = [];

Просмотреть файл

@ -78,6 +78,7 @@ module J2ME {
var verboseOption: Options.Option;
var classpathOption: Options.Option;
var callGraphOption: Options.Option;
var classFilterOption: Options.Option;
var debuggerOption: Options.Option;
var releaseOption: Options.Option;
@ -89,6 +90,9 @@ module J2ME {
verboseOption = shellOptions.register(new Options.Option("v", "verbose", "boolean", false, "Verbose"));
classpathOption = shellOptions.register(new Options.Option("cp", "classpath", "string []", [], "Compile ClassPath"));
callGraphOption = shellOptions.register(new Options.Option("cg", "callGraph", "string []", [], "Call Grpah Files"));
classFilterOption = shellOptions.register(new Options.Option("f", "filter", "string", ".*", "Compile Filter"));
debuggerOption = shellOptions.register(new Options.Option("d", "debugger", "boolean", false, "Emit Debug Information"));
releaseOption = shellOptions.register(new Options.Option("r", "release", "boolean", false, "Release mode"));
@ -121,6 +125,16 @@ module J2ME {
return true;
}
});
callGraphOption.value.filter(function (value, index, array) {
if (value.endsWith(".json")) {
var calls = JSON.parse(snarf(value));
writer.writeLn(JSON.stringify(calls, null, 2));
} else {
return true;
}
});
} catch (x) {
writer.writeLn(x.message);
writer.writeLns(x.stack);