Skip to content

Commit 5036922

Browse files
committed
Ensure we do not create goto labels with a "-" inside
1 parent 1f4dd65 commit 5036922

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/main/php/lang/ast/emit/PHP56.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function returnType($name) {
3535

3636
protected function catches($catch) {
3737
$last= array_pop($catch[0]);
38-
$label= 'c'.crc32($last);
38+
$label= sprintf('c%u', crc32($last));
3939
foreach ($catch[0] as $type) {
4040
$this->out->write('catch('.$type.' $'.$catch[1].') { goto '.$label.'; }');
4141
}

src/main/php/lang/ast/emit/PHP70.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function returnType($name) {
3131

3232
protected function catches($catch) {
3333
$last= array_pop($catch[0]);
34-
$label= 'c'.crc32($last);
34+
$label= sprintf('c%u', crc32($last));
3535
foreach ($catch[0] as $type) {
3636
$this->out->write('catch('.$type.' $'.$catch[1].') { goto '.$label.'; }');
3737
}

src/test/php/lang/ast/unittest/emit/EmittingTest.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function type($code) {
3030
$out= new MemoryOutputStream();
3131
$emit= Emitter::forRuntime(PHP_VERSION)->newInstance(new StringWriter($out));
3232
$emit->emit($parse->execute());
33-
33+
// var_dump($out->getBytes());
3434
self::$cl->setClassBytes($name, $out->getBytes());
3535
return self::$cl->loadClass($name);
3636
}

0 commit comments

Comments
 (0)