JavaScriptCore:

        Reviewed by Darin(first pass) and Hyatt.

        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=3576
        (roll in support for "const" keyword from KDE tree)
        - make processVarDecls handle deletability of variables declared
        in an eval block the same as evaluate would
        - make eval() call processVarDecls - needed to match mozilla and
        to make the second change testable

        I started with the KDE implementation of const but I ended up changing it a bit
        to avoid the use of a global variable. Now instead of the global variable it distinguishes
        const and var at the grammar level so the appropriate node can know the right kind of
        declaration.

        Test cases:
        * tests/mozilla/expected.html: Updated for one new test that is
        failing - we used to bail on it entirely because it checks for
        const support before starting.
        - see also test cases added in WebCore

        * kjs/grammar.y: Add rules for const declarations.
        * kjs/keywords.table: Add const keyword.
        * kjs/nodes.cpp:
        (VarDeclNode::VarDeclNode): Add parameter.
        (VarDeclNode::evaluate): Add const support.
        (VarDeclNode::processVarDecls): Add const support.
        (VarStatementNode::execute): Irrelevant change.
        (ForInNode::ForInNode): Tell our variable node that it's a variable.
        * kjs/nodes.h:
        (KJS::VarDeclNode::): Add declaration of type enum, extra constructor parameter.
        (KJS::VarStatementNode::VarStatementNode): Irrelevant change.
        * kjs/function.cpp:
        (KJS::GlobalFuncImp::call): Process var decls before evaluating.

WebCore:

        Reviewed by Darin(first pass) and Hyatt.

        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=3576
        (roll in support for "const" keyword from KDE tree)
        - make processVarDecls handle deletability of variables declared
        in an eval block the same as evaluate would
        - make eval() call processVarDecls - needed to match mozilla and
        to make the second change testable

	Test cases only, fix is in JavaScriptCore

        Test cases added:
        * layout-tests/fast/js/const-expected.txt: Added.
        * layout-tests/fast/js/const.html: Added.
        * layout-tests/fast/js/eval-var-decl-expected.txt: Added.
        * layout-tests/fast/js/eval-var-decl.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@9445 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index ace8586..4e8ebfe 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,5 +1,41 @@
 2005-06-20  Maciej Stachowiak  <mjs@apple.com>
 
+        Reviewed by Darin(first pass) and Hyatt.
+
+        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=3576
+        (roll in support for "const" keyword from KDE tree)
+        - make processVarDecls handle deletability of variables declared
+        in an eval block the same as evaluate would
+        - make eval() call processVarDecls - needed to match mozilla and
+        to make the second change testable
+
+        I started with the KDE implementation of const but I ended up changing it a bit
+        to avoid the use of a global variable. Now instead of the global variable it distinguishes
+        const and var at the grammar level so the appropriate node can know the right kind of
+        declaration.
+
+        Test cases:
+        * tests/mozilla/expected.html: Updated for one new test that is
+        failing - we used to bail on it entirely because it checks for
+        const support before starting.
+        - see also test cases added in WebCore
+
+        * kjs/grammar.y: Add rules for const declarations.
+        * kjs/keywords.table: Add const keyword.
+        * kjs/nodes.cpp:
+        (VarDeclNode::VarDeclNode): Add parameter.
+        (VarDeclNode::evaluate): Add const support.
+        (VarDeclNode::processVarDecls): Add const support.
+        (VarStatementNode::execute): Irrelevant change.
+        (ForInNode::ForInNode): Tell our variable node that it's a variable.
+        * kjs/nodes.h:
+        (KJS::VarDeclNode::): Add declaration of type enum, extra constructor parameter.
+        (KJS::VarStatementNode::VarStatementNode): Irrelevant change.
+        * kjs/function.cpp:
+        (KJS::GlobalFuncImp::call): Process var decls before evaluating.
+
+2005-06-20  Maciej Stachowiak  <mjs@apple.com>
+
         Patch from Mark Rowe <opendarwin.org@bdash.net.nz>, reviewed by me.
 
 	- fixed http://bugzilla.opendarwin.org/attachment.cgi?id=2483
