1 /*
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
47 import jdk.test.lib.jittester.StaticMemberVariable;
48 import jdk.test.lib.jittester.Switch;
49 import jdk.test.lib.jittester.Symbol;
50 import jdk.test.lib.jittester.TernaryOperator;
51 import jdk.test.lib.jittester.Throw;
52 import jdk.test.lib.jittester.TryCatchBlock;
53 import jdk.test.lib.jittester.Type;
54 import jdk.test.lib.jittester.TypeList;
55 import jdk.test.lib.jittester.UnaryOperator;
56 import jdk.test.lib.jittester.VariableBase;
57 import jdk.test.lib.jittester.VariableDeclaration;
58 import jdk.test.lib.jittester.VariableDeclarationBlock;
59 import jdk.test.lib.jittester.VariableInitialization;
60 import jdk.test.lib.jittester.arrays.ArrayCreation;
61 import jdk.test.lib.jittester.arrays.ArrayElement;
62 import jdk.test.lib.jittester.arrays.ArrayExtraction;
63 import jdk.test.lib.jittester.classes.ClassDefinitionBlock;
64 import jdk.test.lib.jittester.classes.Interface;
65 import jdk.test.lib.jittester.classes.Klass;
66 import jdk.test.lib.jittester.classes.MainKlass;
67 import jdk.test.lib.jittester.functions.ArgumentDeclaration;
68 import jdk.test.lib.jittester.functions.ConstructorDefinition;
69 import jdk.test.lib.jittester.functions.ConstructorDefinitionBlock;
70 import jdk.test.lib.jittester.functions.Function;
71 import jdk.test.lib.jittester.functions.FunctionDeclaration;
72 import jdk.test.lib.jittester.functions.FunctionDeclarationBlock;
73 import jdk.test.lib.jittester.functions.FunctionDefinition;
74 import jdk.test.lib.jittester.functions.FunctionDefinitionBlock;
75 import jdk.test.lib.jittester.functions.FunctionInfo;
76 import jdk.test.lib.jittester.functions.FunctionRedefinition;
77 import jdk.test.lib.jittester.functions.FunctionRedefinitionBlock;
78 import jdk.test.lib.jittester.functions.Return;
79 import jdk.test.lib.jittester.functions.StaticConstructorDefinition;
80 import jdk.test.lib.jittester.loops.CounterInitializer;
81 import jdk.test.lib.jittester.loops.CounterManipulator;
82 import jdk.test.lib.jittester.loops.DoWhile;
83 import jdk.test.lib.jittester.loops.For;
84 import jdk.test.lib.jittester.loops.LoopingCondition;
85 import jdk.test.lib.jittester.loops.While;
86 import jdk.test.lib.jittester.types.TypeKlass;
93 private Optional<Integer> operatorLimit = Optional.empty();
94 private Optional<TypeKlass> ownerClass = Optional.empty();
95 private Optional<Type> resultType = Optional.empty();
96 private Optional<Boolean> safe = Optional.empty();
97 private Optional<Boolean> noConsts = Optional.empty();
98 private Optional<OperatorKind> opKind = Optional.empty();
99 private Optional<Integer> statementLimit = Optional.empty();
100 private Optional<Boolean> subBlock = Optional.empty();
101 private Optional<Boolean> canHaveBreaks = Optional.empty();
102 private Optional<Boolean> canHaveContinues = Optional.empty();
103 private Optional<Boolean> canHaveReturn = Optional.empty();
104 //not in use yet because 'throw' is only placed to the locations where 'return' is allowed
105 private Optional<Boolean> canHaveThrow = Optional.empty();
106 private Optional<Integer> level = Optional.empty();
107 private Optional<String> prefix = Optional.empty();
108 private Optional<Integer> memberFunctionsLimit = Optional.empty();
109 private Optional<Integer> memberFunctionsArgLimit = Optional.empty();
110 private Optional<LocalVariable> localVariable = Optional.empty();
111 private Optional<Boolean> isLocal = Optional.empty();
112 private Optional<Boolean> isStatic = Optional.empty();
113 private Optional<Boolean> isConstant = Optional.empty();
114 private Optional<Boolean> isInitialized = Optional.empty();
115 private Optional<String> name = Optional.empty();
116 private Optional<Integer> flags = Optional.empty();
117 private Optional<FunctionInfo> functionInfo = Optional.empty();
118 private Optional<Boolean> semicolon = Optional.empty();
119
120 public Factory<ArgumentDeclaration> getArgumentDeclarationFactory() {
121 return new ArgumentDeclarationFactory(getArgumentType(), getVariableNumber());
122 }
123
124 public Factory<Operator> getArithmeticOperatorFactory() throws ProductionFailedException {
125 return new ArithmeticOperatorFactory(getComplexityLimit(), getOperatorLimit(),
126 getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts());
127 }
128
129 public Factory<ArrayCreation> getArrayCreationFactory() {
130 return new ArrayCreationFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
131 getResultType(), getExceptionSafe(), getNoConsts());
132 }
291 getMemberFunctionsArgLimit(), getLevel());
292 }
293
294 public Factory<Continue> getContinueFactory() {
295 return new ContinueFactory();
296 }
297
298 public Factory<CounterInitializer> getCounterInitializerFactory(int counterValue) {
299 return new CounterInitializerFactory(getOwnerClass(), counterValue);
300 }
301
302 public Factory<CounterManipulator> getCounterManipulatorFactory() {
303 return new CounterManipulatorFactory(getLocalVariable());
304 }
305
306 public Factory<Declaration> getDeclarationFactory() {
307 return new DeclarationFactory(getOwnerClass(), getComplexityLimit(), getOperatorLimit(),
308 getIsLocal(), getExceptionSafe());
309 }
310
311 public Factory<DoWhile> getDoWhileFactory() {
312 return new DoWhileFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
313 getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn());
314 }
315
316 public Factory<While> getWhileFactory() {
317 return new WhileFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
318 getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn());
319 }
320
321 public Factory<If> getIfFactory() {
322 return new IfFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
323 getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveBreaks(),
324 getCanHaveContinues(), getCanHaveReturn());
325 }
326
327 public Factory<For> getForFactory() {
328 return new ForFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
329 getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn());
330 }
333 return new SwitchFactory(getOwnerClass(), getComplexityLimit(), getStatementLimit(),
334 getOperatorLimit(), getLevel(), getCanHaveReturn());
335 }
336
337 public Factory<IRNode> getExpressionFactory() throws ProductionFailedException {
338 return new ExpressionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
339 getResultType(), getExceptionSafe(), getNoConsts());
340 }
341
342 public Factory<FunctionDeclarationBlock> getFunctionDeclarationBlockFactory() {
343 return new FunctionDeclarationBlockFactory(getOwnerClass(), getMemberFunctionsLimit(),
344 getMemberFunctionsArgLimit(), getLevel());
345 }
346
347 public Factory<FunctionDeclaration> getFunctionDeclarationFactory() {
348 return new FunctionDeclarationFactory(getName(), getOwnerClass(),resultType.orElse(TypeList.VOID),
349 getMemberFunctionsArgLimit(), getFlags());
350 }
351
352 public Factory<FunctionDefinitionBlock> getFunctionDefinitionBlockFactory() {
353 return new FunctionDefinitionBlockFactory(getOwnerClass(), getMemberFunctionsLimit(),
354 getMemberFunctionsArgLimit(), getComplexityLimit(), getStatementLimit(),
355 getOperatorLimit(), getLevel(), getFlags());
356 }
357
358 public Factory<FunctionDefinition> getFunctionDefinitionFactory() {
359 return new FunctionDefinitionFactory(getName(), getOwnerClass(), resultType.orElse(TypeList.VOID),
360 getComplexityLimit(), getStatementLimit(), getOperatorLimit(),
361 getMemberFunctionsArgLimit(), getLevel(), getFlags());
362 }
363
364 public Factory<Function> getFunctionFactory() {
365 return new FunctionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
366 resultType.orElse(null), getExceptionSafe());
367 }
368
369 public Factory<FunctionRedefinitionBlock> getFunctionRedefinitionBlockFactory(Collection<Symbol>
370 functionSet) {
371 return new FunctionRedefinitionBlockFactory(functionSet, getOwnerClass(),
372 getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel());
373 }
374
375 public Factory<FunctionRedefinition> getFunctionRedefinitionFactory() {
376 return new FunctionRedefinitionFactory(getFunctionInfo(), getOwnerClass(),
377 getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel(),
378 getFlags());
379 }
380
381 public Factory<Interface> getInterfaceFactory() {
382 return new InterfaceFactory(getName(), getMemberFunctionsLimit(),
383 getMemberFunctionsArgLimit(), getLevel());
384 }
385
386 public Factory<Klass> getKlassFactory() {
387 return new KlassFactory(getName(), getComplexityLimit(),
388 getMemberFunctionsLimit(), getMemberFunctionsArgLimit(), getStatementLimit(),
389 getOperatorLimit(), getLevel());
390 }
391
392 public Factory<IRNode> getLimitedExpressionFactory() throws ProductionFailedException {
393 return new LimitedExpressionFactory(getComplexityLimit(), getOperatorLimit(),
394 getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts());
395 }
396
397 public Factory<Literal> getLiteralFactory() {
398 return new LiteralFactory(getResultType());
399 }
400
401 public Factory<LocalVariable> getLocalVariableFactory() {
402 return new LocalVariableFactory(/*getVariableType()*/getResultType(), getFlags());
403 }
404
405 public Factory<Operator> getLogicOperatorFactory() throws ProductionFailedException {
406 return new LogicOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
407 getResultType(), getExceptionSafe(), getNoConsts());
408 }
409
410 public Factory<LoopingCondition> getLoopingConditionFactory(Literal _limiter) {
411 return new LoopingConditionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
441
442 public Factory<StaticConstructorDefinition> getStaticConstructorDefinitionFactory() {
443 return new StaticConstructorDefinitionFactory(getOwnerClass(), getComplexityLimit(),
444 getStatementLimit(), getOperatorLimit(), getLevel());
445 }
446
447 public Factory<StaticMemberVariable> getStaticMemberVariableFactory() {
448 return new StaticMemberVariableFactory(getOwnerClass(), /*getVariableType()*/getResultType(), getFlags());
449 }
450
451 public Factory<TernaryOperator> getTernaryOperatorFactory() {
452 return new TernaryOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
453 getResultType(), getExceptionSafe(), getNoConsts());
454 }
455
456 public Factory<VariableDeclarationBlock> getVariableDeclarationBlockFactory() {
457 return new VariableDeclarationBlockFactory(getOwnerClass(), getComplexityLimit(),
458 getOperatorLimit(), getLevel(), getExceptionSafe());
459 }
460
461 public Factory<VariableDeclaration> getVariableDeclarationFactory() {
462 return new VariableDeclarationFactory(getOwnerClass(), getIsStatic(), getIsLocal(), getResultType());
463 }
464
465 public Factory<VariableBase> getVariableFactory() {
466 return new VariableFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
467 /*getVariableType()*/getResultType(), getIsConstant(), getIsInitialized(), getExceptionSafe(), getNoConsts());
468 }
469
470 public Factory<VariableInitialization> getVariableInitializationFactory() {
471 return new VariableInitializationFactory(getOwnerClass(), getIsConstant(), getIsStatic(),
472 getIsLocal(), getComplexityLimit(), getOperatorLimit(), getExceptionSafe());
473 }
474
475 public Factory<TryCatchBlock> getTryCatchBlockFactory() {
476 return new TryCatchBlockFactory(getOwnerClass(), getResultType(),
477 getComplexityLimit(), getStatementLimit(), getOperatorLimit(),
478 getLevel(), subBlock.orElse(false), getCanHaveBreaks(),
479 getCanHaveContinues(), getCanHaveReturn());
480 }
577 public IRNodeBuilder setMemberFunctionsArgLimit(int value) {
578 memberFunctionsArgLimit = Optional.of(value);
579 return this;
580 }
581
582 public IRNodeBuilder setLocalVariable(LocalVariable value) {
583 localVariable = Optional.of(value);
584 return this;
585 }
586
587 public IRNodeBuilder setIsLocal(boolean value) {
588 isLocal = Optional.of(value);
589 return this;
590 }
591
592 public IRNodeBuilder setIsStatic(boolean value) {
593 isStatic = Optional.of(value);
594 return this;
595 }
596
597 public IRNodeBuilder setIsInitialized(boolean value) {
598 isInitialized = Optional.of(value);
599 return this;
600 }
601
602 public IRNodeBuilder setIsConstant(boolean value) {
603 isConstant = Optional.of(value);
604 return this;
605 }
606
607 public IRNodeBuilder setName(String value) {
608 name = Optional.of(value);
609 return this;
610 }
611
612 public IRNodeBuilder setFlags(int value) {
613 flags = Optional.of(value);
614 return this;
615 }
616
689 }
690
691 private int getMemberFunctionsArgLimit() {
692 return memberFunctionsArgLimit.orElseThrow(() -> new IllegalArgumentException(
693 "memberFunctionsArg limit wasn't set"));
694 }
695
696 private LocalVariable getLocalVariable() {
697 return localVariable.orElseThrow(() -> new IllegalArgumentException(
698 "local variable wasn't set"));
699 }
700
701 private boolean getIsLocal() {
702 return isLocal.orElseThrow(() -> new IllegalArgumentException("isLocal wasn't set"));
703 }
704
705 private boolean getIsStatic() {
706 return isStatic.orElseThrow(() -> new IllegalArgumentException("isStatic wasn't set"));
707 }
708
709 private boolean getIsInitialized() {
710 return isInitialized.orElseThrow(() -> new IllegalArgumentException(
711 "isInitialized wasn't set"));
712 }
713
714 private boolean getIsConstant() {
715 return isConstant.orElseThrow(() -> new IllegalArgumentException("isConstant wasn't set"));
716 }
717
718 private boolean getCanHaveReturn() {
719 return canHaveReturn.orElseThrow(() -> new IllegalArgumentException(
720 "canHaveReturn wasn't set"));
721 }
722
723 private boolean getCanHaveBreaks() {
724 return canHaveBreaks.orElseThrow(() -> new IllegalArgumentException(
725 "canHaveBreaks wasn't set"));
726 }
727
728 private boolean getCanHaveContinues() {
|
1 /*
2 * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
47 import jdk.test.lib.jittester.StaticMemberVariable;
48 import jdk.test.lib.jittester.Switch;
49 import jdk.test.lib.jittester.Symbol;
50 import jdk.test.lib.jittester.TernaryOperator;
51 import jdk.test.lib.jittester.Throw;
52 import jdk.test.lib.jittester.TryCatchBlock;
53 import jdk.test.lib.jittester.Type;
54 import jdk.test.lib.jittester.TypeList;
55 import jdk.test.lib.jittester.UnaryOperator;
56 import jdk.test.lib.jittester.VariableBase;
57 import jdk.test.lib.jittester.VariableDeclaration;
58 import jdk.test.lib.jittester.VariableDeclarationBlock;
59 import jdk.test.lib.jittester.VariableInitialization;
60 import jdk.test.lib.jittester.arrays.ArrayCreation;
61 import jdk.test.lib.jittester.arrays.ArrayElement;
62 import jdk.test.lib.jittester.arrays.ArrayExtraction;
63 import jdk.test.lib.jittester.classes.ClassDefinitionBlock;
64 import jdk.test.lib.jittester.classes.Interface;
65 import jdk.test.lib.jittester.classes.Klass;
66 import jdk.test.lib.jittester.classes.MainKlass;
67 import jdk.test.lib.jittester.classes.ValueKlass;
68 import jdk.test.lib.jittester.functions.ArgumentDeclaration;
69 import jdk.test.lib.jittester.functions.ConstructorDefinition;
70 import jdk.test.lib.jittester.functions.ConstructorDefinitionBlock;
71 import jdk.test.lib.jittester.functions.Function;
72 import jdk.test.lib.jittester.functions.FunctionDeclaration;
73 import jdk.test.lib.jittester.functions.FunctionDeclarationBlock;
74 import jdk.test.lib.jittester.functions.FunctionDefinition;
75 import jdk.test.lib.jittester.functions.FunctionDefinitionBlock;
76 import jdk.test.lib.jittester.functions.FunctionInfo;
77 import jdk.test.lib.jittester.functions.FunctionRedefinition;
78 import jdk.test.lib.jittester.functions.FunctionRedefinitionBlock;
79 import jdk.test.lib.jittester.functions.Return;
80 import jdk.test.lib.jittester.functions.StaticConstructorDefinition;
81 import jdk.test.lib.jittester.loops.CounterInitializer;
82 import jdk.test.lib.jittester.loops.CounterManipulator;
83 import jdk.test.lib.jittester.loops.DoWhile;
84 import jdk.test.lib.jittester.loops.For;
85 import jdk.test.lib.jittester.loops.LoopingCondition;
86 import jdk.test.lib.jittester.loops.While;
87 import jdk.test.lib.jittester.types.TypeKlass;
94 private Optional<Integer> operatorLimit = Optional.empty();
95 private Optional<TypeKlass> ownerClass = Optional.empty();
96 private Optional<Type> resultType = Optional.empty();
97 private Optional<Boolean> safe = Optional.empty();
98 private Optional<Boolean> noConsts = Optional.empty();
99 private Optional<OperatorKind> opKind = Optional.empty();
100 private Optional<Integer> statementLimit = Optional.empty();
101 private Optional<Boolean> subBlock = Optional.empty();
102 private Optional<Boolean> canHaveBreaks = Optional.empty();
103 private Optional<Boolean> canHaveContinues = Optional.empty();
104 private Optional<Boolean> canHaveReturn = Optional.empty();
105 //not in use yet because 'throw' is only placed to the locations where 'return' is allowed
106 private Optional<Boolean> canHaveThrow = Optional.empty();
107 private Optional<Integer> level = Optional.empty();
108 private Optional<String> prefix = Optional.empty();
109 private Optional<Integer> memberFunctionsLimit = Optional.empty();
110 private Optional<Integer> memberFunctionsArgLimit = Optional.empty();
111 private Optional<LocalVariable> localVariable = Optional.empty();
112 private Optional<Boolean> isLocal = Optional.empty();
113 private Optional<Boolean> isStatic = Optional.empty();
114 private boolean isSynchronizedAllowed = false;
115 private Optional<Boolean> isConstant = Optional.empty();
116 private Optional<Boolean> isInitialized = Optional.empty();
117 private Optional<String> name = Optional.empty();
118 private Optional<Integer> flags = Optional.empty();
119 private Optional<FunctionInfo> functionInfo = Optional.empty();
120 private Optional<Boolean> semicolon = Optional.empty();
121
122 public Factory<ArgumentDeclaration> getArgumentDeclarationFactory() {
123 return new ArgumentDeclarationFactory(getArgumentType(), getVariableNumber());
124 }
125
126 public Factory<Operator> getArithmeticOperatorFactory() throws ProductionFailedException {
127 return new ArithmeticOperatorFactory(getComplexityLimit(), getOperatorLimit(),
128 getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts());
129 }
130
131 public Factory<ArrayCreation> getArrayCreationFactory() {
132 return new ArrayCreationFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
133 getResultType(), getExceptionSafe(), getNoConsts());
134 }
293 getMemberFunctionsArgLimit(), getLevel());
294 }
295
296 public Factory<Continue> getContinueFactory() {
297 return new ContinueFactory();
298 }
299
300 public Factory<CounterInitializer> getCounterInitializerFactory(int counterValue) {
301 return new CounterInitializerFactory(getOwnerClass(), counterValue);
302 }
303
304 public Factory<CounterManipulator> getCounterManipulatorFactory() {
305 return new CounterManipulatorFactory(getLocalVariable());
306 }
307
308 public Factory<Declaration> getDeclarationFactory() {
309 return new DeclarationFactory(getOwnerClass(), getComplexityLimit(), getOperatorLimit(),
310 getIsLocal(), getExceptionSafe());
311 }
312
313 public Factory<Declaration> getConstantDeclarationFactory() {
314 return new DeclarationFactory(getOwnerClass(), getComplexityLimit(), getOperatorLimit(),
315 getIsLocal(), getExceptionSafe(), true);
316 }
317
318 public Factory<DoWhile> getDoWhileFactory() {
319 return new DoWhileFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
320 getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn());
321 }
322
323 public Factory<While> getWhileFactory() {
324 return new WhileFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
325 getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn());
326 }
327
328 public Factory<If> getIfFactory() {
329 return new IfFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
330 getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveBreaks(),
331 getCanHaveContinues(), getCanHaveReturn());
332 }
333
334 public Factory<For> getForFactory() {
335 return new ForFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
336 getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn());
337 }
340 return new SwitchFactory(getOwnerClass(), getComplexityLimit(), getStatementLimit(),
341 getOperatorLimit(), getLevel(), getCanHaveReturn());
342 }
343
344 public Factory<IRNode> getExpressionFactory() throws ProductionFailedException {
345 return new ExpressionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
346 getResultType(), getExceptionSafe(), getNoConsts());
347 }
348
349 public Factory<FunctionDeclarationBlock> getFunctionDeclarationBlockFactory() {
350 return new FunctionDeclarationBlockFactory(getOwnerClass(), getMemberFunctionsLimit(),
351 getMemberFunctionsArgLimit(), getLevel());
352 }
353
354 public Factory<FunctionDeclaration> getFunctionDeclarationFactory() {
355 return new FunctionDeclarationFactory(getName(), getOwnerClass(),resultType.orElse(TypeList.VOID),
356 getMemberFunctionsArgLimit(), getFlags());
357 }
358
359 public Factory<FunctionDefinitionBlock> getFunctionDefinitionBlockFactory() {
360 Factory<FunctionDefinitionBlock> result =
361 new FunctionDefinitionBlockFactory(getOwnerClass(), getMemberFunctionsLimit(),
362 getMemberFunctionsArgLimit(), getComplexityLimit(), getStatementLimit(),
363 getOperatorLimit(), getLevel(), getFlags(), isSynchronizedAllowed);
364 isSynchronizedAllowed = true;
365 return result;
366 }
367
368 public Factory<FunctionDefinition> getFunctionDefinitionFactory() {
369 return new FunctionDefinitionFactory(getName(), getOwnerClass(), resultType.orElse(TypeList.VOID),
370 getComplexityLimit(), getStatementLimit(), getOperatorLimit(),
371 getMemberFunctionsArgLimit(), getLevel(), getFlags());
372 }
373
374 public Factory<Function> getFunctionFactory() {
375 return new FunctionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
376 resultType.orElse(null), getExceptionSafe());
377 }
378
379 public Factory<FunctionRedefinitionBlock> getFunctionRedefinitionBlockFactory(Collection<Symbol>
380 functionSet) {
381 return new FunctionRedefinitionBlockFactory(functionSet, getOwnerClass(),
382 getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel());
383 }
384
385 public Factory<FunctionRedefinition> getFunctionRedefinitionFactory() {
386 return new FunctionRedefinitionFactory(getFunctionInfo(), getOwnerClass(),
387 getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel(),
388 getFlags());
389 }
390
391 public Factory<Interface> getInterfaceFactory() {
392 return new InterfaceFactory(getName(), getMemberFunctionsLimit(),
393 getMemberFunctionsArgLimit(), getLevel());
394 }
395
396 public Factory<Klass> getKlassFactory() {
397 return new KlassFactory(getName(), getComplexityLimit(),
398 getMemberFunctionsLimit(), getMemberFunctionsArgLimit(), getStatementLimit(),
399 getOperatorLimit(), getLevel());
400 }
401
402 public Factory<ValueKlass> getValueKlassFactory() {
403 return new ValueKlassFactory(getName(), getComplexityLimit(),
404 getMemberFunctionsLimit(), getMemberFunctionsArgLimit(), getStatementLimit(),
405 getOperatorLimit(), getLevel());
406 }
407
408 public Factory<IRNode> getLimitedExpressionFactory() throws ProductionFailedException {
409 return new LimitedExpressionFactory(getComplexityLimit(), getOperatorLimit(),
410 getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts());
411 }
412
413 public Factory<Literal> getLiteralFactory() {
414 return new LiteralFactory(getResultType());
415 }
416
417 public Factory<LocalVariable> getLocalVariableFactory() {
418 return new LocalVariableFactory(/*getVariableType()*/getResultType(), getFlags());
419 }
420
421 public Factory<Operator> getLogicOperatorFactory() throws ProductionFailedException {
422 return new LogicOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
423 getResultType(), getExceptionSafe(), getNoConsts());
424 }
425
426 public Factory<LoopingCondition> getLoopingConditionFactory(Literal _limiter) {
427 return new LoopingConditionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
457
458 public Factory<StaticConstructorDefinition> getStaticConstructorDefinitionFactory() {
459 return new StaticConstructorDefinitionFactory(getOwnerClass(), getComplexityLimit(),
460 getStatementLimit(), getOperatorLimit(), getLevel());
461 }
462
463 public Factory<StaticMemberVariable> getStaticMemberVariableFactory() {
464 return new StaticMemberVariableFactory(getOwnerClass(), /*getVariableType()*/getResultType(), getFlags());
465 }
466
467 public Factory<TernaryOperator> getTernaryOperatorFactory() {
468 return new TernaryOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
469 getResultType(), getExceptionSafe(), getNoConsts());
470 }
471
472 public Factory<VariableDeclarationBlock> getVariableDeclarationBlockFactory() {
473 return new VariableDeclarationBlockFactory(getOwnerClass(), getComplexityLimit(),
474 getOperatorLimit(), getLevel(), getExceptionSafe());
475 }
476
477 /**
478 * Creates a variable declaration block factory constrained to constants.
479 *
480 * @return constant-only declaration block factory
481 */
482 public Factory<VariableDeclarationBlock> getConstantVariableDeclarationBlockFactory() {
483 return new VariableDeclarationBlockFactory(getOwnerClass(), getComplexityLimit(),
484 getOperatorLimit(), getLevel(), getExceptionSafe());
485 }
486
487 public Factory<VariableDeclaration> getVariableDeclarationFactory() {
488 return new VariableDeclarationFactory(getOwnerClass(), getIsStatic(), getIsLocal(), getResultType());
489 }
490
491 public Factory<VariableBase> getVariableFactory() {
492 return new VariableFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
493 /*getVariableType()*/getResultType(), getIsConstant(), getIsInitialized(), getExceptionSafe(), getNoConsts());
494 }
495
496 public Factory<VariableInitialization> getVariableInitializationFactory() {
497 return new VariableInitializationFactory(getOwnerClass(), getIsConstant(), getIsStatic(),
498 getIsLocal(), getComplexityLimit(), getOperatorLimit(), getExceptionSafe());
499 }
500
501 public Factory<TryCatchBlock> getTryCatchBlockFactory() {
502 return new TryCatchBlockFactory(getOwnerClass(), getResultType(),
503 getComplexityLimit(), getStatementLimit(), getOperatorLimit(),
504 getLevel(), subBlock.orElse(false), getCanHaveBreaks(),
505 getCanHaveContinues(), getCanHaveReturn());
506 }
603 public IRNodeBuilder setMemberFunctionsArgLimit(int value) {
604 memberFunctionsArgLimit = Optional.of(value);
605 return this;
606 }
607
608 public IRNodeBuilder setLocalVariable(LocalVariable value) {
609 localVariable = Optional.of(value);
610 return this;
611 }
612
613 public IRNodeBuilder setIsLocal(boolean value) {
614 isLocal = Optional.of(value);
615 return this;
616 }
617
618 public IRNodeBuilder setIsStatic(boolean value) {
619 isStatic = Optional.of(value);
620 return this;
621 }
622
623 public IRNodeBuilder setIsSynchronizedAllowed(boolean value) {
624 isSynchronizedAllowed = value;
625 return this;
626 }
627
628 public IRNodeBuilder setIsInitialized(boolean value) {
629 isInitialized = Optional.of(value);
630 return this;
631 }
632
633 public IRNodeBuilder setIsConstant(boolean value) {
634 isConstant = Optional.of(value);
635 return this;
636 }
637
638 public IRNodeBuilder setName(String value) {
639 name = Optional.of(value);
640 return this;
641 }
642
643 public IRNodeBuilder setFlags(int value) {
644 flags = Optional.of(value);
645 return this;
646 }
647
720 }
721
722 private int getMemberFunctionsArgLimit() {
723 return memberFunctionsArgLimit.orElseThrow(() -> new IllegalArgumentException(
724 "memberFunctionsArg limit wasn't set"));
725 }
726
727 private LocalVariable getLocalVariable() {
728 return localVariable.orElseThrow(() -> new IllegalArgumentException(
729 "local variable wasn't set"));
730 }
731
732 private boolean getIsLocal() {
733 return isLocal.orElseThrow(() -> new IllegalArgumentException("isLocal wasn't set"));
734 }
735
736 private boolean getIsStatic() {
737 return isStatic.orElseThrow(() -> new IllegalArgumentException("isStatic wasn't set"));
738 }
739
740 private boolean getIsSynchronizedAllowed() {
741 return isSynchronizedAllowed;
742 }
743
744 private boolean getIsInitialized() {
745 return isInitialized.orElseThrow(() -> new IllegalArgumentException(
746 "isInitialized wasn't set"));
747 }
748
749 private boolean getIsConstant() {
750 return isConstant.orElseThrow(() -> new IllegalArgumentException("isConstant wasn't set"));
751 }
752
753 private boolean getCanHaveReturn() {
754 return canHaveReturn.orElseThrow(() -> new IllegalArgumentException(
755 "canHaveReturn wasn't set"));
756 }
757
758 private boolean getCanHaveBreaks() {
759 return canHaveBreaks.orElseThrow(() -> new IllegalArgumentException(
760 "canHaveBreaks wasn't set"));
761 }
762
763 private boolean getCanHaveContinues() {
|