[phc-internals] [phc commit] r1831 - in trunk: . src/generated src/lib

codesite-noreply at google.com codesite-noreply at google.com
Tue Oct 28 20:00:59 GMT 2008


Author: paul.biggar
Date: Tue Oct 28 12:59:26 2008
New Revision: 1831

Added:
    trunk/src/generated/AST_user_defined.h
    trunk/src/generated/HIR_user_defined.h
    trunk/src/generated/MIR_user_defined.h
Modified:
    trunk/Makefile.am
    trunk/Makefile.in
    trunk/src/lib/Boolean.h
    trunk/src/lib/Integer.h
    trunk/src/lib/List.h
    trunk/src/lib/Map.h
    trunk/src/lib/Object.h
    trunk/src/lib/String.h

Log:
Merge the List cloning fixes back to trunk from dataflow. This also fixes  
some bugs, in that Integers, Strings and Booleans were not marked as  
clonable. Map was marked as having a clone method, but it didnt actually  
support it.

This adds the XXX_user_defined.h files, which are used to handle which  
types are clonable.


Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am	(original)
+++ trunk/Makefile.am	Tue Oct 28 12:59:26 2008
@@ -92,6 +92,7 @@
  	src/generated/AST.h										\
  	src/generated/AST_transform.cpp						\
  	src/generated/AST_transform.h							\
+	src/generated/AST_user_defined.h						\
  	src/generated/AST_visitor.cpp							\
  	src/generated/AST_visitor.h							\
  	src/generated/cmdline.c									\
@@ -103,6 +104,7 @@
  	src/generated/HIR.h										\
  	src/generated/HIR_transform.cpp						\
  	src/generated/HIR_transform.h							\
+	src/generated/HIR_user_defined.h						\
  	src/generated/HIR_visitor.cpp							\
  	src/generated/HIR_visitor.h							\
  	src/generated/keywords.h								\
@@ -114,6 +116,7 @@
  	src/generated/MIR.h										\
  	src/generated/MIR_transform.cpp						\
  	src/generated/MIR_transform.h							\
+	src/generated/MIR_user_defined.h						\
  	src/generated/MIR_visitor.cpp							\
  	src/generated/MIR_visitor.h							\
  	src/generated/php_parser.tab.cpp						\
@@ -232,6 +235,7 @@
  	src/generated/AST.h										\
  	src/generated/AST_transform.cpp						\
  	src/generated/AST_transform.h							\
+	src/generated/AST_user_defined.h						\
  	src/generated/AST_visitor.cpp							\
  	src/generated/AST_visitor.h							\
  	src/generated/cmdline.c									\
@@ -243,6 +247,7 @@
  	src/generated/HIR.h										\
  	src/generated/HIR_transform.cpp						\
  	src/generated/HIR_transform.h							\
+	src/generated/HIR_user_defined.h						\
  	src/generated/HIR_visitor.cpp							\
  	src/generated/HIR_visitor.h							\
  	src/generated/keywords.h								\
@@ -254,6 +259,7 @@
  	src/generated/MIR.h										\
  	src/generated/MIR_transform.cpp						\
  	src/generated/MIR_transform.h							\
+	src/generated/MIR_user_defined.h						\
  	src/generated/MIR_visitor.cpp							\
  	src/generated/MIR_visitor.h							\
  	src/generated/php_parser.tab.cpp						\
@@ -274,17 +280,20 @@
  	src/generated/AST_fold.h				\
  	src/generated/AST.h						\
  	src/generated/AST_transform.h			\
+	src/generated/AST_user_defined.h		\
  	src/generated/AST_visitor.h			\
  	src/generated/cmdline.h					\
  	src/generated/HIR_factory.h			\
  	src/generated/HIR_fold.h				\
  	src/generated/HIR.h						\
  	src/generated/HIR_transform.h			\
+	src/generated/HIR_user_defined.h		\
  	src/generated/HIR_visitor.h			\
  	src/generated/MIR_factory.h			\
  	src/generated/MIR_fold.h				\
  	src/generated/MIR.h						\
  	src/generated/MIR_transform.h			\
+	src/generated/MIR_user_defined.h		\
  	src/generated/MIR_visitor.h

  strangeparsingdir = $(pkgincludedir)/parsing
@@ -445,41 +454,44 @@
  #   the correct way is so onerous, that this way seems much better.
  # - sed (also rm, mv and echo, below) are amongst the allowed programs to  
use
  #   in a Makefile. See GNU coding standards 7.2.2.
-src/generated/AST.cpp: 				src/generated/AST.h
-src/generated/AST_transform.cpp:	src/generated/AST.h
-src/generated/AST_transform.h:	src/generated/AST.h
-src/generated/AST_visitor.cpp:	src/generated/AST.h
-src/generated/AST_visitor.h:		src/generated/AST.h
-src/generated/AST_factory.cpp:	src/generated/AST.h
-src/generated/AST_factory.h:		src/generated/AST.h
-src/generated/AST_fold.h:			src/generated/AST.h
-#src/generated/schema.xsd:			src/generated/AST.h
+src/generated/AST.cpp: 					src/generated/AST.h
+src/generated/AST_factory.cpp:		src/generated/AST.h
+src/generated/AST_factory.h:			src/generated/AST.h
+src/generated/AST_fold.h:				src/generated/AST.h
+src/generated/AST_transform.cpp:		src/generated/AST.h
+src/generated/AST_transform.h:		src/generated/AST.h
+src/generated/AST_user_defined.h:	src/generated/AST.h
+src/generated/AST_visitor.cpp:		src/generated/AST.h
+src/generated/AST_visitor.h:			src/generated/AST.h
+#src/generated/schema.xsd:				src/generated/AST.h

  src/generated/AST.h: src/generated_src/ast.tea @maketea@
  	@maketea@ src/generated_src/ast.tea