diff --git a/JavaScriptCore/kjs/function.cpp b/JavaScriptCore/kjs/function.cpp
index 4cc57e9..30bbf82 100644
--- a/JavaScriptCore/kjs/function.cpp
+++ b/JavaScriptCore/kjs/function.cpp
@@ -659,6 +659,7 @@
       newExec.setException(exec->exception()); // could be null
 
       // execute the code
+      progNode->processVarDecls(&newExec);
       Completion c = progNode->execute(&newExec);
 
       // if an exception occured, propogate it back to the previous execution object
diff --git a/JavaScriptCore/kjs/grammar.y b/JavaScriptCore/kjs/grammar.y
index cf0dc17..5f584b3 100644
--- a/JavaScriptCore/kjs/grammar.y
+++ b/JavaScriptCore/kjs/grammar.y
@@ -92,7 +92,7 @@
 %token STRING NUMBER
 
 /* keywords */
-%token BREAK CASE DEFAULT FOR NEW VAR CONTINUE
+%token BREAK CASE DEFAULT FOR NEW VAR CONST CONTINUE
 %token FUNCTION RETURN VOID DELETE
 %token IF THIS DO WHILE ELSE IN INSTANCEOF TYPEOF
 %token SWITCH WITH RESERVED
@@ -136,7 +136,7 @@
 %type <fnode> Finally
 
 %type <stat>  Statement Block
-%type <stat>  VariableStatement EmptyStatement ExprStatement
+%type <stat>  VariableStatement ConstStatement EmptyStatement ExprStatement
 %type <stat>  IfStatement IterationStatement ContinueStatement
 %type <stat>  BreakStatement ReturnStatement WithStatement
 %type <stat>  SwitchStatement LabelledStatement
@@ -153,8 +153,8 @@
 %type <prog>  Program
 %type <args>  Arguments
 %type <alist> ArgumentList
-%type <vlist> VariableDeclarationList
-%type <decl>  VariableDeclaration
+%type <vlist> VariableDeclarationList ConstDeclarationList
+%type <decl>  VariableDeclaration ConstDeclaration
 %type <cblk>  CaseBlock
 %type <ccl>   CaseClause DefaultClause
 %type <clist> CaseClauses  CaseClausesOpt
@@ -386,6 +386,7 @@
 Statement:
     Block
   | VariableStatement
+  | ConstStatement
   | EmptyStatement
   | ExprStatement
   | IfStatement
@@ -429,8 +430,31 @@
 ;
 
 VariableDeclaration:
-    IDENT                          { $$ = new VarDeclNode(*$1, 0); }
-  | IDENT Initializer              { $$ = new VarDeclNode(*$1, $2); }
+    IDENT                          { $$ = new VarDeclNode(*$1, 0, VarDeclNode::Variable); }
+  | IDENT Initializer              { $$ = new VarDeclNode(*$1, $2, VarDeclNode::Variable); }
+;
+
+ConstStatement:
+    CONST ConstDeclarationList ';' { $$ = new VarStatementNode($2);
+                                      DBG($$, @1, @3); }
+  | CONST ConstDeclarationList error { if (automatic()) {
+                                          $$ = new VarStatementNode($2);
+					  DBG($$, @1, @2);
+                                        } else {
+					  YYABORT;
+					}
+                                      }
+;
+
+ConstDeclarationList:
+    ConstDeclaration            { $$ = new VarDeclListNode($1); }
+  | ConstDeclarationList ',' VariableDeclaration
+                                   { $$ = new VarDeclListNode($1, $3); }
+;
+
+ConstDeclaration:
+    IDENT                          { $$ = new VarDeclNode(*$1, 0, VarDeclNode::Constant); }
+  | IDENT Initializer              { $$ = new VarDeclNode(*$1, $2, VarDeclNode::Constant); }
 ;
 
 Initializer:
diff --git a/JavaScriptCore/kjs/keywords.table b/JavaScriptCore/kjs/keywords.table
index 391aa34..85dcaa0 100644
--- a/JavaScriptCore/kjs/keywords.table
+++ b/JavaScriptCore/kjs/keywords.table
@@ -8,6 +8,7 @@
 break		BREAK
 case		CASE
 catch		CATCH
