HPHP/XHP: always pass file/line into XHP constructors

Esse commit está contido em:
Kyle Delong
2013-07-24 16:49:53 -07:00
commit de Sara Golemon
commit 70e0cf3568
25 arquivos alterados com 1099 adições e 838 exclusões
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+5 -4
Ver Arquivo
@@ -3,14 +3,15 @@
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
+5 -4
Ver Arquivo
@@ -3,14 +3,15 @@
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
+5 -4
Ver Arquivo
@@ -3,14 +3,15 @@
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
+5 -4
Ver Arquivo
@@ -3,14 +3,15 @@
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
+5 -4
Ver Arquivo
@@ -3,14 +3,15 @@
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
+1
Ver Arquivo
@@ -3,6 +3,7 @@
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+1
Ver Arquivo
@@ -3,6 +3,7 @@
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+14 -14
Ver Arquivo
@@ -389,41 +389,41 @@ bool TestParserExpr::TestClosure() {
bool TestParserExpr::TestXHP() {
// basics
V("<?php $x = <thing />;",
"$x = new xhp_thing(array(), array());\n");
"$x = new xhp_thing(array(), array(), __FILE__, __LINE__);\n");
// white spaces
V("<?php $x = <x> a{ 'b' }c </x>;",
"$x = new xhp_x(array(), array(' a', 'b', 'c '));\n");
"$x = new xhp_x(array(), array(' a', 'b', 'c '), __FILE__, __LINE__);\n");
V("<?php $x = <x> a { 'b' } c </x>;",
"$x = new xhp_x(array(), array(' a ', 'b', ' c '));\n");
"$x = new xhp_x(array(), array(' a ', 'b', ' c '), __FILE__, __LINE__);\n");
V("<?php $x = <x>\n foo\n </x>;",
"$x = new xhp_x(array(), array(' foo '));\n");
"$x = new xhp_x(array(), array(' foo '), __FILE__, __LINE__);\n");
V("<?php $x = <x>\n foo\n bar\n </x>;",
"$x = new xhp_x(array(), array(' foo bar '));\n");
"$x = new xhp_x(array(), array(' foo bar '), __FILE__, __LINE__);\n");
// attributes
V("<?php $x = <x:y attr={:tag::CONSTANT} />;",
"$x = new xhp_x__y(array('attr' => xhp_tag::CONSTANT), array());\n");
"$x = new xhp_x__y(array('attr' => xhp_tag::CONSTANT), array(), __FILE__, __LINE__);\n");
V("<?php $x = <a b=\"&nbsp;\">c</a>;",
"$x = new xhp_a(array('b' => '\xC2\xA0'), array('c'));\n");
"$x = new xhp_a(array('b' => '\xC2\xA0'), array('c'), __FILE__, __LINE__);\n");
V("<?php $x = <a b=\"\" />;",
"$x = new xhp_a(array('b' => ''), array());\n");
"$x = new xhp_a(array('b' => ''), array(), __FILE__, __LINE__);\n");
// children
V("<?php $x = <x> <x /> {'a'} </x>;",
"$x = new xhp_x(array(), array(new xhp_x(array(), array()), 'a'));\n");
"$x = new xhp_x(array(), array(new xhp_x(array(), array(), __FILE__, __LINE__), 'a'), __FILE__, __LINE__);\n");
V("<?php $x = <x> {'a'}<x /></x>;",
"$x = new xhp_x(array(), array('a', new xhp_x(array(), array())));");
"$x = new xhp_x(array(), array('a', new xhp_x(array(), array(), __FILE__, __LINE__)), __FILE__, __LINE__);");
V("<?php $x = <x>\n<x>\n</x>.\n</x>;",
"$x = new xhp_x(array(), array(new xhp_x(array(), array()), '. '));\n");
"$x = new xhp_x(array(), array(new xhp_x(array(), array(), __FILE__, __LINE__), '. '), __FILE__, __LINE__);\n");
V("<?php <div><a />=<a /></div>;",
"new xhp_div(array(), array(new xhp_a(array(), array()), '=', "
"new xhp_a(array(), array())));\n");
"new xhp_div(array(), array(new xhp_a(array(), array(), __FILE__, __LINE__), '=', "
"new xhp_a(array(), array(), __FILE__, __LINE__)), __FILE__, __LINE__);\n");
// closing tag
V("<?php $x = <a><a><a>hi</a></></a>;",
"$x = new xhp_a(array(), array(new xhp_a(array(), "
"array(new xhp_a(array(), array('hi'))))));\n");
"array(new xhp_a(array(), array('hi'), __FILE__, __LINE__)), __FILE__, __LINE__)), __FILE__, __LINE__);\n");
// class name with PHP keyword
V("<?php class :a:b:switch-links { }",
+22
Ver Arquivo
@@ -0,0 +1,22 @@
<?php
class :xhp {
public function __construct($attributes, $children, $file=null, $line=null) {
$assert = function($cond) {
if (!$cond) {
throw new Exception('fail');
}
};
$assert(is_array($attributes));
$assert(is_array($children));
$assert($file === __FILE__);
$assert($line === $attributes['line']);
}
}
<xhp line={__LINE__} />;
<xhp line={__LINE__}>text</xhp>;
<xhp line={__LINE__} some-attr="value" />;
<xhp line={__LINE__} attr1="one" a2={2}>text</xhp>;
echo "pass\n";
+1
Ver Arquivo
@@ -0,0 +1 @@
pass
+19 -1
Ver Arquivo
@@ -125,6 +125,16 @@ static void scalar_null(Parser *_p, Token &out) {
_p->onConstantValue(out, tnull);
}
static void scalar_file(Parser *_p, Token &out) {
Token file; file.setText("__FILE__");
_p->onScalar(out, T_FILE, file);
}
static void scalar_line(Parser *_p, Token &out) {
Token line; line.setText("__LINE__");
_p->onScalar(out, T_LINE, line);
}
///////////////////////////////////////////////////////////////////////////////
// converting constant declartion to "define(name, value);"
@@ -1791,15 +1801,23 @@ xhp_tag:
xhp_tag_body:
xhp_attributes '/' { Token t1; _p->onArray(t1,$1);
Token t2; _p->onArray(t2,$2);
Token file; scalar_file(_p, file);
Token line; scalar_line(_p, line);
_p->onCallParam($1,NULL,t1,0);
_p->onCallParam($$, &$1,t2,0);
_p->onCallParam($1, &$1,file,0);
_p->onCallParam($1, &$1,line,0);
$$.setText("");}
| xhp_attributes T_XHP_TAG_GT
xhp_children T_XHP_TAG_LT '/'
xhp_opt_end_label { _p->onArray($4,$1);
xhp_opt_end_label { Token file; scalar_file(_p, file);
Token line; scalar_line(_p, line);
_p->onArray($4,$1);
_p->onArray($5,$3);
_p->onCallParam($2,NULL,$4,0);
_p->onCallParam($$, &$2,$5,0);
_p->onCallParam($2, &$2,file,0);
_p->onCallParam($2, &$2,line,0);
$$.setText($6.text());}
;
xhp_opt_end_label:
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//
+15
Ver Arquivo
@@ -1,3 +1,18 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
// Copyright 2013, ARM Limited
// All rights reserved.
//