-src/generated/HIR.cpp: 				src/generated/HIR.h
-src/generated/HIR_transform.cpp:	src/generated/HIR.h
-src/generated/HIR_transform.h:	src/generated/HIR.h
-src/generated/HIR_visitor.cpp:	src/generated/HIR.h
-src/generated/HIR_visitor.h:		src/generated/HIR.h
-src/generated/HIR_factory.cpp:	src/generated/HIR.h
-src/generated/HIR_factory.h:		src/generated/HIR.h
-src/generated/HIR_fold.h:			src/generated/HIR.h
-#src/generated/schema.xsd:			src/generated/HIR.h
+src/generated/HIR.cpp: 					src/generated/HIR.h
+src/generated/HIR_factory.cpp:		src/generated/HIR.h
+src/generated/HIR_factory.h:			src/generated/HIR.h
+src/generated/HIR_fold.h:				src/generated/HIR.h
+src/generated/HIR_transform.cpp:		src/generated/HIR.h
+src/generated/HIR_transform.h:		src/generated/HIR.h
+src/generated/HIR_user_defined.h:	src/generated/HIR.h
+src/generated/HIR_visitor.cpp:		src/generated/HIR.h
+src/generated/HIR_visitor.h:			src/generated/HIR.h
+#src/generated/schema.xsd:				src/generated/HIR.h

  src/generated/HIR.h: src/generated_src/hir.tea @maketea@
  	@maketea@ src/generated_src/hir.tea

-src/generated/MIR.cpp: 				src/generated/MIR.h
-src/generated/MIR_transform.cpp:	src/generated/MIR.h
-src/generated/MIR_transform.h:	src/generated/MIR.h
-src/generated/MIR_visitor.cpp:	src/generated/MIR.h
-src/generated/MIR_visitor.h:		src/generated/MIR.h
-src/generated/MIR_factory.cpp:	src/generated/MIR.h
-src/generated/MIR_factory.h:		src/generated/MIR.h
-src/generated/MIR_fold.h:			src/generated/MIR.h
-#src/generated/schema.xsd:			src/generated/MIR.h
+src/generated/MIR.cpp: 					src/generated/MIR.h
+src/generated/MIR_factory.cpp:		src/generated/MIR.h
+src/generated/MIR_factory.h:			src/generated/MIR.h
+src/generated/MIR_fold.h:				src/generated/MIR.h
+src/generated/MIR_transform.cpp:		src/generated/MIR.h
+src/generated/MIR_transform.h:		src/generated/MIR.h
+src/generated/MIR_user_defined.h:	src/generated/MIR.h
+src/generated/MIR_visitor.cpp:		src/generated/MIR.h
+src/generated/MIR_visitor.h:			src/generated/MIR.h
+#src/generated/schema.xsd:				src/generated/MIR.h

  src/generated/MIR.h: src/generated_src/mir.tea @maketea@
  	@maketea@ src/generated_src/mir.tea

Modified: trunk/Makefile.in
==============================================================================
--- trunk/Makefile.in	(original)
+++ trunk/Makefile.in	Tue Oct 28 12:59:26 2008
@@ -625,6 +625,7 @@
  	src/generated/AST.h										\
  	src/generated/AST_transform.cpp						\
  	src/generated/AST_transform.h							\
+	src/generated/AST_user_defined.h						\
  	src/generated/AST_visitor.cpp							\
  	src/generated/AST_visitor.h							\
  	src/generated/cmdline.c									\
@@ -636,6 +637,7 @@
  	src/generated/HIR.h										\
  	src/generated/HIR_transform.cpp						\
  	src/generated/HIR_transform.h							\
+	src/generated/HIR_user_defined.h						\
  	src/generated/HIR_visitor.cpp							\
  	src/generated/HIR_visitor.h							\
  	src/generated/keywords.h								\
@@ -647,6 +649,7 @@
  	src/generated/MIR.h										\
  	src/generated/MIR_transform.cpp						\
  	src/generated/MIR_transform.h							\
+	src/generated/MIR_user_defined.h						\
  	src/generated/MIR_visitor.cpp							\
  	src/generated/MIR_visitor.h							\
  	src/generated/php_parser.tab.cpp						\
@@ -765,6 +768,7 @@
  	src/generated/AST.h										\
  	src/generated/AST_transform.cpp						\
  	src/generated/AST_transform.h							\
+	src/generated/AST_user_defined.h						\
  	src/generated/AST_visitor.cpp							\
  	src/generated/AST_visitor.h							\
  	src/generated/cmdline.c									\
@@ -776,6 +780,7 @@
  	src/generated/HIR.h										\
  	src/generated/HIR_transform.cpp						\
  	src/generated/HIR_transform.h							\
+	src/generated/HIR_user_defined.h						\
  	src/generated/HIR_visitor.cpp							\
  	src/generated/HIR_visitor.h							\
  	src/generated/keywords.h								\
@@ -787,6 +792,7 @@
  	src/generated/MIR.h										\
  	src/generated/MIR_transform.cpp						\
  	src/generated/MIR_transform.h							\
+	src/generated/MIR_user_defined.h						\
  	src/generated/MIR_visitor.cpp							\
  	src/generated/MIR_visitor.h							\
  	src/generated/php_parser.tab.cpp						\
@@ -808,17 +814,20 @@
  	src/generated/AST_fold.h				\
  	src/generated/AST.h						\
  	src/generated/AST_transform.h			\
+	src/generated/AST_user_defined.h		\
  	src/generated/AST_visitor.h			\
  	src/generated/cmdline.h					\
  	src/generated/HIR_factory.h			\
  	src/generated/HIR_fold.h				\
  	src/generated/HIR.h						\
  	src/generated/HIR_transform.h			\
