Skip to content

Commit 79d365a

Browse files
driusanircmaxell
authored andcommitted
Add include OpCode
This adds an OpCode to emit when encontering a PHPCfg\Expr\Include_ in compile. Support for it isn't included in the VM, JIT, or AOT, but at least it allows bin/print.php to handle files that have an include statement without throwing an exception while trying to generate the OpCodes. Fixes #62.
1 parent 69e8aa8 commit 79d365a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/Compiler.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@ protected function compileExpr(Op\Expr $expr, Block $block): array {
496496
);
497497
}
498498
return $return;
499+
case Op\Expr\Include_::class:
500+
return [new OpCode(
501+
OpCode::TYPE_INCLUDE,
502+
$this->compileOperand($expr->expr, $block, true),
503+
)];
499504
}
500505
throw new \LogicException("Unsupported expression: " . $expr->getType());
501506
}

lib/OpCode.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class OpCode {
6565
const TYPE_INIT_ARRAY = 53;
6666
const TYPE_ADD_ARRAY_ELEMENT = 54;
6767
const TYPE_STATICCALL_INIT = 55;
68+
const TYPE_INCLUDE = 56;
6869

6970
public int $type;
7071
public ?int $arg1;
@@ -89,4 +90,4 @@ public function getType(): string {
8990
}
9091
return 'unknown opcode';
9192
}
92-
}
93+
}

0 commit comments

Comments
 (0)