Browse Source

throw asm.js error when trying to use lambdas

Michael Holman 8 years ago
parent
commit
e40de2ede8
3 changed files with 17 additions and 3 deletions
  1. 13 0
      lib/Parser/Parse.cpp
  2. 0 3
      lib/Runtime/Language/RuntimeLanguagePch.h
  3. 4 0
      lib/Runtime/Runtime.h

+ 13 - 0
lib/Parser/Parse.cpp

@@ -399,6 +399,10 @@ HRESULT Parser::ParseSourceInternal(
     {
         hr = e.GetError();
     }
+    catch (Js::AsmJsParseException&)
+    {
+        hr = JSERR_AsmJsCompileError;
+    }
 
     if (FAILED(hr))
     {
@@ -5244,6 +5248,15 @@ bool Parser::ParseFncDeclHelper(ParseNodePtr pnodeFnc, LPCOLESTR pNameHint, usho
 
         if (isTopLevelDeferredFunc || (m_InAsmMode && m_deferAsmJs))
         {
+#ifdef ASMJS_PLAT
+            if (m_InAsmMode && fLambda)
+            {
+                // asm.js doesn't support lambda functions
+                Js::AsmJSCompiler::OutputError(m_scriptContext, _u("Lambda functions are not supported."));
+                Js::AsmJSCompiler::OutputError(m_scriptContext, _u("Asm.js compilation failed."));
+                throw Js::AsmJsParseException();
+            }
+#endif
             AssertMsg(!fLambda, "Deferring function parsing of a function does not handle lambda syntax");
             fDeferred = true;
 

+ 0 - 3
lib/Runtime/Language/RuntimeLanguagePch.h

@@ -9,11 +9,8 @@
 
 #include "Runtime.h"
 
-#include "Language/AsmJsTypes.h"
 #include "Language/AsmJsUtils.h"
 #include "Language/AsmJsLink.h"
-#include "Language/AsmJsModule.h"
-#include "Language/AsmJs.h"
 #ifdef ASMJS_PLAT
 #include "Language/AsmJsJitTemplate.h"
 #include "Language/AsmJsEncoder.h"

+ 4 - 0
lib/Runtime/Runtime.h

@@ -547,6 +547,10 @@ enum tagDEBUG_EVENT_INFO_TYPE
 
 #include "../WasmReader/WasmReader.h"
 
+#include "Language/AsmJsTypes.h"
+#include "Language/AsmJsModule.h"
+#include "Language/AsmJs.h"
+
 //
 // .inl files
 //