+	src/generated/HIR_user_defined.h		\
  	src/generated/HIR_visitor.h			\
  	src/generated/MIR_factory.h			\
  	src/generated/MIR_fold.h				\
  	src/generated/MIR.h						\
  	src/generated/MIR_transform.h			\
+	src/generated/MIR_user_defined.h		\
  	src/generated/MIR_visitor.h

  strangeparsingdir = $(pkgincludedir)/parsing
@@ -2704,41 +2713,44 @@
  #   the correct way is so onerous, that this way seems much better.
  # - sed (also rm, mv and echo, below) are amongst the allowed programs to  
use
  #   in a Makefile. See GNU coding standards 7.2.2.
-src/generated/AST.cpp: 				src/generated/AST.h
-src/generated/AST_transform.cpp:	src/generated/AST.h
-src/generated/AST_transform.h:	src/generated/AST.h
-src/generated/AST_visitor.cpp:	src/generated/AST.h
-src/generated/AST_visitor.h:		src/generated/AST.h
-src/generated/AST_factory.cpp:	src/generated/AST.h
-src/generated/AST_factory.h:		src/generated/AST.h
-src/generated/AST_fold.h:			src/generated/AST.h
-#src/generated/schema.xsd:			src/generated/AST.h
+src/generated/AST.cpp: 					src/generated/AST.h
+src/generated/AST_factory.cpp:		src/generated/AST.h
+src/generated/AST_factory.h:			src/generated/AST.h
+src/generated/AST_fold.h:				src/generated/AST.h
+src/generated/AST_transform.cpp:		src/generated/AST.h
+src/generated/AST_transform.h:		src/generated/AST.h
+src/generated/AST_user_defined.h:	src/generated/AST.h
+src/generated/AST_visitor.cpp:		src/generated/AST.h
+src/generated/AST_visitor.h:			src/generated/AST.h
+#src/generated/schema.xsd:				src/generated/AST.h

  src/generated/AST.h: src/generated_src/ast.tea @maketea@
  	@maketea@ src/generated_src/ast.tea

-src/generated/HIR.cpp: 				src/generated/HIR.h
-src/generated/HIR_transform.cpp:	src/generated/HIR.h
-src/generated/HIR_transform.h:	src/generated/HIR.h
-src/generated/HIR_visitor.cpp:	src/generated/HIR.h
-src/generated/HIR_visitor.h:		src/generated/HIR.h
-src/generated/HIR_factory.cpp:	src/generated/HIR.h
-src/generated/HIR_factory.h:		src/generated/HIR.h
-src/generated/HIR_fold.h:			src/generated/HIR.h
-#src/generated/schema.xsd:			src/generated/HIR.h
+src/generated/HIR.cpp: 					src/generated/HIR.h
+src/generated/HIR_factory.cpp:		src/generated/HIR.h
+src/generated/HIR_factory.h:			src/generated/HIR.h
+src/generated/HIR_fold.h:				src/generated/HIR.h
+src/generated/HIR_transform.cpp:		src/generated/HIR.h
+src/generated/HIR_transform.h:		src/generated/HIR.h
+src/generated/HIR_user_defined.h:	src/generated/HIR.h
+src/generated/HIR_visitor.cpp:		src/generated/HIR.h
+src/generated/HIR_visitor.h:			src/generated/HIR.h
+#src/generated/schema.xsd:				src/generated/HIR.h

  src/generated/HIR.h: src/generated_src/hir.tea @maketea@
  	@maketea@ src/generated_src/hir.tea

-src/generated/MIR.cpp: 				src/generated/MIR.h
-src/generated/MIR_transform.cpp:	src/generated/MIR.h
-src/generated/MIR_transform.h:	src/generated/MIR.h
-src/generated/MIR_visitor.cpp:	src/generated/MIR.h
-src/generated/MIR_visitor.h:		src/generated/MIR.h
-src/generated/MIR_factory.cpp:	src/generated/MIR.h
-src/generated/MIR_factory.h:		src/generated/MIR.h
-src/generated/MIR_fold.h:			src/generated/MIR.h
-#src/generated/schema.xsd:			src/generated/MIR.h
+src/generated/MIR.cpp: 					src/generated/MIR.h
+src/generated/MIR_factory.cpp:		src/generated/MIR.h
+src/generated/MIR_factory.h:			src/generated/MIR.h
+src/generated/MIR_fold.h:				src/generated/MIR.h
+src/generated/MIR_transform.cpp:		src/generated/MIR.h
+src/generated/MIR_transform.h:		src/generated/MIR.h
+src/generated/MIR_user_defined.h:	src/generated/MIR.h
+src/generated/MIR_visitor.cpp:		src/generated/MIR.h
+src/generated/MIR_visitor.h:			src/generated/MIR.h
+#src/generated/schema.xsd:				src/generated/MIR.h

  src/generated/MIR.h: src/generated_src/mir.tea @maketea@
  	@maketea@ src/generated_src/mir.tea

