Skip to content

Commit

Permalink
Update to branched version of pre, install node, and fix build to pro…
Browse files Browse the repository at this point in the history
…perly use both
  • Loading branch information
ircmaxell committed Apr 17, 2019
1 parent 57a371e commit 7f5e48b
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 76 deletions.
4 changes: 4 additions & 0 deletions Docker/dev/ubuntu-16.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Docker/dev/ubuntu-18.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
94 changes: 75 additions & 19 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 14 additions & 16 deletions src/macros.yay
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ $(macro :unsafe :recursive) {
}
} >> {
$(stmts ... {
$$(trim {

$(assignop ? ... {
$(nullcheck ? ... {
Expand Down Expand Up @@ -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);
})
Expand All @@ -342,7 +341,7 @@ $(macro :unsafe :recursive) {
})
})

$(binary_sub ? ... {
$(binary_sub ? {
$(unsigned ? {
$(result) = $this->context->builder->subNoUnsignedWrap($(binary_left), $__right);
})
Expand All @@ -351,7 +350,7 @@ $(macro :unsafe :recursive) {
})
})

$(binary_mul ? ... {
$(binary_mul ? {
$(unsigned ? {
$(result) = $this->context->builder->mulNoUnsignedWrap($(binary_left), $__right);
})
Expand All @@ -360,7 +359,7 @@ $(macro :unsafe :recursive) {
})
})

$(binary_div ? ... {
$(binary_div ? {
$(unsigned ? {
$(result) = $this->context->builder->unsignedDiv($(binary_left), $__right);
})
Expand All @@ -369,7 +368,7 @@ $(macro :unsafe :recursive) {
})
})

$(binary_mod ? ... {
$(binary_mod ? {
$(unsigned ? {
$(result) = $this->context->builder->unsignedRem($(binary_left), $__right);
})
Expand All @@ -378,7 +377,7 @@ $(macro :unsafe :recursive) {
})
})

$(binary_smaller ? ... {
$(binary_smaller ? {
$(unsigned ? {
$cmp = PHPLLVM\Builder::INT_ULT;
})
Expand All @@ -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;
})
Expand All @@ -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;
})
Expand All @@ -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;
})
Expand All @@ -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);
})
})
Expand Down Expand Up @@ -708,6 +707,5 @@ $(macro :unsafe :recursive) {
);
})

})
})
}
43 changes: 6 additions & 37 deletions test/bin/macro_compile.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit 7f5e48b

Please sign in to comment.