+const		CONST
 default		DEFAULT
 finally		FINALLY
 for		FOR
@@ -36,7 +37,6 @@
 byte		RESERVED
 char		RESERVED
 class		RESERVED
-const		RESERVED
 debugger	RESERVED
 double		RESERVED
 enum		RESERVED
diff --git a/JavaScriptCore/kjs/nodes.cpp b/JavaScriptCore/kjs/nodes.cpp
index e3b952b..76ad4d8 100644
--- a/JavaScriptCore/kjs/nodes.cpp
+++ b/JavaScriptCore/kjs/nodes.cpp
@@ -1587,8 +1587,9 @@
 
 // ------------------------------ VarDeclNode ----------------------------------
 
-VarDeclNode::VarDeclNode(const Identifier &id, AssignExprNode *in)
-    : ident(id), init(in)
+    
+VarDeclNode::VarDeclNode(const Identifier &id, AssignExprNode *in, Type t)
+    : varType(t), ident(id), init(in)
 {
 }
 
@@ -1628,12 +1629,13 @@
 #endif
   // We use Internal to bypass all checks in derived objects, e.g. so that
   // "var location" creates a dynamic property instead of activating window.location.
-  if (exec->context().imp()->codeType() == EvalCode) {
-      // ECMA 10.2.2
-      variable.put(exec, ident, val, Internal); 
-  } else {
-      variable.put(exec, ident, val, DontDelete | Internal);
-  }
+  int flags = Internal;
+  if (exec->context().imp()->codeType() != EvalCode)
+    flags |= DontDelete;
+  if (varType == VarDeclNode::Constant)
+    flags |= ReadOnly;
+  variable.put(exec, ident, val, flags);
+
   return ident.ustring();
 }
 
@@ -1644,7 +1646,12 @@
   // If a variable by this name already exists, don't clobber it -
   // it might be a function parameter
   if (!variable.hasProperty(exec, ident)) {
-    variable.put(exec,ident, Undefined(), DontDelete);
+    int flags = Internal;
+    if (exec->context().imp()->codeType() != EvalCode)
+      flags |= DontDelete;
+    if (varType == VarDeclNode::Constant)
+      flags |= ReadOnly;
+    variable.put(exec, ident, Undefined(), flags);
   }
 }
 