Added: trunk/src/generated/AST_user_defined.h
==============================================================================
--- (empty file)
+++ trunk/src/generated/AST_user_defined.h	Tue Oct 28 12:59:26 2008
@@ -0,0 +1,172 @@
+#ifndef _AST_USER_DEFINED_H_
+#define _AST_USER_DEFINED_H_
+
+#ifndef MAKETEA_USER_DEFINED
+#error "MAKETEA_USER_DEFINED macro undefined"
+#endif
+
+namespace AST{
+class Node;
+class PHP_script;
+class Class_mod;
+class Signature;
+class Method_mod;
+class Formal_parameter;
+class Type;
+class Attr_mod;
+class Name_with_default;
+class Directive;
+class List_element;
+class Variable_name;
+class Target;
+class Array_elem;
+class Method_name;
+class Actual_parameter;
+class Class_name;
+class Commented_node;
+class Source_rep;
+class Statement;
+class Member;
+class Switch_case;
+class Catch;
+class Expr;
+class Nested_list_elements;
+class Reflection;
+class Identifier;
+class Class_def;
+class Interface_def;
+class Method;
+class Attribute;
+class If;
+class While;
+class Do;
+class For;
+class Foreach;
+class Switch;
+class Break;
+class Continue;
+class Return;
+class Static_declaration;
+class Global;
+class Declare;
+class Try;
+class Throw;
+class Eval_expr;
+class Nop;
+class Literal;
+class Assignment;
+class Op_assignment;
+class List_assignment;
+class Cast;
+class Unary_op;
+class Bin_op;
+class Conditional_expr;
+class Ignore_errors;
+class Constant;
+class Instanceof;
+class Variable;
+class Pre_op;
+class Post_op;
+class Array;
+class Method_invocation;
+class New;
+class FOREIGN;
+class CLASS_NAME;
+class INTERFACE_NAME;
+class METHOD_NAME;
+class VARIABLE_NAME;
+class DIRECTIVE_NAME;
+class OP;
+class CAST;
+class CONSTANT_NAME;
+class INT;
+class REAL;
+class STRING;
+class BOOL;
+class NIL;
+class None;
+
+}
+
+MAKETEA_USER_DEFINED(AST::Node)
+MAKETEA_USER_DEFINED(AST::PHP_script)
+MAKETEA_USER_DEFINED(AST::Class_mod)
+MAKETEA_USER_DEFINED(AST::Signature)
+MAKETEA_USER_DEFINED(AST::Method_mod)
+MAKETEA_USER_DEFINED(AST::Formal_parameter)
+MAKETEA_USER_DEFINED(AST::Type)
+MAKETEA_USER_DEFINED(AST::Attr_mod)
+MAKETEA_USER_DEFINED(AST::Name_with_default)
+MAKETEA_USER_DEFINED(AST::Directive)
+MAKETEA_USER_DEFINED(AST::List_element)
+MAKETEA_USER_DEFINED(AST::Variable_name)
+MAKETEA_USER_DEFINED(AST::Target)
+MAKETEA_USER_DEFINED(AST::Array_elem)
+MAKETEA_USER_DEFINED(AST::Method_name)
+MAKETEA_USER_DEFINED(AST::Actual_parameter)
+MAKETEA_USER_DEFINED(AST::Class_name)
+MAKETEA_USER_DEFINED(AST::Commented_node)
+MAKETEA_USER_DEFINED(AST::Source_rep)
+MAKETEA_USER_DEFINED(AST::Statement)
+MAKETEA_USER_DEFINED(AST::Member)
+MAKETEA_USER_DEFINED(AST::Switch_case)
+MAKETEA_USER_DEFINED(AST::Catch)
+MAKETEA_USER_DEFINED(AST::Expr)
+MAKETEA_USER_DEFINED(AST::Nested_list_elements)
+MAKETEA_USER_DEFINED(AST::Reflection)
+MAKETEA_USER_DEFINED(AST::Identifier)
+MAKETEA_USER_DEFINED(AST::Class_def)
+MAKETEA_USER_DEFINED(AST::Interface_def)
+MAKETEA_USER_DEFINED(AST::Method)
+MAKETEA_USER_DEFINED(AST::Attribute)
+MAKETEA_USER_DEFINED(AST::If)
+MAKETEA_USER_DEFINED(AST::While)
+MAKETEA_USER_DEFINED(AST::Do)
+MAKETEA_USER_DEFINED(AST::For)
+MAKETEA_USER_DEFINED(AST::Foreach)
+MAKETEA_USER_DEFINED(AST::Switch)
+MAKETEA_USER_DEFINED(AST::Break)
+MAKETEA_USER_DEFINED(AST::Continue)
+MAKETEA_USER_DEFINED(AST::Return)
+MAKETEA_USER_DEFINED(AST::Static_declaration)
+MAKETEA_USER_DEFINED(AST::Global)
+MAKETEA_USER_DEFINED(AST::Declare)
+MAKETEA_USER_DEFINED(AST::Try)
+MAKETEA_USER_DEFINED(AST::Throw)
+MAKETEA_USER_DEFINED(AST::Eval_expr)
+MAKETEA_USER_DEFINED(AST::Nop)
+MAKETEA_USER_DEFINED(AST::Literal)
+MAKETEA_USER_DEFINED(AST::Assignment)
+MAKETEA_USER_DEFINED(AST::Op_assignment)
+MAKETEA_USER_DEFINED(AST::List_assignment)
+MAKETEA_USER_DEFINED(AST::Cast)
+MAKETEA_USER_DEFINED(AST::Unary_op)
+MAKETEA_USER_DEFINED(AST::Bin_op)
+MAKETEA_USER_DEFINED(AST::Conditional_expr)
+MAKETEA_USER_DEFINED(AST::Ignore_errors)
+MAKETEA_USER_DEFINED(AST::Constant)
+MAKETEA_USER_DEFINED(AST::Instanceof)
+MAKETEA_USER_DEFINED(AST::Variable)
+MAKETEA_USER_DEFINED(AST::Pre_op)
+MAKETEA_USER_DEFINED(AST::Post_op)
+MAKETEA_USER_DEFINED(AST::Array)
+MAKETEA_USER_DEFINED(AST::Method_invocation)
+MAKETEA_USER_DEFINED(AST::New)
+MAKETEA_USER_DEFINED(AST::FOREIGN)
+MAKETEA_USER_DEFINED(AST::CLASS_NAME)
+MAKETEA_USER_DEFINED(AST::INTERFACE_NAME)
+MAKETEA_USER_DEFINED(AST::METHOD_NAME)
+MAKETEA_USER_DEFINED(AST::VARIABLE_NAME)
+MAKETEA_USER_DEFINED(AST::DIRECTIVE_NAME)
+MAKETEA_USER_DEFINED(AST::OP)
+MAKETEA_USER_DEFINED(AST::CAST)
+MAKETEA_USER_DEFINED(AST::CONSTANT_NAME)
+MAKETEA_USER_DEFINED(AST::INT)
+MAKETEA_USER_DEFINED(AST::REAL)
+MAKETEA_USER_DEFINED(AST::STRING)
+MAKETEA_USER_DEFINED(AST::BOOL)
+MAKETEA_USER_DEFINED(AST::NIL)
+MAKETEA_USER_DEFINED(AST::None)
+
+
+#endif

