Package org.teavm.debugging.information

Examples of org.teavm.debugging.information.DebugInformationBuilder$ClassMetadata


                vm.setProgressListener(progressListener);
            }
            vm.setMinifying(minifying);
            vm.setBytecodeLogging(bytecodeLogging);
            vm.setProperties(properties);
            DebugInformationBuilder debugEmitter = debugInformationGenerated || sourceMapsFileGenerated ?
                    new DebugInformationBuilder() : null;
            vm.setDebugEmitter(debugEmitter);
            vm.setIncremental(incremental);
            if (incremental) {
                vm.setAstCache(astCache);
                vm.setProgramCache(programCache);
            }
            vm.installPlugins();
            for (ClassHolderTransformer transformer : transformers) {
                vm.add(transformer);
            }
            if (mainClass != null) {
                MethodDescriptor mainMethodDesc = new MethodDescriptor("main", String[].class, void.class);
                vm.entryPoint("main", new MethodReference(mainClass, mainMethodDesc))
                        .withValue(1, "java.lang.String");
            }
            for (ClassAlias alias : classAliases) {
                vm.exportType(alias.getAlias(), alias.getClassName());
            }
            for (MethodAlias methodAlias : methodAliases) {
                MethodReference ref = new MethodReference(methodAlias.getClassName(), methodAlias.getMethodName(),
                        MethodDescriptor.parseSignature(methodAlias.getDescriptor()));
                TeaVMEntryPoint entryPoint = vm.entryPoint(methodAlias.getAlias(), ref);
                if (methodAlias.getTypes() != null) {
                    for (int i = 0; i < methodAlias.getTypes().length; ++i) {
                        String types = methodAlias.getTypes()[i];
                        if (types != null) {
                            for (String type : types.split(" +")) {
                                type = type.trim();
                                if (!type.isEmpty()) {
                                    entryPoint.withValue(i, type);
                                }
                            }
                        }
                    }
                }
            }
            targetDirectory.mkdirs();
            try (Writer writer = new OutputStreamWriter(new BufferedOutputStream(
                    new FileOutputStream(new File(targetDirectory, targetFileName))), "UTF-8")) {
                if (runtime == RuntimeCopyOperation.MERGED) {
                    vm.add(runtimeInjector);
                }
                vm.build(writer, new DirectoryBuildTarget(targetDirectory));
                if (vm.wasCancelled()) {
                    log.info("Build cancelled");
                    cancelled = true;
                    return;
                }
                if (vm.hasMissingItems()) {
                    log.info("Missing items found");
                    return;
                }
                log.info("JavaScript file successfully built");
                if (debugInformationGenerated) {
                    DebugInformation debugInfo = debugEmitter.getDebugInformation();
                    try (OutputStream debugInfoOut = new FileOutputStream(new File(targetDirectory,
                            targetFileName + ".teavmdbg"))) {
                        debugInfo.write(debugInfoOut);
                    }
                    log.info("Debug information successfully written");
                }
                if (sourceMapsFileGenerated) {
                    DebugInformation debugInfo = debugEmitter.getDebugInformation();
                    String sourceMapsFileName = targetFileName + ".map";
                    writer.append("\n//# sourceMappingURL=").append(sourceMapsFileName);
                    try (Writer sourceMapsOut = new OutputStreamWriter(new FileOutputStream(
                            new File(targetDirectory, sourceMapsFileName)), "UTF-8")) {
                        debugInfo.writeAsSourceMaps(sourceMapsOut, "src", targetFileName);
View Full Code Here


        new TestExceptionPlugin().install(vm);
        for (ClassHolderTransformer transformer : transformers) {
            vm.add(transformer);
        }
        File file = new File(outputDir, targetName);
        DebugInformationBuilder debugInfoBuilder = sourceMapsGenerated || debugInformationGenerated ?
                new DebugInformationBuilder() : null;
        try (Writer innerWriter = new OutputStreamWriter(new FileOutputStream(file), "UTF-8")) {
            MethodReference cons = new MethodReference(methodRef.getClassName(), "<init>", ValueType.VOID);
            MethodReference exceptionMsg = new MethodReference(ExceptionHelper.class, "showException",
                    Throwable.class, String.class);
            vm.entryPoint("initInstance", cons);
            vm.entryPoint("runTest", methodRef).withValue(0, cons.getClassName());
            vm.entryPoint("extractException", exceptionMsg);
            vm.exportType("TestClass", cons.getClassName());
            vm.setDebugEmitter(debugInfoBuilder);
            vm.build(innerWriter, new DirectoryBuildTarget(outputDir));
            if (!vm.hasMissingItems()) {
                innerWriter.append("\n");
                innerWriter.append("\nJUnitClient.run();");
                if (sourceMapsGenerated) {
                    String sourceMapsFileName = targetName.substring(targetName.lastIndexOf('/') + 1) + ".map";
                    innerWriter.append("\n//# sourceMappingURL=").append(sourceMapsFileName);
                }
            } else {
                innerWriter.append("JUnitClient.reportError(\n");
                StringBuilder sb = new StringBuilder();
                vm.showMissingItems(sb);
                escapeStringLiteral(sb.toString(), innerWriter);
                innerWriter.append(");");
                log.warning("Error building test " + methodRef);
                log.warning(sb.toString());
            }
        }
        if (sourceMapsGenerated) {
            DebugInformation debugInfo = debugInfoBuilder.getDebugInformation();
            try (OutputStream debugInfoOut = new FileOutputStream(new File(outputDir, targetName + ".teavmdbg"))) {
                debugInfo.write(debugInfoOut);
            }
        }
        if (sourceMapsGenerated) {
            DebugInformation debugInfo = debugInfoBuilder.getDebugInformation();
            String sourceMapsFileName = targetName + ".map";
            try (Writer sourceMapsOut = new OutputStreamWriter(new FileOutputStream(
                    new File(outputDir, sourceMapsFileName)), "UTF-8")) {
                debugInfo.writeAsSourceMaps(sourceMapsOut, "src", targetName);
            }
View Full Code Here

TOP

Related Classes of org.teavm.debugging.information.DebugInformationBuilder$ClassMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.