[phc-internals] [phc commit] r1199 - in trunk/src: generated generated_src

codesite-noreply at google.com codesite-noreply at google.com
Wed Apr 30 13:58:14 IST 2008


Author: paul.biggar
Date: Wed Apr 30 05:56:57 2008
New Revision: 1199

Modified:
   trunk/src/generated/AST-contexts
   trunk/src/generated/AST.cpp
   trunk/src/generated/AST.h
   trunk/src/generated/AST_factory.cpp
   trunk/src/generated_src/ast.tea

Log:
A Cast no longer needs to be specified with CAST<String*>. The String* 
is implicit, and is left-over from the days of source_rep.


Modified: trunk/src/generated/AST-contexts
==============================================================================
--- trunk/src/generated/AST-contexts	(original)
+++ trunk/src/generated/AST-contexts	Wed Apr 30 05:56:57 2008
@@ -67,7 +67,7 @@
 (Variable_name,Variable_name,)
 (While,Statement,*)
 (BOOL<bool>,Expr,)
-(CAST<String*>,CAST<String*>,)
+(CAST,CAST,)
 (CLASS_NAME,CLASS_NAME,)
 (CONSTANT_NAME,CONSTANT_NAME,)
 (DIRECTIVE_NAME,DIRECTIVE_NAME,)

Modified: trunk/src/generated/AST.cpp
==============================================================================
--- trunk/src/generated/AST.cpp	(original)
+++ trunk/src/generated/AST.cpp	Wed Apr 30 05:56:57 2008
@@ -8259,6 +8259,11 @@
     transform->children_cast(this);
 }

+String* CAST::get_value_as_string()
+{
+    return value;
+}
+
 int CAST::classid()
 {
     return ID;
@@ -8274,63 +8279,41 @@
     CAST* that = dynamic_cast<CAST*>(in);
     if(that == NULL) return false;

-    if(!match_value(that))
-    	return false;
+    if(this->value != NULL && that->value != NULL)
+    	return (*this->value == *that->value);
     else
     	return true;
 }

-bool CAST::match_value(CAST* that)
-{
-    return true;
-}
-
 bool CAST::equals(Node* in)
 {
     CAST* that = dynamic_cast<CAST*>(in);
     if(that == NULL) return false;

-    if(!equals_value(that))
+    if(this->value == NULL || that->value == NULL)
+    {
+    	if(this->value != NULL || that->value != NULL)
+    		return false;
+    }
+    else if(*this->value != *that->value)
     	return false;

     if(!Node::is_mixin_equal(that)) return false;
     return true;
 }

-bool CAST::equals_value(CAST* that)
-{
-    return (*this->value == *that->value);
-}
-
 CAST* CAST::clone()
 {
-    value = clone_value();
+    String* value = new String(*this->value);
     CAST* clone = new CAST(value);
     clone->Node::clone_mixin_from(this);
     return clone;
 }

-String* CAST::clone_value()
-{
-    return value;
-}
-
 void CAST::assert_valid()
 {
-    assert_value_valid();
+    assert(value != NULL);
     Node::assert_mixin_valid();
-}
-
-void CAST::assert_value_valid()
-{
-    // Assume value is valid
-}
-
-String* CAST::get_value_as_string()
-{
-    {
-		return value;
-	}
 }

 CONSTANT_NAME::CONSTANT_NAME(String* value)

Modified: trunk/src/generated/AST.h
==============================================================================
--- trunk/src/generated/AST.h	(original)
+++ trunk/src/generated/AST.h	Wed Apr 30 05:56:57 2008
@@ -788,7 +788,7 @@
     virtual void assert_valid();
 };

-// Identifier ::= INTERFACE_NAME | CLASS_NAME | METHOD_NAME | 
VARIABLE_NAME | CAST<String*> | OP | CONSTANT_NAME | LABEL_NAME | DIRECTIVE_NAME;
+// Identifier ::= INTERFACE_NAME | CLASS_NAME | METHOD_NAME | 
VARIABLE_NAME | CAST | OP | CONSTANT_NAME | LABEL_NAME | DIRECTIVE_NAME;
 class Identifier : virtual public Source_rep
 {
 public:
@@ -1672,7 +1672,7 @@
     virtual void assert_valid();
 };

-// Cast ::= CAST<String*> Expr ;
+// Cast ::= CAST Expr ;
 class Cast : virtual public Expr
 {
 public:
@@ -2214,23 +2214,18 @@
     virtual void transform_children(Transform* transform);
 public:
     String* value;
+    virtual String* get_value_as_string();
 public:
     static const int ID = 74;
     virtual int classid();
 public:
     virtual bool match(Node* in);
-    virtual bool match_value(CAST* that);
 public:
     virtual bool equals(Node* in);
-    virtual bool equals_value(CAST* that);
 public:
     virtual CAST* clone();
-    virtual String* clone_value();
 public:
     virtual void assert_valid();
-    virtual void assert_value_valid();
-public:
-    String* get_value_as_string();
 };

 class CONSTANT_NAME : virtual public Identifier

Modified: trunk/src/generated/AST_factory.cpp
==============================================================================
--- trunk/src/generated/AST_factory.cpp	(original)
+++ trunk/src/generated/AST_factory.cpp	Wed Apr 30 05:56:57 2008
@@ -491,6 +491,12 @@
     	assert(i == args->end());
     	return new OP(value);
     }
+    if(!strcmp(type_id, "CAST"))
+    {
+    	String* value = dynamic_cast<String*>(*i++);
+    	assert(i == args->end());
+    	return new CAST(value);
+    }
     if(!strcmp(type_id, "CONSTANT_NAME"))
     {
     	String* value = dynamic_cast<String*>(*i++);

Modified: trunk/src/generated_src/ast.tea
==============================================================================
--- trunk/src/generated_src/ast.tea	(original)
+++ trunk/src/generated_src/ast.tea	Wed Apr 30 05:56:57 2008
@@ -135,7 +135,7 @@
 List_element ::= Variable | Nested_list_elements ;
 Nested_list_elements ::= List_element?* ;

-Cast ::= CAST<String*> Expr ;
+Cast ::= CAST Expr ;
 Unary_op ::= OP Expr ;
 Bin_op ::= left:Expr OP right:Expr ;

@@ -176,7 +176,7 @@

 Identifier ::=
 	  INTERFACE_NAME | CLASS_NAME | METHOD_NAME | VARIABLE_NAME
-	  | CAST<String*> | OP | CONSTANT_NAME | LABEL_NAME
+	  | CAST | OP | CONSTANT_NAME | LABEL_NAME
 	  | DIRECTIVE_NAME
 	;

@@ -561,15 +561,6 @@
 		this->cast = new CAST(new String(type));
 		this->cast->set_source_rep (source_rep);
 		this->expr = expr;
-	}
-};
-
-class CAST
-{
-public:
-	String* get_value_as_string ()
-	{
-		return value;
 	}
 };



More information about the phc-internals mailing list