Added: trunk/src/generated/HIR_user_defined.h
==============================================================================
--- (empty file)
+++ trunk/src/generated/HIR_user_defined.h	Tue Oct 28 12:59:26 2008
@@ -0,0 +1,168 @@
+#ifndef _HIR_USER_DEFINED_H_
+#define _HIR_USER_DEFINED_H_
+
+#ifndef MAKETEA_USER_DEFINED
+#error "MAKETEA_USER_DEFINED macro undefined"
+#endif
+
+namespace HIR{
+class Node;
+class PHP_script;
+class Statement;
+class Class_mod;
+class Member;
+class Signature;
+class Method_mod;
+class Formal_parameter;
+class Type;
+class Attr_mod;
+class Name_with_default;
+class Catch;
+class Expr;
+class Rvalue;
+class Target;
+class Actual_parameter;
+class Method_name;
+class Class_name;
+class Field_name;
+class Static_value;
+class Static_array_elem;
+class Static_array_key;
+class Identifier;
+class Class_def;
+class Interface_def;
+class Method;
+class Attribute;
+class If;
+class Loop;
+class Foreach;
+class Break;
+class Continue;
+class Return;
+class Static_declaration;
+class Global;
+class Try;
+class Throw;
+class Assign_var;
+class Assign_field;
+class Assign_array;
+class Assign_var_var;
+class Assign_next;
+class Pre_op;
+class Eval_expr;
+class Literal;
+class Field_access;
+class Array_access;
+class Array_next;
+class Cast;
+class Unary_op;
+class Bin_op;
+class Constant;
+class Instanceof;
+class Method_invocation;
+class New;
+class Variable_actual_parameter;
+class Variable_name;
+class Variable_method;
+class Variable_class;
+class Variable_field;
+class Static_array;
+class FOREIGN;
+class CLASS_NAME;
+class INTERFACE_NAME;
+class METHOD_NAME;
+class OP;
+class CAST;
+class CONSTANT_NAME;
+class FIELD_NAME;
+class Variable_variable;
+class VARIABLE_NAME;
+class INT;
+class REAL;
+class STRING;
+class BOOL;
+class NIL;
+class None;
+
+}
+
+MAKETEA_USER_DEFINED(HIR::Node)
+MAKETEA_USER_DEFINED(HIR::PHP_script)
+MAKETEA_USER_DEFINED(HIR::Statement)
+MAKETEA_USER_DEFINED(HIR::Class_mod)
+MAKETEA_USER_DEFINED(HIR::Member)
+MAKETEA_USER_DEFINED(HIR::Signature)
+MAKETEA_USER_DEFINED(HIR::Method_mod)
+MAKETEA_USER_DEFINED(HIR::Formal_parameter)
+MAKETEA_USER_DEFINED(HIR::Type)
+MAKETEA_USER_DEFINED(HIR::Attr_mod)
+MAKETEA_USER_DEFINED(HIR::Name_with_default)
+MAKETEA_USER_DEFINED(HIR::Catch)
+MAKETEA_USER_DEFINED(HIR::Expr)
+MAKETEA_USER_DEFINED(HIR::Rvalue)
+MAKETEA_USER_DEFINED(HIR::Target)
+MAKETEA_USER_DEFINED(HIR::Actual_parameter)
+MAKETEA_USER_DEFINED(HIR::Method_name)
+MAKETEA_USER_DEFINED(HIR::Class_name)
+MAKETEA_USER_DEFINED(HIR::Field_name)
+MAKETEA_USER_DEFINED(HIR::Static_value)
+MAKETEA_USER_DEFINED(HIR::Static_array_elem)
+MAKETEA_USER_DEFINED(HIR::Static_array_key)
+MAKETEA_USER_DEFINED(HIR::Identifier)
+MAKETEA_USER_DEFINED(HIR::Class_def)
+MAKETEA_USER_DEFINED(HIR::Interface_def)
+MAKETEA_USER_DEFINED(HIR::Method)
+MAKETEA_USER_DEFINED(HIR::Attribute)
+MAKETEA_USER_DEFINED(HIR::If)
+MAKETEA_USER_DEFINED(HIR::Loop)
+MAKETEA_USER_DEFINED(HIR::Foreach)
+MAKETEA_USER_DEFINED(HIR::Break)
+MAKETEA_USER_DEFINED(HIR::Continue)
+MAKETEA_USER_DEFINED(HIR::Return)
+MAKETEA_USER_DEFINED(HIR::Static_declaration)
+MAKETEA_USER_DEFINED(HIR::Global)
+MAKETEA_USER_DEFINED(HIR::Try)
+MAKETEA_USER_DEFINED(HIR::Throw)
+MAKETEA_USER_DEFINED(HIR::Assign_var)
+MAKETEA_USER_DEFINED(HIR::Assign_field)
+MAKETEA_USER_DEFINED(HIR::Assign_array)
+MAKETEA_USER_DEFINED(HIR::Assign_var_var)
+MAKETEA_USER_DEFINED(HIR::Assign_next)
+MAKETEA_USER_DEFINED(HIR::Pre_op)
+MAKETEA_USER_DEFINED(HIR::Eval_expr)
+MAKETEA_USER_DEFINED(HIR::Literal)
+MAKETEA_USER_DEFINED(HIR::Field_access)
+MAKETEA_USER_DEFINED(HIR::Array_access)
+MAKETEA_USER_DEFINED(HIR::Array_next)
+MAKETEA_USER_DEFINED(HIR::Cast)
+MAKETEA_USER_DEFINED(HIR::Unary_op)
+MAKETEA_USER_DEFINED(HIR::Bin_op)
+MAKETEA_USER_DEFINED(HIR::Constant)
+MAKETEA_USER_DEFINED(HIR::Instanceof)
+MAKETEA_USER_DEFINED(HIR::Method_invocation)
+MAKETEA_USER_DEFINED(HIR::New)
+MAKETEA_USER_DEFINED(HIR::Variable_actual_parameter)
+MAKETEA_USER_DEFINED(HIR::Variable_name)
+MAKETEA_USER_DEFINED(HIR::Variable_method)
+MAKETEA_USER_DEFINED(HIR::Variable_class)
+MAKETEA_USER_DEFINED(HIR::Variable_field)
+MAKETEA_USER_DEFINED(HIR::Static_array)
+MAKETEA_USER_DEFINED(HIR::FOREIGN)
+MAKETEA_USER_DEFINED(HIR::CLASS_NAME)
+MAKETEA_USER_DEFINED(HIR::INTERFACE_NAME)
+MAKETEA_USER_DEFINED(HIR::METHOD_NAME)
+MAKETEA_USER_DEFINED(HIR::OP)
+MAKETEA_USER_DEFINED(HIR::CAST)
+MAKETEA_USER_DEFINED(HIR::CONSTANT_NAME)
+MAKETEA_USER_DEFINED(HIR::FIELD_NAME)
+MAKETEA_USER_DEFINED(HIR::Variable_variable)
+MAKETEA_USER_DEFINED(HIR::VARIABLE_NAME)
+MAKETEA_USER_DEFINED(HIR::INT)
+MAKETEA_USER_DEFINED(HIR::REAL)
+MAKETEA_USER_DEFINED(HIR::STRING)
+MAKETEA_USER_DEFINED(HIR::BOOL)
+MAKETEA_USER_DEFINED(HIR::NIL)
+MAKETEA_USER_DEFINED(HIR::None)
+
+
+#endif

