зеркало из https://github.com/mozilla/pluotsorbet.git
Dump call graphs.
This commit is contained in:
Родитель
5ba82d9738
Коммит
9cbb5aa1b2
|
@ -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 [] = [];
|
||||
|
|
14
opt/shell.ts
14
opt/shell.ts
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче