diff --git a/Docker/dev/ubuntu-16.04/Dockerfile b/Docker/dev/ubuntu-16.04/Dockerfile index 64c5743..971b59c 100755 --- a/Docker/dev/ubuntu-16.04/Dockerfile +++ b/Docker/dev/ubuntu-16.04/Dockerfile @@ -4,6 +4,10 @@ RUN mkdir compiler && \ apt-get update && \ apt-get -y install git build-essential gdb llvm-4.0-dev clang-4.0 unzip curl libcurl4-openssl-dev autoconf libssl-dev libgd-dev libzip-dev bison re2c libxml2-dev libsqlite3-dev libonig-dev vim clang + +RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ + apt-get -y install nodejs + RUN curl -L https://github.com/php/php-src/archive/PHP-7.4.zip -o PHP-7.4.zip && unzip PHP-7.4.zip && mv php-src-PHP-7.4 php WORKDIR php diff --git a/Docker/dev/ubuntu-18.04/Dockerfile b/Docker/dev/ubuntu-18.04/Dockerfile index e643538..a0722cd 100755 --- a/Docker/dev/ubuntu-18.04/Dockerfile +++ b/Docker/dev/ubuntu-18.04/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:18.04 RUN mkdir compiler && \ apt-get update && \ - apt-get -y install git build-essential gdb llvm-4.0-dev clang-4.0 unzip curl libcurl4-openssl-dev autoconf libssl-dev libgd-dev libzip-dev bison re2c libxml2-dev libsqlite3-dev libonig-dev vim clang + apt-get -y install git build-essential gdb llvm-4.0-dev clang-4.0 unzip curl libcurl4-openssl-dev autoconf libssl-dev libgd-dev libzip-dev bison re2c libxml2-dev libsqlite3-dev libonig-dev vim clang nodejs RUN curl -L https://github.com/php/php-src/archive/PHP-7.4.zip -o PHP-7.4.zip && unzip PHP-7.4.zip && mv php-src-PHP-7.4 php diff --git a/Makefile b/Makefile index ab3250c..ca6879a 100755 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ .PHONY: composer-install composer-install: docker run -v $(shell pwd):/compiler ircmaxell/php-compiler:16.04-dev composer install --no-ansi --no-interaction --no-progress - docker run -v $(shell pwd):/compiler ircmaxell/php-compiler:16.04-dev php vendor/pre/plugin/source/environment.php - docker run -v $(shell pwd):/compiler --entrypoint "/usr/bin/patch" ircmaxell/php-compiler:16.04-dev -p0 -d /compiler/vendor/pre/plugin/hidden/vendor/yay/yay/src -i /compiler/Docker/yaypatch.patch + #docker run -v $(shell pwd):/compiler ircmaxell/php-compiler:16.04-dev php vendor/pre/plugin/source/environment.php + #docker run -v $(shell pwd):/compiler --entrypoint "/usr/bin/patch" ircmaxell/php-compiler:16.04-dev -p0 -d /compiler/vendor/pre/plugin/hidden/vendor/yay/yay/src -i /compiler/Docker/yaypatch.patch .PHONY: composer-update composer-update: diff --git a/composer.json b/composer.json index c79dc38..d89fd82 100755 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require-dev": { "phpunit/phpunit": "^8.0", "friendsofphp/php-cs-fixer": "*", - "pre/plugin": "dev-master", + "pre/plugin": "dev-develop", "phan/phan": "dev-master" }, "minimum-stability": "dev", diff --git a/composer.lock b/composer.lock index 47ab75d..6705096 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b32fcadf0267ff6cdafcf5a56684d414", + "content-hash": "39a321e29f08a3979152c465bf621f3d", "packages": [ { "name": "ircmaxell/php-cfg", @@ -602,12 +602,12 @@ "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "e9d66a580baf74a19c72b0457db5329a193f313c" + "reference": "c12abbc052b9378c251914b027c0c712e2b63885" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/e9d66a580baf74a19c72b0457db5329a193f313c", - "reference": "e9d66a580baf74a19c72b0457db5329a193f313c", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c12abbc052b9378c251914b027c0c712e2b63885", + "reference": "c12abbc052b9378c251914b027c0c712e2b63885", "shasum": "" }, "require": { @@ -687,7 +687,7 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2019-04-15T09:15:25+00:00" + "time": "2019-04-17T10:18:10+00:00" }, { "name": "microsoft/tolerant-php-parser", @@ -868,12 +868,12 @@ "source": { "type": "git", "url": "https://github.com/phan/phan.git", - "reference": "72ea5937c5ecf4daf1e528ec584fe4738b33f2b3" + "reference": "bf2e5409fbac6a5dc7a6162d8de0ac183f13a962" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phan/phan/zipball/72ea5937c5ecf4daf1e528ec584fe4738b33f2b3", - "reference": "72ea5937c5ecf4daf1e528ec584fe4738b33f2b3", + "url": "https://api.github.com/repos/phan/phan/zipball/bf2e5409fbac6a5dc7a6162d8de0ac183f13a962", + "reference": "bf2e5409fbac6a5dc7a6162d8de0ac183f13a962", "shasum": "" }, "require": { @@ -929,7 +929,7 @@ "php", "static" ], - "time": "2019-04-15T18:03:11+00:00" + "time": "2019-04-16T23:45:21+00:00" }, { "name": "phar-io/manifest", @@ -1635,24 +1635,25 @@ }, { "name": "pre/plugin", - "version": "dev-master", + "version": "dev-develop", "source": { "type": "git", "url": "https://github.com/preprocess/pre-plugin.git", - "reference": "f58a4ed8ccb664b4932a97cd62355dc67da92c52" + "reference": "37a67e6b34317ac7c15dbcafe28d2c382e203137" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/preprocess/pre-plugin/zipball/f58a4ed8ccb664b4932a97cd62355dc67da92c52", - "reference": "f58a4ed8ccb664b4932a97cd62355dc67da92c52", + "url": "https://api.github.com/repos/preprocess/pre-plugin/zipball/37a67e6b34317ac7c15dbcafe28d2c382e203137", + "reference": "37a67e6b34317ac7c15dbcafe28d2c382e203137", "shasum": "" }, "require": { - "composer-plugin-api": "^1.1" + "composer-plugin-api": "^1.1", + "yay/yay": "^0.7.0" }, "require-dev": { "composer/composer": "^1.3", - "phpunit/phpunit": "^5.0|^6.0" + "phpunit/phpunit": "^5.0|^6.0|^7.0" }, "type": "composer-plugin", "extra": { @@ -1665,9 +1666,6 @@ "Pre\\Plugin\\": "source" }, "files": [ - "source/environment.php", - "source/expanders.php", - "source/parsers.php", "source/functions.php", "source/autoload.php", "source/macros.php" @@ -1677,7 +1675,7 @@ "license": [ "MIT" ], - "time": "2019-04-10T05:28:01+00:00" + "time": "2019-04-17T07:01:59+00:00" }, { "name": "psr/log", @@ -3201,6 +3199,64 @@ "validate" ], "time": "2018-12-25T11:19:39+00:00" + }, + { + "name": "yay/yay", + "version": "0.7.0", + "source": { + "type": "git", + "url": "https://github.com/marcioAlmada/yay.git", + "reference": "277f52cf44d78e677cc7dadd1aa48d54cfe9d272" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/marcioAlmada/yay/zipball/277f52cf44d78e677cc7dadd1aa48d54cfe9d272", + "reference": "277f52cf44d78e677cc7dadd1aa48d54cfe9d272", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "ext-tokenizer": "*", + "nikic/php-parser": "^2.1|^3.0|^4.0", + "php": "7.*" + }, + "require-dev": { + "phpbench/phpbench": "@dev", + "phpunit/phpunit": "~6.5" + }, + "bin": [ + "bin/yay", + "bin/yay-pretty" + ], + "type": "library", + "autoload": { + "files": [ + "src/parsers.php", + "src/parsers_internal.php", + "src/expanders.php" + ], + "psr-4": { + "Yay\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márcio Almada", + "email": "marcio3w@gmail.com", + "homepage": "https://github.com/marcioAlmada" + } + ], + "description": "A high level PHP Pre-Processor", + "keywords": [ + "language", + "pre-processor", + "syntax" + ], + "time": "2018-06-26T11:52:57+00:00" } ], "aliases": [], diff --git a/src/macros.yay b/src/macros.yay index 6d36369..d2c060f 100755 --- a/src/macros.yay +++ b/src/macros.yay @@ -190,7 +190,6 @@ $(macro :unsafe :recursive) { } } >> { $(stmts ... { - $$(trim { $(assignop ? ... { $(nullcheck ? ... { @@ -321,19 +320,19 @@ $(macro :unsafe :recursive) { }) }) - $(binary_and ? ... { + $(binary_and ? { $(result) = $this->context->builder->bitwiseAnd($(binary_left), $__right); }) - $(binary_or ? ... { + $(binary_or ? { $(result) = $this->context->builder->bitwiseOr($(binary_left), $__right); }) - $(binary_xor ? ... { + $(binary_xor ? { $(result) = $this->context->builder->bitwiseXor($(binary_left), $__right); }) - $(binary_add ? ... { + $(binary_add ? { $(unsigned ? { $(result) = $this->context->builder->addNoUnsignedWrap($(binary_left), $__right); }) @@ -342,7 +341,7 @@ $(macro :unsafe :recursive) { }) }) - $(binary_sub ? ... { + $(binary_sub ? { $(unsigned ? { $(result) = $this->context->builder->subNoUnsignedWrap($(binary_left), $__right); }) @@ -351,7 +350,7 @@ $(macro :unsafe :recursive) { }) }) - $(binary_mul ? ... { + $(binary_mul ? { $(unsigned ? { $(result) = $this->context->builder->mulNoUnsignedWrap($(binary_left), $__right); }) @@ -360,7 +359,7 @@ $(macro :unsafe :recursive) { }) }) - $(binary_div ? ... { + $(binary_div ? { $(unsigned ? { $(result) = $this->context->builder->unsignedDiv($(binary_left), $__right); }) @@ -369,7 +368,7 @@ $(macro :unsafe :recursive) { }) }) - $(binary_mod ? ... { + $(binary_mod ? { $(unsigned ? { $(result) = $this->context->builder->unsignedRem($(binary_left), $__right); }) @@ -378,7 +377,7 @@ $(macro :unsafe :recursive) { }) }) - $(binary_smaller ? ... { + $(binary_smaller ? { $(unsigned ? { $cmp = PHPLLVM\Builder::INT_ULT; }) @@ -388,7 +387,7 @@ $(macro :unsafe :recursive) { $(result) = $this->context->builder->icmp($cmp, $(binary_left), $__right); }) - $(binary_smaller_equal ? ... { + $(binary_smaller_equal ? { $(unsigned ? { $cmp = PHPLLVM\Builder::INT_ULE; }) @@ -398,7 +397,7 @@ $(macro :unsafe :recursive) { $(result) = $this->context->builder->icmp($cmp, $(binary_left), $__right); }) - $(binary_greater ? ... { + $(binary_greater ? { $(unsigned ? { $cmp = PHPLLVM\Builder::INT_UGT; }) @@ -408,7 +407,7 @@ $(macro :unsafe :recursive) { $(result) = $this->context->builder->icmp($cmp, $(binary_left), $__right); }) - $(binary_greater_equal ? ... { + $(binary_greater_equal ? { $(unsigned ? { $cmp = PHPLLVM\Builder::INT_UGE; }) @@ -418,11 +417,11 @@ $(macro :unsafe :recursive) { $(result) = $this->context->builder->icmp($cmp, $(binary_left), $__right); }) - $(binary_equals ? ... { + $(binary_equals ? { $(result) = $this->context->builder->icmp(PHPLLVM\Builder::INT_EQ, $(binary_left), $__right); }) - $(binary_not_equal ? ... { + $(binary_not_equal ? { $(result) = $this->context->builder->icmp(PHPLLVM\Builder::INT_NE, $(binary_left), $__right); }) }) @@ -708,6 +707,5 @@ $(macro :unsafe :recursive) { ); }) - }) }) } diff --git a/test/bin/macro_compile.php b/test/bin/macro_compile.php old mode 100644 new mode 100755 index e233121..46be26c --- a/test/bin/macro_compile.php +++ b/test/bin/macro_compile.php @@ -9,44 +9,13 @@ * @license MIT See LICENSE at the root of the project for more info */ -namespace Pre\Plugin { - function defer($code) - { - $hidden = find('hidden/vendor/autoload.php'); - $visible = find('autoload.php'); - if (! $visible) { - // the plugin is being used/tested directly - $visible = __DIR__.'/../vendor/autoload.php'; - } - $defer = " - namespace Yay { - /** - * Abusing namespaces to make Cycle->id() predictable during tests only! - */ - function md5(\$foo) { return (string) \$foo; } - } - namespace { - require '{$hidden}'; - require '{$visible}'; - \$function = function() { - {$code}; - }; - print base64_encode(gzencode(\$function())); - } - "; - $result = exec( - escapeshellcmd(\PHP_BINARY)." -r 'eval(base64_decode(\"".base64_encode($defer)."\"));'", - $output - ); - - $value = @gzdecode(base64_decode($result, true)); - if (! $value) { - throw new \LogicException("Test failed due to: \n".implode("\n", $output)); - } - - return $value; - } +namespace Yay { + /** + * Abusing namespaces to make Cycle->id() predictable during tests only! + */ + function md5($foo) { return (string) $foo; } } + namespace { require __DIR__.'/../../vendor/autoload.php';