Added: trunk/src/generated/MIR_user_defined.h
==============================================================================
--- (empty file)
+++ trunk/src/generated/MIR_user_defined.h	Tue Oct 28 12:59:26 2008
@@ -0,0 +1,192 @@
+#ifndef _MIR_USER_DEFINED_H_
+#define _MIR_USER_DEFINED_H_
+
+#ifndef MAKETEA_USER_DEFINED
+#error "MAKETEA_USER_DEFINED macro undefined"
+#endif
+
+namespace MIR{
+class Node;
+class PHP_script;
+class Statement;
+class Class_mod;
+class Member;
+class Signature;
+class Method_mod;
+class Formal_parameter;
+class Type;
+class Attr_mod;
+class Name_with_default;
+class Catch;
+class Expr;
+class Rvalue;
+class Target;
+class Actual_parameter;
+class Method_name;
+class Class_name;
+class Field_name;
+class Static_value;
+class Static_array_elem;
+class Static_array_key;
+class Identifier;
+class PARAM_INDEX;
+class Class_def;
+class Interface_def;
+class Method;
+class Attribute;
+class Class_alias;
+class Interface_alias;
+class Method_alias;
+class Return;
+class Static_declaration;
+class Global;
+class Try;
+class Throw;
+class Assign_var;
+class Assign_field;
+class Assign_array;
+class Assign_var_var;
+class Assign_next;
+class Pre_op;
+class Eval_expr;
+class Unset;
+class Isset;
+class Literal;
+class Field_access;
+class Array_access;
+class Array_next;
+class Cast;
+class Unary_op;
+class Bin_op;
+class Constant;
+class Instanceof;
+class Method_invocation;
+class New;
+class Variable_name;
+class Variable_method;
+class Variable_class;
+class Variable_field;
+class Static_array;
+class Branch;
+class Goto;
+class Label;
+class Foreach_reset;
+class Foreach_next;
+class Foreach_end;
+class Foreach_has_key;
+class Foreach_get_key;
+class Foreach_get_val;
+class Param_is_ref;
+class FOREIGN;
+class CLASS_NAME;
+class INTERFACE_NAME;
+class METHOD_NAME;
+class OP;
+class CAST;
+class CONSTANT_NAME;
+class FIELD_NAME;
+class LABEL_NAME;
+class HT_ITERATOR;
+class Variable_variable;
+class VARIABLE_NAME;
+class INT;
+class REAL;
+class STRING;
+class BOOL;
+class NIL;
+class None;
+
+}
+
+MAKETEA_USER_DEFINED(MIR::Node)
+MAKETEA_USER_DEFINED(MIR::PHP_script)
+MAKETEA_USER_DEFINED(MIR::Statement)
+MAKETEA_USER_DEFINED(MIR::Class_mod)
+MAKETEA_USER_DEFINED(MIR::Member)
+MAKETEA_USER_DEFINED(MIR::Signature)
+MAKETEA_USER_DEFINED(MIR::Method_mod)
+MAKETEA_USER_DEFINED(MIR::Formal_parameter)
+MAKETEA_USER_DEFINED(MIR::Type)
+MAKETEA_USER_DEFINED(MIR::Attr_mod)
+MAKETEA_USER_DEFINED(MIR::Name_with_default)
+MAKETEA_USER_DEFINED(MIR::Catch)
+MAKETEA_USER_DEFINED(MIR::Expr)
+MAKETEA_USER_DEFINED(MIR::Rvalue)
+MAKETEA_USER_DEFINED(MIR::Target)
+MAKETEA_USER_DEFINED(MIR::Actual_parameter)
+MAKETEA_USER_DEFINED(MIR::Method_name)
+MAKETEA_USER_DEFINED(MIR::Class_name)
+MAKETEA_USER_DEFINED(MIR::Field_name)
+MAKETEA_USER_DEFINED(MIR::Static_value)
+MAKETEA_USER_DEFINED(MIR::Static_array_elem)
+MAKETEA_USER_DEFINED(MIR::Static_array_key)
+MAKETEA_USER_DEFINED(MIR::Identifier)
+MAKETEA_USER_DEFINED(MIR::PARAM_INDEX)
+MAKETEA_USER_DEFINED(MIR::Class_def)
+MAKETEA_USER_DEFINED(MIR::Interface_def)
+MAKETEA_USER_DEFINED(MIR::Method)
+MAKETEA_USER_DEFINED(MIR::Attribute)
+MAKETEA_USER_DEFINED(MIR::Class_alias)
+MAKETEA_USER_DEFINED(MIR::Interface_alias)
+MAKETEA_USER_DEFINED(MIR::Method_alias)
+MAKETEA_USER_DEFINED(MIR::Return)
+MAKETEA_USER_DEFINED(MIR::Static_declaration)
+MAKETEA_USER_DEFINED(MIR::Global)
+MAKETEA_USER_DEFINED(MIR::Try)
+MAKETEA_USER_DEFINED(MIR::Throw)
+MAKETEA_USER_DEFINED(MIR::Assign_var)
+MAKETEA_USER_DEFINED(MIR::Assign_field)
+MAKETEA_USER_DEFINED(MIR::Assign_array)
+MAKETEA_USER_DEFINED(MIR::Assign_var_var)
+MAKETEA_USER_DEFINED(MIR::Assign_next)
+MAKETEA_USER_DEFINED(MIR::Pre_op)
+MAKETEA_USER_DEFINED(MIR::Eval_expr)
+MAKETEA_USER_DEFINED(MIR::Unset)
+MAKETEA_USER_DEFINED(MIR::Isset)
+MAKETEA_USER_DEFINED(MIR::Literal)
+MAKETEA_USER_DEFINED(MIR::Field_access)
+MAKETEA_USER_DEFINED(MIR::Array_access)
+MAKETEA_USER_DEFINED(MIR::Array_next)
+MAKETEA_USER_DEFINED(MIR::Cast)
+MAKETEA_USER_DEFINED(MIR::Unary_op)
+MAKETEA_USER_DEFINED(MIR::Bin_op)
+MAKETEA_USER_DEFINED(MIR::Constant)
+MAKETEA_USER_DEFINED(MIR::Instanceof)
+MAKETEA_USER_DEFINED(MIR::Method_invocation)
+MAKETEA_USER_DEFINED(MIR::New)
+MAKETEA_USER_DEFINED(MIR::Variable_name)
+MAKETEA_USER_DEFINED(MIR::Variable_method)
+MAKETEA_USER_DEFINED(MIR::Variable_class)
+MAKETEA_USER_DEFINED(MIR::Variable_field)
+MAKETEA_USER_DEFINED(MIR::Static_array)
+MAKETEA_USER_DEFINED(MIR::Branch)
+MAKETEA_USER_DEFINED(MIR::Goto)
+MAKETEA_USER_DEFINED(MIR::Label)
+MAKETEA_USER_DEFINED(MIR::Foreach_reset)
+MAKETEA_USER_DEFINED(MIR::Foreach_next)
+MAKETEA_USER_DEFINED(MIR::Foreach_end)
+MAKETEA_USER_DEFINED(MIR::Foreach_has_key)
+MAKETEA_USER_DEFINED(MIR::Foreach_get_key)
+MAKETEA_USER_DEFINED(MIR::Foreach_get_val)
+MAKETEA_USER_DEFINED(MIR::Param_is_ref)
+MAKETEA_USER_DEFINED(MIR::FOREIGN)
+MAKETEA_USER_DEFINED(MIR::CLASS_NAME)
+MAKETEA_USER_DEFINED(MIR::INTERFACE_NAME)
+MAKETEA_USER_DEFINED(MIR::METHOD_NAME)
+MAKETEA_USER_DEFINED(MIR::OP)
+MAKETEA_USER_DEFINED(MIR::CAST)
+MAKETEA_USER_DEFINED(MIR::CONSTANT_NAME)
+MAKETEA_USER_DEFINED(MIR::FIELD_NAME)
+MAKETEA_USER_DEFINED(MIR::LABEL_NAME)
+MAKETEA_USER_DEFINED(MIR::HT_ITERATOR)
+MAKETEA_USER_DEFINED(MIR::Variable_variable)
+MAKETEA_USER_DEFINED(MIR::VARIABLE_NAME)
+MAKETEA_USER_DEFINED(MIR::INT)
+MAKETEA_USER_DEFINED(MIR::REAL)
+MAKETEA_USER_DEFINED(MIR::STRING)
+MAKETEA_USER_DEFINED(MIR::BOOL)
+MAKETEA_USER_DEFINED(MIR::NIL)
+MAKETEA_USER_DEFINED(MIR::None)
+
+
+#endif

