Fix minor bugs

This commit is contained in:
Alexey Andreev 2016-09-16 23:26:34 +03:00
parent 8bfcb5f086
commit 7aaf67d16f
5 changed files with 23 additions and 11 deletions

View File

@ -233,6 +233,7 @@ public class JavaScriptTarget implements TeaVMTarget, TeaVMJavaScriptHost {
} }
RenderingContext renderingContext = new RenderingContext(debugEmitterToUse, classes, RenderingContext renderingContext = new RenderingContext(debugEmitterToUse, classes,
controller.getClassLoader(), controller.getServices(), controller.getProperties(), naming); controller.getClassLoader(), controller.getServices(), controller.getProperties(), naming);
renderingContext.setMinifying(minifying);
Renderer renderer = new Renderer(sourceWriter, asyncMethods, asyncFamilyMethods, Renderer renderer = new Renderer(sourceWriter, asyncMethods, asyncFamilyMethods,
controller.getDiagnostics(), renderingContext); controller.getDiagnostics(), renderingContext);
renderer.setProperties(controller.getProperties()); renderer.setProperties(controller.getProperties());

View File

@ -454,8 +454,8 @@ public class StatementRenderer implements ExprVisitor, StatementVisitor {
} }
private String generateVariableName(int index) { private String generateVariableName(int index) {
if (index == 0) { if (index == 0 && minifying) {
return minifying ? "$t" : "$this"; return "$t";
} }
if (!minifying) { if (!minifying) {

View File

@ -1,8 +1,18 @@
<!-- Copyright 2014 Alexey Andreev. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this <!--
file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ~ Copyright 2016 Alexey Andreev.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS ~
IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language ~ Licensed under the Apache License, Version 2.0 (the "License");
governing permissions and limitations under the License. --> ~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -129,8 +139,9 @@
<targetDirectory>${project.build.directory}/generated/js/teavm</targetDirectory> <targetDirectory>${project.build.directory}/generated/js/teavm</targetDirectory>
<mainClass>org.teavm.samples.benchmark.teavm.BenchmarkStarter</mainClass> <mainClass>org.teavm.samples.benchmark.teavm.BenchmarkStarter</mainClass>
<runtime>SEPARATE</runtime> <runtime>SEPARATE</runtime>
<minifying>false</minifying> <minifying>true</minifying>
<debugInformationGenerated>true</debugInformationGenerated> <debugInformationGenerated>true</debugInformationGenerated>
<optimizationLevel>FULL</optimizationLevel>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>

View File

@ -80,11 +80,11 @@ public final class TeaVMRunner {
options.addOption(OptionBuilder options.addOption(OptionBuilder
.withDescription("Generate debug information") .withDescription("Generate debug information")
.withLongOpt("debug") .withLongOpt("debug")
.create('D')); .create('g'));
options.addOption(OptionBuilder options.addOption(OptionBuilder
.withDescription("Generate source maps") .withDescription("Generate source maps")
.withLongOpt("sourcemaps") .withLongOpt("sourcemaps")
.create('S')); .create('G'));
options.addOption(OptionBuilder options.addOption(OptionBuilder
.withDescription("Incremental build") .withDescription("Incremental build")
.withLongOpt("incremental") .withLongOpt("incremental")

View File

@ -432,7 +432,7 @@ public class TeaVMTool implements BaseTeaVMTool {
} }
if (targetType == TeaVMTargetType.JAVASCRIPT) { if (targetType == TeaVMTargetType.JAVASCRIPT) {
try (OutputStream output = buildTarget.createResource(outputName)) { try (OutputStream output = new FileOutputStream(new File(targetDirectory, outputName), true)) {
Writer writer = new OutputStreamWriter(output, "UTF-8"); Writer writer = new OutputStreamWriter(output, "UTF-8");
additionalJavaScriptOutput(writer); additionalJavaScriptOutput(writer);
} }