diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7b4f32de869..39b8cad881e 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -10,19 +10,15 @@
+
-
-
-
-
+
-
-
-
-
+
+
@@ -152,19 +148,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -225,10 +208,19 @@
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
@@ -237,63 +229,50 @@
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -301,21 +280,19 @@
-
-
+
+
-
-
-
-
+
+
-
-
+
+
-
+
@@ -352,10 +329,19 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
@@ -394,21 +380,21 @@
@@ -508,248 +494,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -815,35 +559,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -959,6 +675,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1115,11 +864,11 @@
-
-
-
-
-
+
+
+
+
+
localhost
@@ -1238,7 +987,7 @@
-
+
@@ -1251,7 +1000,6 @@
-
@@ -1276,6 +1024,7 @@
+
@@ -1285,110 +1034,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1396,9 +1048,102 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/translator/src/org/jetbrains/k2js/K2JSTranslator.java b/translator/src/org/jetbrains/k2js/K2JSTranslator.java
index a2fd58fe234..8107172ff64 100644
--- a/translator/src/org/jetbrains/k2js/K2JSTranslator.java
+++ b/translator/src/org/jetbrains/k2js/K2JSTranslator.java
@@ -63,10 +63,11 @@ public final class K2JSTranslator {
@NotNull
public String translateStringWithCallToMain(@NotNull String programText, @NotNull String argumentsString) {
JetFile file = createPsiFile("test", programText);
- String programCode = generateProgramCode(file);
+ String programCode = generateProgramCode(file) + "\n";
+ String flushOutput = "Kotlin.System.flush();\n";
String callToMain = generateCallToMain(file, argumentsString);
- String programOutput = "Kotlin.System.output();";
- return programCode + callToMain + programOutput;
+ String programOutput = "Kotlin.System.output();\n";
+ return programCode + flushOutput + callToMain + programOutput;
}
private String generateProgramCode(JetFile psiFile) {
diff --git a/translator/src/org/jetbrains/k2js/translate/context/NamingScope.java b/translator/src/org/jetbrains/k2js/translate/context/NamingScope.java
index f583f279108..bb7c3510e63 100644
--- a/translator/src/org/jetbrains/k2js/translate/context/NamingScope.java
+++ b/translator/src/org/jetbrains/k2js/translate/context/NamingScope.java
@@ -69,8 +69,13 @@ public final class NamingScope {
private String mayBeObfuscateName(@NotNull String name) {
int obfuscate = 0;
String result = name;
-// while (scope.findExistingName(result) != null) {
-// result = name + "_" + obfuscate;
+// while (true) {
+// JsName existingNameWithSameIdent = scope.findExistingName(result);
+// boolean isDuplicate = (existingNameWithSameIdent != null) && (scope.ownsName(existingNameWithSameIdent));
+//
+// if (!isDuplicate) break;
+//
+// result = name + "$" + obfuscate;
// obfuscate++;
// }
return result;
diff --git a/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java b/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java
index 128f453a059..9ba86743f4f 100644
--- a/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java
+++ b/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java
@@ -115,7 +115,6 @@ public final class StandardClasses {
}
}
-
@NotNull
private final JsScope kotlinScope;
diff --git a/translator/testFiles/kotlin_lib.js b/translator/testFiles/kotlin_lib.js
index 18a5726345b..a6ebd687d2b 100644
--- a/translator/testFiles/kotlin_lib.js
+++ b/translator/testFiles/kotlin_lib.js
@@ -387,6 +387,9 @@ Kotlin.System = function () {
},
output:function () {
return output;
+ },
+ flush:function () {
+ output = "";
}
};
}();