Modified: trunk/src/lib/Boolean.h
==============================================================================
--- trunk/src/lib/Boolean.h	(original)
+++ trunk/src/lib/Boolean.h	Tue Oct 28 12:59:26 2008
@@ -24,4 +24,6 @@
  	Boolean* clone();
  };

+SET_CLONABLE(Boolean)
+
  #endif // PHC_BOOLEAN_H

Modified: trunk/src/lib/Integer.h
==============================================================================
--- trunk/src/lib/Integer.h	(original)
+++ trunk/src/lib/Integer.h	Tue Oct 28 12:59:26 2008
@@ -30,4 +30,6 @@
  	void operator++(POST_INCREMENT);
  };

+SET_CLONABLE(Integer)
+
  #endif // PHC_INTEGER_H

Modified: trunk/src/lib/List.h
==============================================================================
--- trunk/src/lib/List.h	(original)
+++ trunk/src/lib/List.h	Tue Oct 28 12:59:26 2008
@@ -13,30 +13,60 @@
  #include "process_ir/Foreach.h"

  // XXX HACK
-/* The implementation of List requires a clone() method, because it was
+/*
+ * The implementation of List requires a clone() method, because it was
   * originally designed for the maketea derived clone() methods. But we  
want to
   * use List instead of std::list to make sure garbage collection is used
   * everywhere.  This "hack" allows us to call Object::clone(), and fail if
   * clone() is called for classes that don't support it (all other classes).
   */
