[phc-internals] [phc commit] r1602 - in trunk: . libphc src src/ast_to_hir src/hir_to_mir test/subjects/parsing

codesite-noreply at google.com codesite-noreply at google.com
Thu Sep 4 13:32:59 IST 2008


Author: paul.biggar
Date: Thu Sep  4 05:31:51 2008
New Revision: 1602

Removed:
    trunk/src/ast_to_hir/Translate_empty.cpp
    trunk/src/ast_to_hir/Translate_empty.h
Modified:
    trunk/Makefile.am
    trunk/Makefile.in
    trunk/libphc/builtin_functions.c
    trunk/src/hir_to_mir/Lower_method_invocations.cpp
    trunk/src/phc.cpp
    trunk/test/subjects/parsing/empty.php

Log:
This removes the Translate_empty pass, and empty() is now handled by a  
run-time call to phc_builtin_empty.




Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am	(original)
+++ trunk/Makefile.am	Thu Sep  4 05:31:51 2008
@@ -77,8 +77,6 @@
  	src/ast_to_hir/Split_unset_isset.h					\
  	src/ast_to_hir/Strip_comments.cpp					\
  	src/ast_to_hir/Strip_comments.h						\
-	src/ast_to_hir/Translate_empty.cpp					\
-	src/ast_to_hir/Translate_empty.h						\
  	src/codegen/Clarify.cpp									\
  	src/codegen/Clarify.h									\
  	src/codegen/Compile_C.cpp								\

Modified: trunk/Makefile.in
==============================================================================
--- trunk/Makefile.in	(original)
+++ trunk/Makefile.in	Thu Sep  4 05:31:51 2008
@@ -90,19 +90,19 @@
  	Early_lower_control_flow.lo Echo_split.lo List_shredder.lo \
  	Lower_expr_flow.lo Pre_post_op_shredder.lo \
  	Split_multiple_arguments.lo Split_unset_isset.lo \
-	Strip_comments.lo Translate_empty.lo Clarify.lo Compile_C.lo \
-	Generate_C.lo Lift_functions_and_classes.lo embed.lo AST.lo \
-	AST_factory.lo AST_transform.lo AST_visitor.lo cmdline.lo \
-	HIR.lo HIR_factory.lo HIR_transform.lo HIR_visitor.lo \
-	lex.yy.lo MIR.lo MIR_factory.lo MIR_transform.lo \
-	MIR_visitor.lo php_parser.tab.lo HIR_lower_expr.lo \
-	Lower_control_flow.lo Lower_method_invocations.lo AttrMap.lo \
-	base64.lo Boolean.lo demangle.lo error.lo Integer.lo Object.lo \
-	String.lo Copy_propagation.lo Dead_code_elimination.lo \
-	Fix_point.lo Prune_symbol_table.lo Use_def_counter.lo \
-	Parse_buffer.lo parse.lo PHP_context.lo XML_parser.lo \
-	Pass_manager.lo Plugin_pass.lo AST_unparser.lo \
-	Constant_folding.lo DOT_unparser.lo Invalid_check.lo \
+	Strip_comments.lo Clarify.lo Compile_C.lo Generate_C.lo \
+	Lift_functions_and_classes.lo embed.lo AST.lo AST_factory.lo \
+	AST_transform.lo AST_visitor.lo cmdline.lo HIR.lo \
+	HIR_factory.lo HIR_transform.lo HIR_visitor.lo lex.yy.lo \
+	MIR.lo MIR_factory.lo MIR_transform.lo MIR_visitor.lo \
+	php_parser.tab.lo HIR_lower_expr.lo Lower_control_flow.lo \
+	Lower_method_invocations.lo AttrMap.lo base64.lo Boolean.lo \
+	demangle.lo error.lo Integer.lo Object.lo String.lo \
+	Copy_propagation.lo Dead_code_elimination.lo Fix_point.lo \
+	Prune_symbol_table.lo Use_def_counter.lo Parse_buffer.lo \
+	parse.lo PHP_context.lo XML_parser.lo Pass_manager.lo \
+	Plugin_pass.lo AST_unparser.lo Constant_folding.lo \
+	DOT_unparser.lo Invalid_check.lo \
  	Note_top_level_declarations.lo Process_includes.lo \
  	Remove_concat_null.lo Remove_parser_temporaries.lo \
  	Strip_unparser_attributes.lo Token_conversion.lo \
@@ -610,8 +610,6 @@
  	src/ast_to_hir/Split_unset_isset.h					\
  	src/ast_to_hir/Strip_comments.cpp					\
  	src/ast_to_hir/Strip_comments.h						\
-	src/ast_to_hir/Translate_empty.cpp					\
-	src/ast_to_hir/Translate_empty.h						\
  	src/codegen/Clarify.cpp									\
  	src/codegen/Clarify.h									\
  	src/codegen/Compile_C.cpp								\
@@ -1258,7 +1256,6 @@
  @AMDEP_TRUE@@am__include@  
@am__quote at ./$(DEPDIR)/Strip_comments.Plo at am__quote@
  @AMDEP_TRUE@@am__include@  
@am__quote at ./$(DEPDIR)/Strip_unparser_attributes.Plo at am__quote@
  @AMDEP_TRUE@@am__include@  
@am__quote at ./$(DEPDIR)/Token_conversion.Plo at am__quote@
- at AMDEP_TRUE@@am__include@  
@am__quote at ./$(DEPDIR)/Translate_empty.Plo at am__quote@
  @AMDEP_TRUE@@am__include@  
@am__quote at ./$(DEPDIR)/Use_def_counter.Plo at am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XML_parser.Plo at am__quote@
  @AMDEP_TRUE@@am__include@  