@@ -1710,7 +1717,7 @@
 {
   KJS_BREAKPOINT;
 
-  (void) list->evaluate(exec); // returns 0L
+  (void) list->evaluate(exec);
   KJS_CHECKEXCEPTION
 
   return Completion(Normal);
@@ -2050,7 +2057,7 @@
   : ident(i), init(in), expr(e), statement(s)
 {
   // for( var foo = bar in baz )
-  varDecl = new VarDeclNode(ident, init);
+  varDecl = new VarDeclNode(ident, init, VarDeclNode::Variable);
   lexpr = new ResolveNode(ident);
 }
 
diff --git a/JavaScriptCore/kjs/nodes.h b/JavaScriptCore/kjs/nodes.h
index e8d0806..6ebe8f7 100644
--- a/JavaScriptCore/kjs/nodes.h
+++ b/JavaScriptCore/kjs/nodes.h
@@ -633,13 +633,15 @@
 
   class VarDeclNode : public Node {
   public:
-    VarDeclNode(const Identifier &id, AssignExprNode *in);
+    enum Type { Variable, Constant };
+    VarDeclNode(const Identifier &id, AssignExprNode *in, Type t);
     virtual void ref();
     virtual bool deref();
     Value evaluate(ExecState *exec);
     virtual void processVarDecls(ExecState *exec);
     virtual void streamTo(SourceStream &s) const;
   private:
+    Type varType;
     Identifier ident;
     AssignExprNode *init;
   };
@@ -664,8 +666,7 @@
 
   class VarStatementNode : public StatementNode {
   public:
-    VarStatementNode(VarDeclListNode *l)
-      : list(l->list) { l->list = 0; }
+    VarStatementNode(VarDeclListNode *l) : list(l->list) { l->list = 0; }
     virtual void ref();
     virtual bool deref();
     virtual Completion execute(ExecState *exec);
diff --git a/JavaScriptCore/tests/mozilla/expected.html b/JavaScriptCore/tests/mozilla/expected.html
index 4dbaeba..a3f0a4e 100644
--- a/JavaScriptCore/tests/mozilla/expected.html
+++ b/JavaScriptCore/tests/mozilla/expected.html
@@ -7,11 +7,11 @@
 <p class='results_summary'>
 Test List: All tests<br>
 Skip List: ecma/Date<br>
-967 test(s) selected, 962 test(s) completed, 125 failures reported (12.99% failed)<br>
+967 test(s) selected, 962 test(s) completed, 126 failures reported (13.09% failed)<br>
 Engine command line: /Users/mjs/Work/symroots/testkjs <br>
-OS type: Darwin maciej-stachowiaks-powerbook-g4-17.local 8.0.0 Darwin Kernel Version 8.0.0: Sat Mar 26 14:15:22 PST 2005; root:xnu-792.obj~1/RELEASE_PPC Power Macintosh powerpc<br>
-Testcase execution time: 2 minutes, 25 seconds.<br>
-Tests completed on Mon Jun 20 01:31:55 2005.<br><br>
+OS type: Darwin il0204a-dhcp15.apple.com 8.0.0 Darwin Kernel Version 8.0.0: Sat Mar 26 14:15:22 PST 2005; root:xnu-792.obj~1/RELEASE_PPC Power Macintosh powerpc<br>
+Testcase execution time: 2 minutes, 29 seconds.<br>
+Tests completed on Mon Jun 20 18:33:32 2005.<br><br>
 [ <a href='#fail_detail'>Failure Details</a> | <a href='#retest_list'>Retest List</a> | <a href='menu.html'>Test Selection Page</a> ]<br>
 <hr>
 <a name='fail_detail'></a>
@@ -192,8 +192,8 @@
 --> (Mon Feb 28 2000 16:00:00 GMT-0800).toLocaleTimeString() = 4:00:00 PM PST FAILED! expected: 16:00:00<br>
 --> (Mon Feb 28 2000 15:59:59 GMT-0800).toLocaleTimeString() = 3:59:59 PM PST FAILED! expected: 15:59:59<br>
 --> (Tue Feb 29 2000 00:00:00 GMT-0800).toLocaleTimeString() = 12:00:00 AM PST FAILED! expected: 00:00:00<br>
---> (Mon Jun 20 2005 01:31:11 GMT-0700).toLocaleTimeString() = 1:31:11 AM PDT FAILED! expected: 01:31:11<br>
---> (Mon Jun 20 2005 09:31:11 GMT-0700).toLocaleTimeString() = 9:31:11 AM PDT FAILED! expected: 09:31:11<br>
+--> (Mon Jun 20 2005 18:32:42 GMT-0700).toLocaleTimeString() = 6:32:42 PM PDT FAILED! expected: 18:32:42<br>
+--> (Tue Jun 21 2005 02:32:42 GMT-0700).toLocaleTimeString() = 2:32:42 AM PDT FAILED! expected: 02:32:42<br>
 --> (Fri Dec 31 2004 16:00:00 GMT-0800).toLocaleTimeString() = 4:00:00 PM PST FAILED! expected: 16:00:00<br>
 --> (Fri Dec 31 2004 15:59:59 GMT-0800).toLocaleTimeString() = 3:59:59 PM PST FAILED! expected: 15:59:59<br>
 --> (Sat Jan 01 2005 00:00:00 GMT-0800).toLocaleTimeString() = 12:00:00 AM PST FAILED! expected: 00:00:00<br>
@@ -1670,29 +1670,40 @@
 Complete testcase output was:<br>
 Exception, line 50: TypeError - Object  (result of expression uneval) does not allow calls.<br>
 </tt><br>
-<a name='failure113'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-104077.js'>js1_5/Regress/regress-104077.js</a> failed</b> <br>
+<a name='failure113'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-103602.js'>js1_5/Regress/regress-103602.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=103602' target='other_window'>Bug Number 103602</a><br>
  [ <a href='#failure112'>Previous Failure</a> | <a href='#failure114'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<tt>--> STATUS: Reassignment to a const is NOT an error per ECMA<br>
+Failure messages were:<br>
+--> FAILED!: [reported from test()] Section 1 of test -<br>
+--> FAILED!: [reported from test()] Expected value '', Actual value 'Redeclaration of a const FAILED to cause an error'<br>
+--> FAILED!: [reported from test()] <br>
+--> FAILED!: [reported from test()] Section 3 of test -<br>
+--> FAILED!: [reported from test()] Expected value '1', Actual value '2'<br>
+--> FAILED!: [reported from test()] <br>
+</tt><br>
+<a name='failure114'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-104077.js'>js1_5/Regress/regress-104077.js</a> failed</b> <br>
+ [ <a href='#failure113'>Previous Failure</a> | <a href='#failure115'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
 <tt>Expected exit code 0, got 3<br>
 Testcase terminated with signal 0<br>
 Complete testcase output was:<br>
 Exception, line 351: SyntaxError - Parse error<br>
 </tt><br>
-<a name='failure114'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-127557.js'>js1_5/Regress/regress-127557.js</a> failed</b> <br>
- [ <a href='#failure113'>Previous Failure</a> | <a href='#failure115'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<a name='failure115'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-127557.js'>js1_5/Regress/regress-127557.js</a> failed</b> <br>
+ [ <a href='#failure114'>Previous Failure</a> | <a href='#failure116'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
 <tt>Expected exit code 0, got 3<br>
 Testcase terminated with signal 0<br>
 Complete testcase output was:<br>
 Exception, line 76: TypeError - Object  (result of expression clone) does not allow calls.<br>
 </tt><br>
-<a name='failure115'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-156354.js'>js1_5/Regress/regress-156354.js</a> failed</b> <br>
- [ <a href='#failure114'>Previous Failure</a> | <a href='#failure116'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<a name='failure116'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-156354.js'>js1_5/Regress/regress-156354.js</a> failed</b> <br>
+ [ <a href='#failure115'>Previous Failure</a> | <a href='#failure117'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
 <tt>Expected exit code 0, got 3<br>
 Testcase terminated with signal 0<br>
 Complete testcase output was:<br>
 Exception, line 56: TypeError - Value undefined (result of expression this.propertyIsEnumerable) is not object.<br>
 </tt><br>
-<a name='failure116'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-168347.js'>js1_5/Regress/regress-168347.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=168347' target='other_window'>Bug Number 168347</a><br>
- [ <a href='#failure115'>Previous Failure</a> | <a href='#failure117'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<a name='failure117'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-168347.js'>js1_5/Regress/regress-168347.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=168347' target='other_window'>Bug Number 168347</a><br>
+ [ <a href='#failure116'>Previous Failure</a> | <a href='#failure118'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
 <tt>--> STATUS: Testing F.toString()<br>
 Failure messages were:<br>
 --> FAILED!: [reported from test()] Section 2 of test -<br>
@@ -1702,15 +1713,15 @@
 --> FAILED!: [reported from test()] Expected value '{--f.i;print("--isucceededi="+f.i);}catch(e){print("--ifailedwith"+e+"i="+f.i);}try{f.i--;print("i--', Actual value '{f.i--;print("--isucceededi="+f.i);}catch(e){print("--ifailedwith"+e+"i="+f.i);}try{f.i--;print("i--'<br>
 --> FAILED!: [reported from test()] <br>
 </tt><br>
-<a name='failure117'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-172699.js'>js1_5/Regress/regress-172699.js</a> failed</b> <br>
- [ <a href='#failure116'>Previous Failure</a> | <a href='#failure118'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<a name='failure118'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-172699.js'>js1_5/Regress/regress-172699.js</a> failed</b> <br>
+ [ <a href='#failure117'>Previous Failure</a> | <a href='#failure119'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
 <tt>Expected exit code 0, got 3<br>
 Testcase terminated with signal 0<br>
 Complete testcase output was:<br>
 Exception, line 62: URIError - URI error<br>
 </tt><br>
-<a name='failure118'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-179524.js'>js1_5/Regress/regress-179524.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=179524' target='other_window'>Bug Number 179524</a><br>
- [ <a href='#failure117'>Previous Failure</a> | <a href='#failure119'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<a name='failure119'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-179524.js'>js1_5/Regress/regress-179524.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=179524' target='other_window'>Bug Number 179524</a><br>
+ [ <a href='#failure118'>Previous Failure</a> | <a href='#failure120'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
 <tt>--> STATUS: Don't crash on extraneous arguments to str.match(), etc.<br>
 Failure messages were:<br>
 --> FAILED!: [reported from test()] Section 14 of test -<br>
@@ -1760,16 +1771,16 @@
 --> FAILED!: [reported from test()] Expected value 'SHOULD HAVE FALLEN INTO CATCH-BLOCK!', Actual value 'ABC Zbc'<br>
 --> FAILED!: [reported from test()] <br>
 </tt><br>
-<a name='failure119'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-185165.js'>js1_5/Regress/regress-185165.js</a> failed</b> <br>
- [ <a href='#failure118'>Previous Failure</a> | <a href='#failure120'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<a name='failure120'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-185165.js'>js1_5/Regress/regress-185165.js</a> failed</b> <br>
+ [ <a href='#failure119'>Previous Failure</a> | <a href='#failure121'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
 <tt>Expected exit code 0, got 3<br>
 Testcase terminated with signal 0<br>
 Complete testcase output was:<br>
 yylex: ERROR.<br>
 Exception, line 3: SyntaxError - Parse error<br>
 </tt><br>
-<a name='failure120'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-44009.js'>js1_5/Regress/regress-44009.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=44009' target='other_window'>Bug Number 44009</a><br>
- [ <a href='#failure119'>Previous Failure</a> | <a href='#failure121'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<a name='failure121'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-44009.js'>js1_5/Regress/regress-44009.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=44009' target='other_window'>Bug Number 44009</a><br>
+ [ <a href='#failure120'>Previous Failure</a> | <a href='#failure122'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
 <tt>Expected exit code 0, got 3<br>
 Testcase terminated with signal 0<br>
 Complete testcase output was:<br>
@@ -1777,8 +1788,8 @@
 --> STATUS: Testing that we don't crash on obj.toSource()<br>
 Exception, line 61: TypeError - Value undefined (result of expression obj.toSource) is not object.<br>
 </tt><br>
-<a name='failure121'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-68498-003.js'>js1_5/Regress/regress-68498-003.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=68498' target='other_window'>Bug Number 68498</a><br>
- [ <a href='#failure120'>Previous Failure</a> | <a href='#failure122'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<a name='failure122'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-68498-003.js'>js1_5/Regress/regress-68498-003.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=68498' target='other_window'>Bug Number 68498</a><br>
+ [ <a href='#failure121'>Previous Failure</a> | <a href='#failure123'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
 <tt>--> STATUS: Testing calling obj.eval(str)<br>
 Failure messages were:<br>
 --> FAILED!: [reported from test()] Testing calling obj.eval(str); currently at expect[1] within test -<br>
@@ -1786,16 +1797,16 @@
 --> FAILED!: [reported from test()] Expected value '43', Actual value 'false'<br>
 --> FAILED!: [reported from test()] <br>
 </tt><br>
-<a name='failure122'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-96128-n.js'>js1_5/Regress/regress-96128-n.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=96128' target='other_window'>Bug Number 96128</a><br>
- [ <a href='#failure121'>Previous Failure</a> | <a href='#failure123'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<a name='failure123'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Regress/regress-96128-n.js'>js1_5/Regress/regress-96128-n.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=96128' target='other_window'>Bug Number 96128</a><br>
+ [ <a href='#failure122'>Previous Failure</a> | <a href='#failure124'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
 <tt>Expected exit code 3, got 0<br>
 Testcase terminated with signal 11<br>
 Complete testcase output was:<br>
 --> BUGNUMBER: 96128<br>
 --> STATUS: Testing that JS infinite recursion protection works<br>
 </tt><br>
-<a name='failure123'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Scope/regress-185485.js'>js1_5/Scope/regress-185485.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=185485' target='other_window'>Bug Number 185485</a><br>
- [ <a href='#failure122'>Previous Failure</a> | <a href='#failure124'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<a name='failure124'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Scope/regress-185485.js'>js1_5/Scope/regress-185485.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=185485' target='other_window'>Bug Number 185485</a><br>
+ [ <a href='#failure123'>Previous Failure</a> | <a href='#failure125'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
 <tt>--> STATUS: Testing |with (x) {function f() {}}| when |x.f| already exists<br>
 Failure messages were:<br>
 --> FAILED!: [reported from test()] Section 2 of test -<br>
@@ -1810,19 +1821,24 @@
 --> FAILED!: [reported from test()] }', Actual value '0'<br>
 --> FAILED!: [reported from test()] <br>
 </tt><br>
-<a name='failure124'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Scope/regress-220584.js'>js1_5/Scope/regress-220584.js</a> failed</b> <br>
- [ <a href='#failure123'>Previous Failure</a> | <a href='#failure125'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<a name='failure125'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Scope/regress-220584.js'>js1_5/Scope/regress-220584.js</a> failed</b> <br>
+ [ <a href='#failure124'>Previous Failure</a> | <a href='#failure126'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
 <tt>Expected exit code 0, got 3<br>
 Testcase terminated with signal 0<br>
 Complete testcase output was:<br>
 Exception, line 57: TypeError - Object  (result of expression Script) does not allow calls.<br>
 </tt><br>
-<a name='failure125'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Scope/scope-001.js'>js1_5/Scope/scope-001.js</a> failed</b> <br>
- [ <a href='#failure124'>Previous Failure</a> | <a href='#failure126'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
-<tt>Expected exit code 0, got 3<br>
-Testcase terminated with signal 0<br>
-Complete testcase output was:<br>
-Exception, line 40: SyntaxError - Parse error<br>
+<a name='failure126'></a><dd><b>Testcase <a target='other_window' href='./js1_5/Scope/scope-001.js'>js1_5/Scope/scope-001.js</a> failed</b> <a href='http://bugzilla.mozilla.org/show_bug.cgi?id=53268' target='other_window'>Bug Number 53268</a><br>
+ [ <a href='#failure125'>Previous Failure</a> | <a href='#failure127'>Next Failure</a> | <a href='#tippy_top'>Top of Page</a> ]<br>
+<tt>--> STATUS: Testing scope after changing obj.__proto__<br>
+Failure messages were:<br>
+--> FAILED!: [reported from test()] Step 1:  setting obj.__proto__ = global object<br>
+--> FAILED!: [reported from test()] Expected value '5', Actual value '1'<br>
+--> FAILED!: [reported from test()] <br>
+--> FAILED!: [reported from test()] Step 2:  setting obj.__proto__ = null<br>
+--> FAILED!: [reported from test()] Type mismatch, expected type undefined, actual type number<br>
+--> FAILED!: [reported from test()] Expected value 'undefined', Actual value '1'<br>
+--> FAILED!: [reported from test()] <br>
 </tt><br>
 </dl>
 [ <a href='#tippy_top'>Top of Page</a> | <a href='#fail_detail'>Top of Failures</a> ]<br>
@@ -1830,9 +1846,9 @@
 <pre>
 <a name='retest_list'></a>
 <h2>Retest List</h2><br>
-# Retest List, kjs, generated Mon Jun 20 01:31:55 2005.
+# Retest List, kjs, generated Mon Jun 20 18:33:32 2005.
 # Original test base was: All tests.
-# 962 of 967 test(s) were completed, 125 failures reported.
+# 962 of 967 test(s) were completed, 126 failures reported.
 ecma/GlobalObject/15.1.2.2-2.js
 ecma/LexicalConventions/7.7.3-1.js
 ecma/Statements/12.7-1-n.js
@@ -1945,6 +1961,7 @@
 js1_5/Object/regress-90596-002.js
 js1_5/Object/regress-96284-001.js
 js1_5/Object/regress-96284-002.js
+js1_5/Regress/regress-103602.js
 js1_5/Regress/regress-104077.js
 js1_5/Regress/regress-127557.js
 js1_5/Regress/regress-156354.js
diff --git a/LayoutTests/fast/js/const-expected.txt b/LayoutTests/fast/js/const-expected.txt
new file mode 100644
index 0000000..e4fb781
--- /dev/null
+++ b/LayoutTests/fast/js/const-expected.txt
@@ -0,0 +1,3 @@
+This test checks that const declarations in JavaScript work and are readonly. The text below should say RIGHT.
+
+RIGHT
diff --git a/LayoutTests/fast/js/const.html b/LayoutTests/fast/js/const.html
new file mode 100644
index 0000000..371f0c1
--- /dev/null
+++ b/LayoutTests/fast/js/const.html
@@ -0,0 +1,19 @@
+<div>
+This test checks that const declarations in JavaScript work and are readonly. The text below should say RIGHT.
+</div>
+<br>
+<div>
+<script>
+if (window.layoutTestController) {
+   layoutTestController.dumpAsText();
+}
+
+try {
+    const x = "RIGHT";
+    x = "WRONG";
+    document.write(x);
+} catch (exc) {
+   document.write("EXCEPTION");
+}
+</script>
+</div>
\ No newline at end of file
diff --git a/LayoutTests/fast/js/eval-var-decl-expected.txt b/LayoutTests/fast/js/eval-var-decl-expected.txt
new file mode 100644
index 0000000..f960de9
--- /dev/null
+++ b/LayoutTests/fast/js/eval-var-decl-expected.txt
@@ -0,0 +1,7 @@
+This test case checks whether variables cause properties to be defined even before reaching the declaration statement in various cases. It should print true true true false on separate lines.
+
+true
+true
+true
+false
+
diff --git a/LayoutTests/fast/js/eval-var-decl.html b/LayoutTests/fast/js/eval-var-decl.html
new file mode 100644
index 0000000..a2a57e0
--- /dev/null
+++ b/LayoutTests/fast/js/eval-var-decl.html
@@ -0,0 +1,24 @@
+<div> 
+This test case checks whether variables cause properties to be
+defined even before reaching the declaration statement in various
+cases. It should print true true true false on separate lines.
+</div>
+<br>
+<div>
+<script>
+if (window.layoutTestController) {
+   layoutTestController.dumpAsText();
+}
+
+document.write(window.hasOwnProperty('foo') + '<br>');
+var foo = 3;
+
+delete bar;
+document.write(window.hasOwnProperty('bar') + '<br>');
+var bar = 3;
+
+eval("document.write(window.hasOwnProperty('y') + '<br>'); var y = 3;");
+eval("delete x; document.write(window.hasOwnProperty('x') + '<br>'); var x = 3;");
+
+</script>
+</div>
\ No newline at end of file
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 61de7b9..130ab31 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,24 @@
 2005-06-20  Maciej Stachowiak  <mjs@apple.com>
 
+        Reviewed by Darin(first pass) and Hyatt.
+
+        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=3576
+        (roll in support for "const" keyword from KDE tree)
+        - make processVarDecls handle deletability of variables declared
+        in an eval block the same as evaluate would
+        - make eval() call processVarDecls - needed to match mozilla and
+        to make the second change testable
+
+	Test cases only, fix is in JavaScriptCore
+	
+        Test cases added:
+        * layout-tests/fast/js/const-expected.txt: Added.
+        * layout-tests/fast/js/const.html: Added.
+        * layout-tests/fast/js/eval-var-decl-expected.txt: Added.
+        * layout-tests/fast/js/eval-var-decl.html: Added.
+
+2005-06-20  Maciej Stachowiak  <mjs@apple.com>
+
         Patch from Mark Rowe <opendarwin.org@bdash.net.nz>, reviewed by me.
 
 	- fixed http://bugzilla.opendarwin.org/attachment.cgi?id=2483