-template<Object*>
-Object* phc_clone (Object* object)
-{
-	if (object == NULL)
-		return NULL;

-	return object->clone ();
-}
+namespace IR { class Node; class FOREIGN; class PHP_script; }
+SET_CLONABLE(IR::Node)
+SET_CLONABLE(IR::FOREIGN)
+SET_CLONABLE(IR::PHP_script)
+
+#define MAKETEA_USER_DEFINED(TYPE) SET_CLONABLE(TYPE)
+#include "AST_user_defined.h"
+#include "HIR_user_defined.h"
+#include "MIR_user_defined.h"
+#undef MAKETEA_USER_DEFINED
+
+/*
+ * For all classes on which SET_CLONABLE is set,  
supports_cloning<T>::value is
+ * true, making the template call obj->clone(). All other classes will  
default
+ * to false, calling assert (0) instead. Using this approach means that  
other
+ * classes do not have to have a clone() method - all other approaches I  
tried
+ * led to compile-time failure, or didnt do the right thing.
+ */
+
+template<bool b>
+struct algorithm_selector
+{
+	template<typename T>
+	static T& clone (T object)
+	{
+		assert (0);
+	}
+};

-template<typename T>
-T phc_clone (T object)
-{
-	if (object == NULL)
-		return NULL;

-	return object->clone ();
-}

+// Call to clone for classes that support it.
+template<>
+struct algorithm_selector<true>
+{
+	template<typename T>
+	static T clone (T object)
+	{
+		return object->clone ();
+	}
+};
+template<typename T>
+T phc_clone (T object)
+{
+	return algorithm_selector<supports_cloning<T>::value>::clone(object);
+}


  template<typename _Tp, typename _Alloc = phc_allocator<_Tp> >
@@ -79,12 +109,6 @@
  	}

  public:
-	// TODO: clone assumes that _Tp supports a clone method. It would be  
useful
-	// if we could automatically call a clone method if supported, and do a
-	// shallow copy (or call a copy-constructor, which?) if not. I think that
-	// checking for a clonable trait of _Tp might do that (involves adding  
such
-	// a trait to Object, which is OK).
-	//
  	List* clone()
  	{
  		List* result = new List<_Tp, _Alloc>;

Modified: trunk/src/lib/Map.h
==============================================================================
--- trunk/src/lib/Map.h	(original)
+++ trunk/src/lib/Map.h	Tue Oct 28 12:59:26 2008
@@ -17,14 +17,12 @@
  	typename _Compare = std::less<_Key>,
  	typename _Alloc = phc_allocator<std::pair<const _Key, _Tp> >
  >
-class Map : public std::map<_Key, _Tp, _Compare, _Alloc>, virtual public  
Object
+class Map : public std::map<_Key, _Tp, _Compare, _Alloc>, virtual public  
GC_obj
  {
  public:
  	Map() : std::map<_Key, _Tp, _Compare, _Alloc>() {}
  	Map(_Compare comparator) : std::map<_Key, _Tp, _Compare,  
_Alloc>(comparator) {}
  	virtual ~Map() {}
-
-	Map* clone() { assert (0); }

  public:
  	bool has(_Key key)

Modified: trunk/src/lib/Object.h
==============================================================================
--- trunk/src/lib/Object.h	(original)
+++ trunk/src/lib/Object.h	Tue Oct 28 12:59:26 2008
@@ -96,4 +96,23 @@
  	return result;
  }

+
+// Add class traits to indicate whether cloning works (see List.h).
+template<typename T>
+struct
+supports_cloning
+{
+  static const bool value = false;
+};
+
+#define SET_CLONABLE(TYPE)								\
+template<>													\
+struct														\
+supports_cloning<TYPE*>									\
+{																\
+  static const bool value = true;					\
+};
+
+SET_CLONABLE(Object)
+
  #endif // PHC_OBJECT_H

Modified: trunk/src/lib/String.h
==============================================================================
--- trunk/src/lib/String.h	(original)
+++ trunk/src/lib/String.h	Tue Oct 28 12:59:26 2008
@@ -48,6 +48,8 @@
  // 'new String' must be the most typed function in phc
  String* s (const string& s);

+SET_CLONABLE(String)
+
  typedef List<String*> String_list;

  #endif // PHC_STRING_H


More information about the phc-internals mailing list