Version 0.1.6.0

svn merge -r 13622:13640 https://dart.googlecode.com/svn/branches/bleeding_edge
trunk

git-svn-id: http://dart.googlecode.com/svn/trunk@13651 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/compiler/implementation/closure.dart b/lib/compiler/implementation/closure.dart
index 6e11253..be78e41 100644
--- a/lib/compiler/implementation/closure.dart
+++ b/lib/compiler/implementation/closure.dart
@@ -312,9 +312,12 @@
       // We still need to visit the right-hand sides of the init-assignments.
       // For SendSets don't visit the left again. Otherwise it would be marked
       // as mutated.
-      if (definition is SendSet) {
-        SendSet assignment = definition;
-        visit(assignment.argumentsNode);
+      if (definition is Send) {
+        Send assignment = definition;
+        Node arguments = assignment.argumentsNode;
+        if (arguments != null) {
+          visit(arguments);
+        }
       } else {
         visit(definition);
       }
diff --git a/lib/compiler/implementation/scanner/class_element_parser.dart b/lib/compiler/implementation/scanner/class_element_parser.dart
index b2a4b03..cd1ae54 100644
--- a/lib/compiler/implementation/scanner/class_element_parser.dart
+++ b/lib/compiler/implementation/scanner/class_element_parser.dart
@@ -99,6 +99,10 @@
       bool isUnary = operator.token.next.next.stringValue === ')';
       return Elements.constructOperatorName(operator.source, isUnary);
     } else {
+      if (receiver == null) {
+        listener.cancel('library prefix in named factory constructor not '
+                        'implemented', node: send.receiver);
+      }
       return Elements.constructConstructorName(receiver.source,
                                                selector.source);
     }
diff --git a/lib/compiler/implementation/scanner/listener.dart b/lib/compiler/implementation/scanner/listener.dart
index 424d17f..a989ef4 100644
--- a/lib/compiler/implementation/scanner/listener.dart
+++ b/lib/compiler/implementation/scanner/listener.dart
@@ -1663,11 +1663,17 @@
                         Token endToken) {
     Statement body = popNode();
     NodeList formals = popNode();
-    NodeList typeParameters = popNode(); // TODO(karlklose): don't throw away.
-    Node name = popNode();
+    // TODO(karlklose): don't throw type parameters away.
+    NodeList typeParameters;
+    Node name;
     if (periodBeforeName !== null) {
+      name = popNode();
+      typeParameters = popNode();
       // A library prefix was handled in [handleQualified].
       name = new Send(popNode(), name);
+    } else {
+      typeParameters = popNode();
+      name = popNode();
     }
     // TODO(ahe): Move this parsing to the parser.
     int modifierCount = 0;
diff --git a/lib/compiler/implementation/scanner/parser.dart b/lib/compiler/implementation/scanner/parser.dart
index a276ebe..54ebdd5 100644
--- a/lib/compiler/implementation/scanner/parser.dart
+++ b/lib/compiler/implementation/scanner/parser.dart
@@ -2135,6 +2135,7 @@
   Token parseAssertStatement(Token token) {
     Token assertKeyword = token;
     token = expect('assert', token);
+    expect('(', token);
     token = parseArguments(token);
     listener.handleAssertStatement(assertKeyword, token);
     return expectSemicolon(token);
diff --git a/lib/compiler/implementation/tree/unparser.dart b/lib/compiler/implementation/tree/unparser.dart
index 8eda637..a99854a 100644
--- a/lib/compiler/implementation/tree/unparser.dart
+++ b/lib/compiler/implementation/tree/unparser.dart
@@ -270,7 +270,8 @@
     if (!node.isPrefix && !node.isIndex) visit(node.selector);
     if (spacesNeeded) sb.add(' ');
     // Also add a space for sequences like x + +1 and y - -y.
-    if (opString === '-' || opString === '+') {
+    // TODO(ahe): remove case for '+' when we drop the support for it.
+    if (node.argumentsNode != null && (opString === '-' || opString === '+')) {
       Token beginToken = node.argumentsNode.getBeginToken();
       if (beginToken !== null && beginToken.stringValue === opString) {
         sb.add(' ');
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index 6502549..179264b 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -1022,27 +1022,32 @@
 
 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalMirrorSystem)(
     Dart_NativeArguments args) {
+  Dart_EnterScope();
   Dart_Handle mirrors = CreateMirrorSystem();
   if (Dart_IsError(mirrors)) {
     Dart_PropagateError(mirrors);
   }
   Dart_SetReturnValue(args, mirrors);
+  Dart_ExitScope();
 }
 
 
 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalInstanceMirror)(
     Dart_NativeArguments args) {
+  Dart_EnterScope();
   Dart_Handle reflectee = Dart_GetNativeArgument(args, 0);
   Dart_Handle mirror = CreateInstanceMirror(reflectee);
   if (Dart_IsError(mirror)) {
     Dart_PropagateError(mirror);
   }
   Dart_SetReturnValue(args, mirror);
+  Dart_ExitScope();
 }
 
 
 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_invoke)(
     Dart_NativeArguments args) {
+  Dart_EnterScope();
   Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
   Dart_Handle member = Dart_GetNativeArgument(args, 1);
   // The wrapped arguments are either simple values or instance mirrors.
@@ -1067,11 +1072,13 @@
     Dart_PropagateError(wrapped_result);
   }
   Dart_SetReturnValue(args, wrapped_result);
+  Dart_ExitScope();
 }
 
 
 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_getField)(
     Dart_NativeArguments args) {
+  Dart_EnterScope();
   Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
   Dart_Handle fieldName = Dart_GetNativeArgument(args, 1);
 
@@ -1088,11 +1095,13 @@
     Dart_PropagateError(wrapped_result);
   }
   Dart_SetReturnValue(args, wrapped_result);
