[phc-internals] [phc] r3394 committed - Fix missing functions when php-embed is not available. This fixes a bu...
phc at googlecode.com
phc at googlecode.com
Tue Oct 26 14:18:04 IST 2010
Revision: 3394
Author: paul.biggar
Date: Tue Oct 26 06:17:27 2010
Log: Fix missing functions when php-embed is not available. This fixes a
bug reported in issue 119 and 130.
While I was there, I removed some unused functions, and refactored
Clarify.cpp and embed.cpp to have the list of superglobals in the right
place.
http://code.google.com/p/phc/source/detail?r=3394
Modified:
/trunk/src/codegen/Clarify.cpp
/trunk/src/embed/embed.cpp
/trunk/src/embed/embed.h
/trunk/src/embed/optimize.cpp
=======================================
--- /trunk/src/codegen/Clarify.cpp Fri Sep 3 06:20:56 2010
+++ /trunk/src/codegen/Clarify.cpp Tue Oct 26 06:17:27 2010
@@ -7,23 +7,10 @@
#include "Clarify.h"
#include "process_ir/General.h"
+#include "embed/embed.h"
using namespace MIR;
-// TODO: deal with all superglobals
-// TODO: _ENV
-// TODO: HTTP_ENV_VARS
-// TODO: _POST
-// TODO: HTTP_POST_VARS
-// TODO: _GET
-// TODO: HTTP_GET_VARS
-// TODO: _COOKIE
-// TODO: HTTP_COOKIE_VARS
-// TODO: _FILES
-// TODO: HTTP_POST_FILES
-// TODO: _REQUEST
-
-
void Clarify::post_method (MIR::Method* in)
{
// abstract method
@@ -34,23 +21,9 @@
if (*in->signature->method_name->value == "__MAIN__")
return;
- String_list* var_names = new String_list;
- var_names->push_back (s("GLOBALS"));
- var_names->push_back (s("_ENV"));
- var_names->push_back (s("HTTP_ENV_VARS"));
- var_names->push_back (s("_POST"));
- var_names->push_back (s("HTTP_POST_VARS"));
- var_names->push_back (s("_GET"));
- var_names->push_back (s("HTTP_GET_VARS"));
- var_names->push_back (s("_COOKIE"));
- var_names->push_back (s("HTTP_COOKIE_VARS"));
- var_names->push_back (s("_FILES"));
- var_names->push_back (s("HTTP_FILES_VARS"));
- var_names->push_back (s("_REQUEST"));
- var_names->push_back (s("HTTP_REQUEST_VARS"));
- foreach (String *s, *var_names)
- {
- Global* glob = new Global (new VARIABLE_NAME (s));
+ foreach (VARIABLE_NAME* var_name, *PHP::get_superglobals())
+ {
+ Global* glob = new Global (var_name);
glob->attrs->set_true ("phc.optimize.is_super_global");
in->statements->push_front (glob);
}
=======================================
--- /trunk/src/embed/embed.cpp Thu Aug 6 05:44:54 2009
+++ /trunk/src/embed/embed.cpp Tue Oct 26 06:17:27 2010
@@ -246,20 +246,6 @@
return result;
}
-
-MIR::VARIABLE_NAME_list*
-PHP::get_initial_vars ()
-{
- phc_TODO ();
-}
-
-// Is IV known to be an array of strings.
-bool
-PHP::is_initial_var_string_array (MIR::VARIABLE_NAME* iv)
-{
- phc_TODO ();
-}
-
#else
@@ -405,6 +391,34 @@
{
return new String;
}
+
+MIR::VARIABLE_NAME_list*
+PHP::get_superglobals ()
+{
+ MIR::VARIABLE_NAME_list* result = new MIR::VARIABLE_NAME_list;
+
+ String_list* var_names = new String_list;
+ var_names->push_back (s("GLOBALS"));
+ var_names->push_back (s("_ENV"));
+ var_names->push_back (s("HTTP_ENV_VARS"));
+ var_names->push_back (s("_POST"));
+ var_names->push_back (s("HTTP_POST_VARS"));
+ var_names->push_back (s("_GET"));
+ var_names->push_back (s("HTTP_GET_VARS"));
+ var_names->push_back (s("_COOKIE"));
+ var_names->push_back (s("HTTP_COOKIE_VARS"));
+ var_names->push_back (s("_FILES"));
+ var_names->push_back (s("HTTP_FILES_VARS"));
+ var_names->push_back (s("_REQUEST"));
+ var_names->push_back (s("HTTP_REQUEST_VARS"));
+
+ foreach (String *s, *var_names)
+ {
+ result->push_back (new MIR::VARIABLE_NAME (s));
+ }
+
+ return result;
+}
#endif
@@ -430,5 +444,3 @@
// TODO: assert absolute filename
included.insert (*filename);
}
-
-
=======================================
--- /trunk/src/embed/embed.h Mon Jun 8 07:59:24 2009
+++ /trunk/src/embed/embed.h Tue Oct 26 06:17:27 2010
@@ -74,10 +74,6 @@
/* Superglobals */
static MIR::VARIABLE_NAME_list* get_superglobals ();
- static MIR::VARIABLE_NAME_list* get_initial_vars ();
-
- // Is the superglobal an array of strings.
- static bool is_initial_var_string_array (MIR::VARIABLE_NAME* sg);
/*
* Optimization (defined in optimize.cpp)
=======================================
--- /trunk/src/embed/optimize.cpp Tue Jul 14 14:39:09 2009
+++ /trunk/src/embed/optimize.cpp Tue Oct 26 06:17:27 2010
@@ -23,6 +23,7 @@
FAIL (Literal* PHP::fold_unary_op (OP*, Literal*))
FAIL (bool PHP::is_true (Literal*));
FAIL (Literal* PHP::cast_to (CAST*, Literal*))
+FAIL (String* PHP::get_string_value (Literal* lit))
FAIL (Literal* PHP::fold_bin_op (Literal* left, OP* op, Literal* right))
FAIL (Literal* PHP::fold_pre_op (Literal* use, OP* op))
FAIL (Literal* PHP::fold_constant (Constant* in))
More information about the phc-internals
mailing list