2008-06-13 Cameron Zwarich <cwzwarich@uwaterloo.ca>
authorcwzwarich@webkit.org <cwzwarich@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Jun 2008 05:06:21 +0000 (05:06 +0000)
committercwzwarich@webkit.org <cwzwarich@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Jun 2008 05:06:21 +0000 (05:06 +0000)
        Reviewed by Maciej.

        Combine TrueNode and FalseNode to make BooleanNode, and remove the
        unused class PlaceholderTrueNode.

        * kjs/grammar.y:
        * kjs/nodes.cpp:
        (KJS::BooleanNode::emitCode):
        * kjs/nodes.h:
        (KJS::BooleanNode::):
        (KJS::BooleanNode::precedence):
        * kjs/nodes2string.cpp:
        (KJS::BooleanNode::streamTo):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@34529 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/grammar.y
JavaScriptCore/kjs/nodes.cpp
JavaScriptCore/kjs/nodes.h
JavaScriptCore/kjs/nodes2string.cpp

index 82dd5774657eb8fcc3c6fa7f441d67f02d705487..f861b2276420a75d65f4f02972370ea052c6fbcf 100644 (file)
@@ -1,3 +1,19 @@
+2008-06-13  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
+
+        Reviewed by Maciej.
+
+        Combine TrueNode and FalseNode to make BooleanNode, and remove the
+        unused class PlaceholderTrueNode.
+
+        * kjs/grammar.y:
+        * kjs/nodes.cpp:
+        (KJS::BooleanNode::emitCode):
+        * kjs/nodes.h:
+        (KJS::BooleanNode::):
+        (KJS::BooleanNode::precedence):
+        * kjs/nodes2string.cpp:
+        (KJS::BooleanNode::streamTo):
+
 2008-06-13  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
 
         Reviewed by Maciej.
index 473b05a1f5d5a363e18e619f9b5bfd0bd28dab13..0020d6a85e6a175edcbf5a119b26101fc02a87cd 100644 (file)
@@ -282,8 +282,8 @@ static inline void appendToVarDeclarationList(ParserRefCountedData<DeclarationSt
 
 Literal:
     NULLTOKEN                           { $$ = createNodeFeatureInfo<ExpressionNode*>(new NullNode, 0); }
-  | TRUETOKEN                           { $$ = createNodeFeatureInfo<ExpressionNode*>(new TrueNode, 0); }
-  | FALSETOKEN                          { $$ = createNodeFeatureInfo<ExpressionNode*>(new FalseNode, 0); }
+  | TRUETOKEN                           { $$ = createNodeFeatureInfo<ExpressionNode*>(new BooleanNode(true), 0); }
+  | FALSETOKEN                          { $$ = createNodeFeatureInfo<ExpressionNode*>(new BooleanNode(false), 0); }
   | NUMBER                              { $$ = createNodeFeatureInfo<ExpressionNode*>(makeNumberNode($1), 0); }
   | STRING                              { $$ = createNodeFeatureInfo<ExpressionNode*>(new StringNode($1), 0); }
   | '/' /* regexp */                    {
index a9a3ae6bd4a80b4af125b4363930aa68992ae62d..585d8d5ba28a77abf23db9524452f479c191b467 100644 (file)
@@ -287,18 +287,11 @@ RegisterID* NullNode::emitCode(CodeGenerator& generator, RegisterID* dst)
     return generator.emitLoad(generator.finalDestination(dst), jsNull());
 }
 
-// ------------------------------ FalseNode ----------------------------------
+// ------------------------------ BooleanNode ----------------------------------
 
-RegisterID* FalseNode::emitCode(CodeGenerator& generator, RegisterID* dst)
+RegisterID* BooleanNode::emitCode(CodeGenerator& generator, RegisterID* dst)
 {
-    return generator.emitLoad(generator.finalDestination(dst), false);
-}
-
-// ------------------------------ TrueNode ----------------------------------
-
-RegisterID* TrueNode::emitCode(CodeGenerator& generator, RegisterID* dst)
-{
-    return generator.emitLoad(generator.finalDestination(dst), true);
+    return generator.emitLoad(generator.finalDestination(dst), m_value);
 }
 
 // ------------------------------ NumberNode -----------------------------------
index cf2b4ec0f189895964a5c30543c2374ef03ba075..27a63a2d17f1cd08e97a2714cec707384f650ed0 100644 (file)
@@ -251,10 +251,11 @@ namespace KJS {
         virtual Precedence precedence() const { return PrecPrimary; }
     };
 
-    class FalseNode : public ExpressionNode {
+    class BooleanNode : public ExpressionNode {
     public:
-        FalseNode() KJS_FAST_CALL
+        BooleanNode(bool value) KJS_FAST_CALL
             : ExpressionNode(BooleanType)
+            , m_value(value)
         {
         }
 
@@ -263,31 +264,9 @@ namespace KJS {
         virtual bool isConstant() const KJS_FAST_CALL { return true; }
         virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
         virtual Precedence precedence() const { return PrecPrimary; }
-    };
-
-    class TrueNode : public ExpressionNode {
-    public:
-        TrueNode() KJS_FAST_CALL
-            : ExpressionNode(BooleanType)
-        {
-        }
-
-        virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
 
-        virtual bool isConstant() const KJS_FAST_CALL { return true; }
-        virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
-        virtual Precedence precedence() const { return PrecPrimary; }
-    };
-
-    class PlaceholderTrueNode : public TrueNode {
-    public:
-        // Like TrueNode, but does not serialize as "true".
-        PlaceholderTrueNode() KJS_FAST_CALL
-            : TrueNode()
-        {
-        }
-
-        virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
+    protected:
+        bool m_value;
     };
 
     class NumberNode : public ExpressionNode {
index 1b815e1dfbcaf0a06acc7b4d203e70596a055f8a..59b6dea031e6bb018c8df24df888f6430dbfb49e 100644 (file)
@@ -297,18 +297,9 @@ void NullNode::streamTo(SourceStream& s) const
     s << "null";
 }
 
-void FalseNode::streamTo(SourceStream& s) const
-{
-    s << "false";
-}
-
-void TrueNode::streamTo(SourceStream& s) const
-{
-    s << "true";
-}
-
-void PlaceholderTrueNode::streamTo(SourceStream&) const
+void BooleanNode::streamTo(SourceStream& s) const
 {
+    s << (m_value ? "true" : "false");
 }
 
 void NumberNode::streamTo(SourceStream& s) const