+  Dart_ExitScope();
 }
 
 
 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_setField)(
     Dart_NativeArguments args) {
+  Dart_EnterScope();
   Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
   Dart_Handle fieldName = Dart_GetNativeArgument(args, 1);
   // The wrapped argument is either a simple value or instance mirror.
@@ -1115,11 +1124,13 @@
     Dart_PropagateError(wrapped_result);
   }
   Dart_SetReturnValue(args, wrapped_result);
+  Dart_ExitScope();
 }
 
 
 void NATIVE_ENTRY_FUNCTION(LocalClosureMirrorImpl_apply)(
     Dart_NativeArguments args) {
+  Dart_EnterScope();
   Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
   // The wrapped arguments are either simple values or instance mirrors.
   Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 1);
@@ -1143,11 +1154,13 @@
     Dart_PropagateError(wrapped_result);
   }
   Dart_SetReturnValue(args, wrapped_result);
+  Dart_ExitScope();
 }
 
 
 void NATIVE_ENTRY_FUNCTION(LocalClassMirrorImpl_invokeConstructor)(
     Dart_NativeArguments args) {
+  Dart_EnterScope();
   Dart_Handle klass_mirror = Dart_GetNativeArgument(args, 0);
   Dart_Handle constructor_name = Dart_GetNativeArgument(args, 1);
   // The wrapped arguments are either simple values or instance mirrors.
@@ -1174,6 +1187,7 @@
     Dart_PropagateError(wrapped_result);
   }
   Dart_SetReturnValue(args, wrapped_result);
+  Dart_ExitScope();
 }
 
 
diff --git a/tests/co19/co19-dart2dart.status b/tests/co19/co19-dart2dart.status
index d9365ce..38b88e3 100644
--- a/tests/co19/co19-dart2dart.status
+++ b/tests/co19/co19-dart2dart.status
@@ -159,7 +159,6 @@
 Language/07_Classes/6_Constructors/1_Generative_Constructors_A09_t01: Fail # http://dartbug.com/5519
 Language/07_Classes/6_Constructors/1_Generative_Constructors_A15_t07: Fail # inherited from VM
 Language/07_Classes/6_Constructors/1_Generative_Constructors_A21_t01: Fail # http://dartbug.com/5519