@am__quote at ./$(DEPDIR)/XML_unparser.Plo at am__quote@
@@ -1440,13 +1437,6 @@
  @AMDEP_TRUE@@am__fastdepCXX_FALSE@	 
source='src/ast_to_hir/Strip_comments.cpp' object='Strip_comments.lo'  
libtool=yes @AMDEPBACKSLASH@
  @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE)  
$(depcomp) @AMDEPBACKSLASH@
  @am__fastdepCXX_FALSE@	$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS)  
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES)  
$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o  
Strip_comments.lo `test -f 'src/ast_to_hir/Strip_comments.cpp' ||  
echo '$(srcdir)/'`src/ast_to_hir/Strip_comments.cpp
-
-Translate_empty.lo: src/ast_to_hir/Translate_empty.cpp
- at am__fastdepCXX_TRUE@	$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS)  
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES)  
$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT  
Translate_empty.lo -MD -MP -MF $(DEPDIR)/Translate_empty.Tpo -c -o  
Translate_empty.lo `test -f 'src/ast_to_hir/Translate_empty.cpp' ||  
echo '$(srcdir)/'`src/ast_to_hir/Translate_empty.cpp
- at am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/Translate_empty.Tpo  
$(DEPDIR)/Translate_empty.Plo
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	 
source='src/ast_to_hir/Translate_empty.cpp' object='Translate_empty.lo'  
libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE)  
$(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS)  
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES)  
$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o  
Translate_empty.lo `test -f 'src/ast_to_hir/Translate_empty.cpp' ||  
echo '$(srcdir)/'`src/ast_to_hir/Translate_empty.cpp

  Clarify.lo: src/codegen/Clarify.cpp
  @am__fastdepCXX_TRUE@	$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS)  
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES)  
$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT  
Clarify.lo -MD -MP -MF $(DEPDIR)/Clarify.Tpo -c -o Clarify.lo `test  
-f 'src/codegen/Clarify.cpp' || echo '$(srcdir)/'`src/codegen/Clarify.cpp

Modified: trunk/libphc/builtin_functions.c
==============================================================================
--- trunk/libphc/builtin_functions.c	(original)
+++ trunk/libphc/builtin_functions.c	Thu Sep  4 05:31:51 2008
@@ -66,6 +66,5 @@
  static void
  phc_builtin_empty (zval* arg, zval* result TSRMLS_DC)
  {
-//   return (not_in_symbol_table || is_false (value))
-  ZVAL_BOOL (result, !zend_is_true);
+  ZVAL_BOOL (result, !zend_is_true (arg));
  }

Modified: trunk/src/hir_to_mir/Lower_method_invocations.cpp
==============================================================================
--- trunk/src/hir_to_mir/Lower_method_invocations.cpp	(original)
+++ trunk/src/hir_to_mir/Lower_method_invocations.cpp	Thu Sep  4 05:31:51  
2008
@@ -40,7 +40,8 @@
  Expr*
  Lower_method_invocations::pre_method_invocation (Method_invocation* in)
  {
-	// Leave unset in place - it still needs access to the target and indices.
+	// Leave unset and isset in place - it still needs access to the target  
and
+	// indices.
  	METHOD_NAME* mn = dynamic_cast <METHOD_NAME*> (in->method_name);
  	if (in->target == NULL
  		&& mn
@@ -166,8 +167,8 @@
  		&& isa<MIR::METHOD_NAME> (param_is_ref->method_name))
  	{
  		String* method_name = dyc<MIR::METHOD_NAME>  
(param_is_ref->method_name)->value;
-		if (*method_name == "isset"
-		    || *method_name == "print")
+		if (	 *method_name == "print"
+		    || *method_name == "empty")
  			return new BOOL (false);
  	}


Modified: trunk/src/phc.cpp
==============================================================================
--- trunk/src/phc.cpp	(original)
+++ trunk/src/phc.cpp	Thu Sep  4 05:31:51 2008
@@ -21,7 +21,6 @@
  #include "ast_to_hir/Split_multiple_arguments.h"
  #include "ast_to_hir/Split_unset_isset.h"
  #include "ast_to_hir/Strip_comments.h"
-#include "ast_to_hir/Translate_empty.h"
  #include "cmdline.h"
  #include "codegen/Clarify.h"
  #include "codegen/Compile_C.h"
@@ -137,7 +136,6 @@
  	pm->add_ast_transform (new Split_multiple_arguments (), s("sma"),  
s("Split multiple arguments for globals, attributes and static  
declarations"));
  	pm->add_ast_transform (new Split_unset_isset (), s("sui"), s("Split  
unset() and isset() into multiple calls with one argument each"));
  	pm->add_ast_transform (new Echo_split (), s("ecs"), s("Split echo() into  
multiple calls with one argument each"));
-	pm->add_ast_transform (new Translate_empty (), s("empty"), s("Translate  
calls to empty() into casts"));

  	pm->add_ast_transform (new Early_lower_control_flow (), s("elcf"),  
s("Early Lower Control Flow - lower for, while, do and switch  
statements")); // AST
  	pm->add_ast_transform (new Lower_expr_flow (), s("lef"), s("Lower  
Expression Flow - Lower ||, && and ?: expressions"));

Modified: trunk/test/subjects/parsing/empty.php
==============================================================================
--- trunk/test/subjects/parsing/empty.php	(original)
+++ trunk/test/subjects/parsing/empty.php	Thu Sep  4 05:31:51 2008
@@ -4,5 +4,18 @@
  {
  	echo "x is empty";
  }
+else
+	echo "x is not empty";
+
+$x = 7;
+
+if( empty($x) )
+{
+	echo "x is empty";
+}
+else
+	echo "x is not empty";
+
+

  ?>


More information about the phc-internals mailing list