File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
src/Compiler/Builder/Generator/Operation Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 22declare (strict_types=1 );
33namespace PHPJava \Compiler \Builder \Generator \Operation ;
44
5+ use PHPJava \Compiler \Builder \Finder \Result \ConstantPoolFinderResult ;
6+ use PHPJava \Compiler \Builder \Types \Int16 ;
7+ use PHPJava \Compiler \Builder \Types \Int32 ;
8+ use PHPJava \Compiler \Builder \Types \Int8 ;
9+ use PHPJava \Compiler \Builder \Types \Uint16 ;
10+ use PHPJava \Compiler \Builder \Types \Uint32 ;
11+ use PHPJava \Compiler \Builder \Types \Uint8 ;
12+ use PHPJava \Exceptions \AssembleStructureException ;
13+
514class Operand
615{
716 protected $ type ;
817 protected $ value ;
918
1019 public static function factory (string $ type , $ value ): self
1120 {
21+ if (!in_array (
22+ $ type ,
23+ [
24+ Uint8::class,
25+ Uint16::class,
26+ Uint32::class,
27+ Int8::class,
28+ Int16::class,
29+ Int32::class,
30+ ],
31+ true
32+ )) {
33+ throw new AssembleStructureException (
34+ 'Invalid class type: ' . $ type
35+ );
36+ }
37+ if (!($ value instanceof ConstantPoolFinderResult)
38+ && !is_int ($ value )
39+ ) {
40+ throw new AssembleStructureException (
41+ 'Passed parameter is not initiated a ConstantPoolFinderResult '
42+ );
43+ }
1244 $ scopedValue = $ value ;
1345 return new static ($ type , $ scopedValue );
1446 }
You can’t perform that action at this time.
0 commit comments