-Language/07_Classes/6_Constructors/2_Factories_A01_t01: Crash # inherited from dart2js
 Language/07_Classes/6_Constructors/2_Factories_A06_t05: Fail # inherited from VM
 Language/07_Classes/6_Constructors/2_Factories_A06_t06: Fail # inherited from VM
 Language/07_Classes/6_Constructors/2_Factories_A07_t01: Fail # inherited from VM
@@ -563,6 +562,8 @@
 
 Language/07_Classes/6_Constructors/1_Generative_Constructors_A16_t07: Fail # Redirecting constructors can not use initializing formals. This bug was previously masked - compilation failed, but for different, wrong reason.
 
+Language/07_Classes/6_Constructors/2_Factories_A01_t01: Fail, OK # Uses deprecated factory syntax.
+
 [ $compiler == dart2dart && $system == windows ]
 LibTest/core/double/operator_remainder_A01_t04: Fail # Result is NaN
 LibTest/core/double/round_A01_t01: Fail # Result is NaN
diff --git a/tests/co19/co19-dart2js.status b/tests/co19/co19-dart2js.status
index 5750632..bcb41de 100644
--- a/tests/co19/co19-dart2js.status
+++ b/tests/co19/co19-dart2js.status
@@ -6,8 +6,6 @@
 # Crashes first, please. Then untriaged bugs. There is a section below
 # for co19 bugs.
 [ $compiler == dart2js ]
-Language/07_Classes/6_Constructors/2_Factories_A01_t01: Crash # http://dartbug.com/5017
-
 Language/03_Overview/1_Scoping_A02_t06: Fail # TODO(ahe): Please triage this failure.
 Language/06_Functions/06_Functions_A01_t22: Fail # TODO(ahe): Please triage this failure.
 Language/07_Classes/07_Classes_A03_t01: Fail # TODO(ahe): Please triage this failure.
@@ -353,6 +351,8 @@
 LibTest/core/String/charCodeAt_A01_t01: Fail, OK # compiler cancelled: Unhandled non-BMP character: U+10000
 LibTest/core/String/charCodes_A01_t01: Fail, OK # compiler cancelled: Unhandled non-BMP character: U+10000
 
+Language/07_Classes/6_Constructors/2_Factories_A01_t01: Fail, OK # Uses deprecated factory syntax.
+
 Language/06_Functions/1_Function_Declaration_A02_t03: Fail, OK # co19 issue 210
 Language/06_Functions/1_Function_Declaration_A03_t03: Fail, OK # co19 issue 210
 Language/06_Functions/2_Formal_Parameters/2_Optional_Formals_A01_t14: Fail, OK # co19 issue 210
diff --git a/tests/compiler/dart2js/unparser_test.dart b/tests/compiler/dart2js/unparser_test.dart
index af53532..bb824b3 100644
--- a/tests/compiler/dart2js/unparser_test.dart
+++ b/tests/compiler/dart2js/unparser_test.dart
@@ -246,6 +246,7 @@
 testClassDeclarations() {
   testUnparseTopLevelWithMetadata('class Foo{}');
   testUnparseTopLevelWithMetadata('abstract class Foo{}');
+  testUnparseTopLevelWithMetadata('class Fisk{operator-(x){}}');
 }
 
 main() {
diff --git a/tests/language/function_type_parameter_test.dart b/tests/language/function_type_parameter_test.dart
index c839a03..3f23daf 100644
--- a/tests/language/function_type_parameter_test.dart
+++ b/tests/language/function_type_parameter_test.dart
@@ -6,6 +6,8 @@
 // default value.
 
 class A {
+  final f;
+  A(int this.f());
 
   static Function func;
 
@@ -22,4 +24,6 @@
   Expect.equals("1234", A.func(1230 + 4));
   A.SetFunc();
   Expect.equals(null, A.func);
+
+  Expect.equals(42, new A(() => 42).f());
 }
diff --git a/tests/language/language_dart2js.status b/tests/language/language_dart2js.status
index f17d87c..eed6019 100644
--- a/tests/language/language_dart2js.status
+++ b/tests/language/language_dart2js.status
@@ -86,7 +86,6 @@
 
 getter_declaration_negative_test: Fail # This will be fixed when dart2js reject old getter syntax.
 
-function_type_this_parameter_test: Crash # Issue 4417.
 compile_time_constant8_test: Fail # We don't take the generic type into account yet.
 canonical_const_test: Fail # We don't take the generic type into account yet.
 
diff --git a/tools/VERSION b/tools/VERSION
index 9ff3a0a..194bfe1 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -1,4 +1,4 @@
 MAJOR 0
 MINOR 1
-BUILD 5
-PATCH 1
+BUILD 6
+PATCH 0
diff --git a/tools/create_sdk.py b/tools/create_sdk.py
index b8e5e1e..237c696 100755
--- a/tools/create_sdk.py
+++ b/tools/create_sdk.py
@@ -103,12 +103,12 @@
   Copy(src, dest)
 
 
-def CopyDart2Js(build_dir, sdk_root, revision):
-  if revision:
+def CopyDart2Js(build_dir, sdk_root, version):
+  if version:
     ReplaceInFiles([os.path.join(sdk_root, 'pkg', 'compiler',
                                  'implementation', 'compiler.dart')],
                    [(r"BUILD_ID = 'build number could not be determined'",
-                     r"BUILD_ID = '%s'" % revision)])
+                     r"BUILD_ID = '%s'" % version)])
   if utils.GuessOS() == 'win32':
     dart2js = os.path.join(sdk_root, 'bin', 'dart2js.bat')
     Copy(os.path.join(build_dir, 'dart2js.bat'), dart2js)
@@ -318,15 +318,15 @@
          "var pathTo7zip = '7zip/7za.exe';"),
       ])
 
-  revision = utils.GetSVNRevision()
+  version = utils.GetVersion()
 
   # Copy dart2js.
-  CopyDart2Js(build_dir, SDK_tmp, revision)
+  CopyDart2Js(build_dir, SDK_tmp, version)
 
-  # Write the 'revision' file
-  if revision is not None:
-    with open(os.path.join(SDK_tmp, 'revision'), 'w') as f:
-      f.write(revision + '\n')
+  # Write the 'version' file
+  if version is not None:
+    with open(os.path.join(SDK_tmp, 'version'), 'w') as f:
+      f.write(version + '\n')
       f.close()
 
   Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README'))
diff --git a/tools/utils.py b/tools/utils.py
index 2ae3821..dee1c8a 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -152,6 +152,14 @@
 def GetBaseDir():
   return BASE_DIR
 
+def GetVersion():
+  dartbin = DartBinary()
+  version_script = VersionScript()
+  p = subprocess.Popen([dartbin, version_script], stdout = subprocess.PIPE,
+      stderr = subprocess.STDOUT, shell=IsWindows())
+  output, not_used = p.communicate()
+  return output.strip()
+
 def GetSVNRevision():
   p = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE,
       stderr = subprocess.STDOUT, shell=IsWindows())
@@ -297,6 +305,11 @@
     os.utime(name, None)
 
 
+def VersionScript():
+  tools_dir = os.path.dirname(os.path.realpath(__file__))
+  return os.path.join(tools_dir, 'version.dart')
+
+
 def DartBinary():
   tools_dir = os.path.dirname(os.path.realpath(__file__))
   dart_binary_prefix = os.path.join(tools_dir, 'testing', 'bin')