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 */ 23 24 package jdk.test.lib.jittester.factories; 25 26 import java.util.Collection; 27 import java.util.Optional; 28 import jdk.test.lib.jittester.Literal; 29 import jdk.test.lib.jittester.LocalVariable; 30 import jdk.test.lib.jittester.OperatorKind; 31 import jdk.test.lib.jittester.ProductionFailedException; 32 import jdk.test.lib.jittester.ProductionParams; 33 import jdk.test.lib.jittester.Symbol; 34 import jdk.test.lib.jittester.Type; 35 import jdk.test.lib.jittester.functions.FunctionInfo; 36 import jdk.test.lib.jittester.types.TypeKlass; 37 38 public class IRNodeBuilder { 39 //private Optional<Type> variableType = Optional.empty(); 40 private Optional<TypeKlass> argumentType = Optional.empty(); 41 private Optional<Integer> variableNumber = Optional.empty(); 42 private Optional<Long> complexityLimit = Optional.empty(); 43 private Optional<Integer> operatorLimit = Optional.empty(); 44 private Optional<TypeKlass> ownerClass = Optional.empty(); 45 private Optional<Type> resultType = Optional.empty(); 46 private Optional<Boolean> safe = Optional.empty(); 47 private Optional<Boolean> noConsts = Optional.empty(); 48 private Optional<OperatorKind> opKind = Optional.empty(); 49 private Optional<Integer> statementLimit = Optional.empty(); 50 private Optional<Boolean> subBlock = Optional.empty(); 51 private Optional<Boolean> canHaveBreaks = Optional.empty(); 52 private Optional<Boolean> canHaveContinues = Optional.empty(); 53 private Optional<Boolean> canHaveReturn = Optional.empty(); 54 //not in use yet because 'throw' is only placed to the locations where 'return' is allowed 55 private Optional<Boolean> canHaveThrow = Optional.empty(); 56 private Optional<Integer> level = Optional.empty(); 57 private Optional<String> prefix = Optional.empty(); 58 private Optional<Integer> memberFunctionsLimit = Optional.empty(); 59 private Optional<Integer> memberFunctionsArgLimit = Optional.empty(); 60 private Optional<LocalVariable> localVariable = Optional.empty(); 61 private Optional<Boolean> isLocal = Optional.empty(); 62 private Optional<Boolean> isStatic = Optional.empty(); 63 private Optional<Boolean> isConstant = Optional.empty(); 64 private Optional<Boolean> isInitialized = Optional.empty(); 65 private Optional<String> name = Optional.empty(); 66 private Optional<String> printerName = Optional.empty(); 67 private Optional<Integer> flags = Optional.empty(); 68 private Optional<FunctionInfo> functionInfo = Optional.empty(); 69 private Optional<Boolean> semicolon = Optional.empty(); 70 71 public ArgumentDeclarationFactory getArgumentDeclarationFactory() { 72 return new ArgumentDeclarationFactory(getArgumentType(), getVariableNumber()); 73 } 74 75 public Factory getArithmeticOperatorFactory() throws ProductionFailedException { 76 return new ArithmeticOperatorFactory(getComplexityLimit(), getOperatorLimit(), 77 getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts()); 78 } 79 80 public ArrayCreationFactory getArrayCreationFactory() { 81 return new ArrayCreationFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), 82 getResultType(), getExceptionSafe(), getNoConsts()); 83 } 84 85 public ArrayElementFactory getArrayElementFactory() { 86 return new ArrayElementFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), 87 getResultType(), getExceptionSafe(), getNoConsts()); 88 } 89 90 public ArrayExtractionFactory getArrayExtractionFactory() { 91 return new ArrayExtractionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), 92 getResultType(), getExceptionSafe(), getNoConsts()); 93 } 94 95 public AssignmentOperatorFactory getAssignmentOperatorFactory() { 96 return new AssignmentOperatorFactory(getComplexityLimit(), getOperatorLimit(), 97 getOwnerClass(), resultType.orElse(null), getExceptionSafe(), getNoConsts()); 98 } 99 100 public BinaryOperatorFactory getBinaryOperatorFactory() throws ProductionFailedException { 101 OperatorKind o = getOperatorKind(); 102 switch (o) { 103 case ASSIGN: 104 return new AssignmentOperatorImplFactory(getComplexityLimit(), getOperatorLimit(), 105 getOwnerClass(), resultType.orElse(null), getExceptionSafe(), getNoConsts()); 106 case AND: 107 case OR: 108 return new BinaryLogicOperatorFactory(o, getComplexityLimit(), getOperatorLimit(), 109 getOwnerClass(), resultType.orElse(null), getExceptionSafe(), getNoConsts()); 110 case BIT_OR: 111 case BIT_XOR: 112 case BIT_AND: 113 return new BinaryBitwiseOperatorFactory(o, getComplexityLimit(), getOperatorLimit(), 114 getOwnerClass(), resultType.orElse(null), getExceptionSafe(), getNoConsts()); 115 116 case EQ: 117 case NE: 118 return new BinaryEqualityOperatorFactory(o, getComplexityLimit(), 119 getOperatorLimit(), getOwnerClass(), resultType.orElse(null), getExceptionSafe(), 120 getNoConsts()); 121 case GT: 122 case LT: 123 case GE: 124 case LE: 125 return new BinaryComparisonOperatorFactory(o, getComplexityLimit(), 126 getOperatorLimit(), getOwnerClass(), resultType.orElse(null), getExceptionSafe(), 127 getNoConsts()); 128 case SHR: 129 case SHL: 130 case SAR: 131 return new BinaryShiftOperatorFactory(o, getComplexityLimit(), getOperatorLimit(), 132 getOwnerClass(), resultType.orElse(null), getExceptionSafe(), getNoConsts()); 133 case ADD: 134 case SUB: 135 case MUL: 136 case DIV: 137 case MOD: 138 return new BinaryArithmeticOperatorFactory(o, getComplexityLimit(), 139 getOperatorLimit(), getOwnerClass(), resultType.orElse(null), getExceptionSafe(), 140 getNoConsts()); 141 case STRADD: 142 return new BinaryStringPlusFactory(getComplexityLimit(), getOperatorLimit(), 143 getOwnerClass(), resultType.orElse(null), getExceptionSafe(), getNoConsts()); 144 case COMPOUND_ADD: 145 case COMPOUND_SUB: 146 case COMPOUND_MUL: 147 case COMPOUND_DIV: 148 case COMPOUND_MOD: 149 return new CompoundArithmeticAssignmentOperatorFactory(o, getComplexityLimit(), 150 getOperatorLimit(), getOwnerClass(), resultType.orElse(null), getExceptionSafe(), 151 getNoConsts()); 152 case COMPOUND_AND: 153 case COMPOUND_OR: 154 case COMPOUND_XOR: 155 return new CompoundBitwiseAssignmentOperatorFactory(o, getComplexityLimit(), 156 getOperatorLimit(), getOwnerClass(), resultType.orElse(null), getExceptionSafe(), 157 getNoConsts()); 158 case COMPOUND_SHR: 159 case COMPOUND_SHL: 160 case COMPOUND_SAR: 161 return new CompoundShiftAssignmentOperatorFactory(o, getComplexityLimit(), 162 getOperatorLimit(), getOwnerClass(), resultType.orElse(null), getExceptionSafe(), 163 getNoConsts()); 164 default: 165 throw new ProductionFailedException(); 166 } 167 } 168 169 public UnaryOperatorFactory getUnaryOperatorFactory() throws ProductionFailedException { 170 OperatorKind o = getOperatorKind(); 171 switch (o) { 172 case NOT: 173 return new LogicalInversionOperatorFactory(getComplexityLimit(), 174 getOperatorLimit(), getOwnerClass(), resultType.orElse(null), getExceptionSafe(), 175 getNoConsts()); 176 case BIT_NOT: 177 return new BitwiseInversionOperatorFactory(getComplexityLimit(), 178 getOperatorLimit(), getOwnerClass(), resultType.orElse(null), getExceptionSafe(), 179 getNoConsts()); 180 case UNARY_PLUS: 181 case UNARY_MINUS: 182 return new UnaryPlusMinusOperatorFactory(o, getComplexityLimit(), 183 getOperatorLimit(), getOwnerClass(), resultType.orElse(null), getExceptionSafe(), 184 getNoConsts()); 185 case PRE_DEC: 186 case POST_DEC: 187 case PRE_INC: 188 case POST_INC: 189 return new IncDecOperatorFactory(o, getComplexityLimit(), getOperatorLimit(), 190 getOwnerClass(), resultType.orElse(null), getExceptionSafe(), getNoConsts()); 191 default: 192 throw new ProductionFailedException(); 193 } 194 } 195 196 public BlockFactory getBlockFactory() throws ProductionFailedException { 197 return new BlockFactory(getOwnerClass(), getResultType(), getComplexityLimit(), 198 getStatementLimit(), getOperatorLimit(), getLevel(), subBlock.orElse(false), 199 canHaveBreaks.orElse(false), canHaveContinues.orElse(false), 200 canHaveReturn.orElse(false), canHaveReturn.orElse(false)); 201 //now 'throw' can be placed only in the same positions as 'return' 202 } 203 204 public BreakFactory getBreakFactory() { 205 return new BreakFactory(); 206 } 207 208 public CastOperatorFactory getCastOperatorFactory() { 209 return new CastOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), 210 getResultType(), getExceptionSafe(), getNoConsts()); 211 } 212 213 public Factory getClassDefinitionBlockFactory() { 214 return new ClassDefinitionBlockFactory(getPrefix(), 215 ProductionParams.classesLimit.value(), 216 ProductionParams.memberFunctionsLimit.value(), 217 ProductionParams.memberFunctionsArgLimit.value(), 218 getComplexityLimit(), 219 ProductionParams.statementLimit.value(), 220 ProductionParams.operatorLimit.value(), 221 getLevel()); 222 } 223 224 public Factory getMainKlassFactory() { 225 return new MainKlassFactory(getName(), getComplexityLimit(), 226 ProductionParams.memberFunctionsLimit.value(), 227 ProductionParams.memberFunctionsArgLimit.value(), 228 ProductionParams.statementLimit.value(), 229 ProductionParams.testStatementLimit.value(), 230 ProductionParams.operatorLimit.value()); 231 } 232 233 public ConstructorDefinitionBlockFactory getConstructorDefinitionBlockFactory() { 234 return new ConstructorDefinitionBlockFactory(getOwnerClass(), getMemberFunctionsLimit(), 235 ProductionParams.memberFunctionsArgLimit.value(), getComplexityLimit(), 236 getStatementLimit(), getOperatorLimit(), getLevel()); 237 } 238 239 public ConstructorDefinitionFactory getConstructorDefinitionFactory() { 240 return new ConstructorDefinitionFactory(getOwnerClass(), getComplexityLimit(), 241 getStatementLimit(), getOperatorLimit(), 242 getMemberFunctionsArgLimit(), getLevel()); 243 } 244 245 public ContinueFactory getContinueFactory() { 246 return new ContinueFactory(); 247 } 248 249 public CounterInitializerFactory getCounterInitializerFactory(int counterValue) { 250 return new CounterInitializerFactory(getOwnerClass(), counterValue); 251 } 252 253 public CounterManipulatorFactory getCounterManipulatorFactory() { 254 return new CounterManipulatorFactory(getLocalVariable()); 255 } 256 257 public DeclarationFactory getDeclarationFactory() { 258 return new DeclarationFactory(getOwnerClass(), getComplexityLimit(), getOperatorLimit(), 259 getIsLocal(), getExceptionSafe()); 260 } 261 262 public DoWhileFactory getDoWhileFactory() { 263 return new DoWhileFactory(getOwnerClass(), getResultType(), getComplexityLimit(), 264 getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn()); 265 } 266 267 public WhileFactory getWhileFactory() { 268 return new WhileFactory(getOwnerClass(), getResultType(), getComplexityLimit(), 269 getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn()); 270 } 271 272 public IfFactory getIfFactory() { 273 return new IfFactory(getOwnerClass(), getResultType(), getComplexityLimit(), 274 getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveBreaks(), 275 getCanHaveContinues(), getCanHaveReturn()); 276 } 277 278 public ForFactory getForFactory() { 279 return new ForFactory(getOwnerClass(), getResultType(), getComplexityLimit(), 280 getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn()); 281 } 282 283 public SwitchFactory getSwitchFactory() { // TODO: switch is not used now 284 return new SwitchFactory(getOwnerClass(), getComplexityLimit(), getStatementLimit(), 285 getOperatorLimit(), getLevel(), getCanHaveReturn()); 286 } 287 288 public ExpressionFactory getExpressionFactory() throws ProductionFailedException { 289 return new ExpressionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), 290 getResultType(), getExceptionSafe(), getNoConsts()); 291 } 292 293 public FunctionDeclarationBlockFactory getFunctionDeclarationBlockFactory() { 294 return new FunctionDeclarationBlockFactory(getOwnerClass(), getMemberFunctionsLimit(), 295 getMemberFunctionsArgLimit(), getLevel()); 296 } 297 298 public FunctionDeclarationFactory getFunctionDeclarationFactory() { 299 return new FunctionDeclarationFactory(getName(), getOwnerClass(),resultType.orElse(null), 300 getMemberFunctionsArgLimit(), getFlags()); 301 } 302 303 public FunctionDefinitionBlockFactory getFunctionDefinitionBlockFactory() { 304 return new FunctionDefinitionBlockFactory(getOwnerClass(), getMemberFunctionsLimit(), 305 getMemberFunctionsArgLimit(), getComplexityLimit(), getStatementLimit(), 306 getOperatorLimit(), getLevel(), getFlags()); 307 } 308 309 public FunctionDefinitionFactory getFunctionDefinitionFactory() { 310 return new FunctionDefinitionFactory(getName(), getOwnerClass(), resultType.orElse(null), 311 getComplexityLimit(), getStatementLimit(), getOperatorLimit(), 312 getMemberFunctionsArgLimit(), getLevel(), getFlags()); 313 } 314 315 public FunctionFactory getFunctionFactory() { 316 return new FunctionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), 317 resultType.orElse(null), getExceptionSafe()); 318 } 319 320 public FunctionRedefinitionBlockFactory getFunctionRedefinitionBlockFactory(Collection<Symbol> 321 functionSet) { 322 return new FunctionRedefinitionBlockFactory(functionSet, getOwnerClass(), 323 getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel()); 324 } 325 326 public FunctionRedefinitionFactory getFunctionRedefinitionFactory() { 327 return new FunctionRedefinitionFactory(getFunctionInfo(), getOwnerClass(), 328 getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel(), 329 getFlags()); 330 } 331 332 public InterfaceFactory getInterfaceFactory() { 333 return new InterfaceFactory(getName(), getMemberFunctionsLimit(), 334 getMemberFunctionsArgLimit(), getLevel()); 335 } 336 337 public KlassFactory getKlassFactory() { 338 return new KlassFactory(getName(), getPrinterName(), getComplexityLimit(), 339 getMemberFunctionsLimit(), getMemberFunctionsArgLimit(), getStatementLimit(), 340 getOperatorLimit(), getLevel()); 341 } 342 343 public LimitedExpressionFactory getLimitedExpressionFactory() throws ProductionFailedException { 344 return new LimitedExpressionFactory(getComplexityLimit(), getOperatorLimit(), 345 getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts()); 346 } 347 348 public LiteralFactory getLiteralFactory() { 349 return new LiteralFactory(getResultType()); 350 } 351 352 public LocalVariableFactory getLocalVariableFactory() { 353 return new LocalVariableFactory(/*getVariableType()*/getResultType(), getFlags()); 354 } 355 356 public LogicOperatorFactory getLogicOperatorFactory() throws ProductionFailedException { 357 return new LogicOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), 358 getResultType(), getExceptionSafe(), getNoConsts()); 359 } 360 361 public LoopingConditionFactory getLoopingConditionFactory(Literal _limiter) { 362 return new LoopingConditionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), 363 getLocalVariable(), _limiter); 364 } 365 366 public NonStaticMemberVariableFactory getNonStaticMemberVariableFactory() { 367 return new NonStaticMemberVariableFactory(getComplexityLimit(), getOperatorLimit(), 368 getOwnerClass(), /*getVariableType()*/getResultType(), getFlags(), getExceptionSafe()); 369 } 370 371 public NothingFactory getNothingFactory() { 372 return new NothingFactory(); 373 } 374 375 public PrintVariablesFactory getPrintVariablesFactory() { 376 return new PrintVariablesFactory(getPrinterName(), getOwnerClass(), getLevel()); 377 } 378 379 public ReturnFactory getReturnFactory() { 380 return new ReturnFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), 381 getResultType(), getExceptionSafe()); 382 } 383 384 public ThrowFactory getThrowFactory() { 385 return new ThrowFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe()); 386 } 387 388 public StatementFactory getStatementFactory() { 389 return new StatementFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), 390 getExceptionSafe(), getNoConsts(), semicolon.orElse(true)); 391 } 392 393 public StaticConstructorDefinitionFactory getStaticConstructorDefinitionFactory() { 394 return new StaticConstructorDefinitionFactory(getOwnerClass(), getComplexityLimit(), 395 getStatementLimit(), getOperatorLimit(), getLevel()); 396 } 397 398 public StaticMemberVariableFactory getStaticMemberVariableFactory() { 399 return new StaticMemberVariableFactory(getOwnerClass(), /*getVariableType()*/getResultType(), getFlags()); 400 } 401 402 public TernaryOperatorFactory getTernaryOperatorFactory() { 403 return new TernaryOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), 404 getResultType(), getExceptionSafe(), getNoConsts()); 405 } 406 407 public VariableDeclarationBlockFactory getVariableDeclarationBlockFactory() { 408 return new VariableDeclarationBlockFactory(getOwnerClass(), getComplexityLimit(), 409 getOperatorLimit(), getLevel(), getExceptionSafe()); 410 } 411 412 public VariableDeclarationFactory getVariableDeclarationFactory() { 413 return new VariableDeclarationFactory(getOwnerClass(), getIsStatic(), getIsLocal(), getResultType()); 414 } 415 416 public VariableFactory getVariableFactory() { 417 return new VariableFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), 418 /*getVariableType()*/getResultType(), getIsConstant(), getIsInitialized(), getExceptionSafe(), getNoConsts()); 419 } 420 421 public VariableInitializationFactory getVariableInitializationFactory() { 422 return new VariableInitializationFactory(getOwnerClass(), getIsConstant(), getIsStatic(), 423 getIsLocal(), getComplexityLimit(), getOperatorLimit(), getExceptionSafe()); 424 } 425 426 public TryCatchBlockFactory getTryCatchBlockFactory() { 427 return new TryCatchBlockFactory(getOwnerClass(), getResultType(), 428 getComplexityLimit(), getStatementLimit(), getOperatorLimit(), 429 getLevel(), subBlock.orElse(false), getCanHaveBreaks(), 430 getCanHaveContinues(), getCanHaveReturn()); 431 } 432 433 /* public IRNodeBuilder setVariableType(Type value) { 434 variableType = Optional.of(value); 435 return this; 436 }*/ 437 438 public IRNodeBuilder setArgumentType(TypeKlass value) { 439 argumentType = Optional.of(value); 440 return this; 441 } 442 443 public IRNodeBuilder setVariableNumber(int value) { 444 variableNumber = Optional.of(value); 445 return this; 446 } 447 448 public IRNodeBuilder setComplexityLimit(long value) { 449 complexityLimit = Optional.of(value); 450 return this; 451 } 452 453 public IRNodeBuilder setOperatorLimit(int value) { 454 operatorLimit = Optional.of(value); 455 return this; 456 } 457 458 public IRNodeBuilder setStatementLimit(int value) { 459 statementLimit = Optional.of(value); 460 return this; 461 } 462 463 public IRNodeBuilder setOwnerKlass(TypeKlass value) { 464 ownerClass = Optional.of(value); 465 return this; 466 } 467 468 public IRNodeBuilder setResultType(Type value) { 469 resultType = Optional.of(value); 470 return this; 471 } 472 // TODO: check if safe is always true in current implementation 473 public IRNodeBuilder setExceptionSafe(boolean value) { 474 safe = Optional.of(value); 475 return this; 476 } 477 // TODO: check is noconsts is always false in current implementation 478 public IRNodeBuilder setNoConsts(boolean value) { 479 noConsts = Optional.of(value); 480 return this; 481 } 482 483 public IRNodeBuilder setOperatorKind(OperatorKind value) { 484 opKind = Optional.of(value); 485 return this; 486 } 487 488 public IRNodeBuilder setLevel(int value) { 489 level = Optional.of(value); 490 return this; 491 } 492 493 public IRNodeBuilder setSubBlock(boolean value) { 494 subBlock = Optional.of(value); 495 return this; 496 } 497 498 public IRNodeBuilder setCanHaveBreaks(boolean value) { 499 canHaveBreaks = Optional.of(value); 500 return this; 501 } 502 503 public IRNodeBuilder setCanHaveContinues(boolean value) { 504 canHaveContinues = Optional.of(value); 505 return this; 506 } 507 508 public IRNodeBuilder setCanHaveReturn(boolean value) { 509 canHaveReturn = Optional.of(value); 510 return this; 511 } 512 513 public IRNodeBuilder setCanHaveThrow(boolean value) { 514 canHaveThrow = Optional.of(value); 515 return this; 516 } 517 518 public IRNodeBuilder setPrefix(String value) { 519 prefix = Optional.of(value); 520 return this; 521 } 522 523 public IRNodeBuilder setMemberFunctionsLimit(int value) { 524 memberFunctionsLimit = Optional.of(value); 525 return this; 526 } 527 528 public IRNodeBuilder setMemberFunctionsArgLimit(int value) { 529 memberFunctionsArgLimit = Optional.of(value); 530 return this; 531 } 532 533 public IRNodeBuilder setLocalVariable(LocalVariable value) { 534 localVariable = Optional.of(value); 535 return this; 536 } 537 538 public IRNodeBuilder setIsLocal(boolean value) { 539 isLocal = Optional.of(value); 540 return this; 541 } 542 543 public IRNodeBuilder setIsStatic(boolean value) { 544 isStatic = Optional.of(value); 545 return this; 546 } 547 548 public IRNodeBuilder setIsInitialized(boolean value) { 549 isInitialized = Optional.of(value); 550 return this; 551 } 552 553 public IRNodeBuilder setIsConstant(boolean value) { 554 isConstant = Optional.of(value); 555 return this; 556 } 557 558 public IRNodeBuilder setName(String value) { 559 name = Optional.of(value); 560 return this; 561 } 562 563 public IRNodeBuilder setFlags(int value) { 564 flags = Optional.of(value); 565 return this; 566 } 567 568 public IRNodeBuilder setFunctionInfo(FunctionInfo value) { 569 functionInfo = Optional.of(value); 570 return this; 571 } 572 573 public IRNodeBuilder setPrinterName(String value) { 574 printerName = Optional.of(value); 575 return this; 576 } 577 578 public IRNodeBuilder setSemicolon(boolean value) { 579 semicolon = Optional.of(value); 580 return this; 581 } 582 583 // getters 584 /* private Type getVariableType() { 585 return variableType.orElseThrow(() -> new IllegalArgumentException( 586 "Variable type wasn't set")); 587 }*/ 588 589 private TypeKlass getArgumentType() { 590 return argumentType.orElseThrow(() -> new IllegalArgumentException( 591 "Argument type wasn't set")); 592 } 593 594 private int getVariableNumber() { 595 return variableNumber.orElseThrow(() -> new IllegalArgumentException( 596 "Variable number wasn't set")); 597 } 598 599 private long getComplexityLimit() { 600 return complexityLimit.orElseThrow(() -> new IllegalArgumentException( 601 "Complexity limit wasn't set")); 602 } 603 604 private int getOperatorLimit() { 605 return operatorLimit.orElseThrow(() -> new IllegalArgumentException( 606 "Operator limit wasn't set")); 607 } 608 609 private int getStatementLimit() { 610 return statementLimit.orElseThrow(() -> new IllegalArgumentException( 611 "Statement limit wasn't set")); 612 } 613 614 private TypeKlass getOwnerClass() { 615 return ownerClass.orElseThrow(() -> new IllegalArgumentException("Type_Klass wasn't set")); 616 } 617 618 private Type getResultType() { 619 return resultType.orElseThrow(() -> new IllegalArgumentException("Return type wasn't set")); 620 } 621 622 private boolean getExceptionSafe() { 623 return safe.orElseThrow(() -> new IllegalArgumentException("Safe wasn't set")); 624 } 625 626 private boolean getNoConsts() { 627 return noConsts.orElseThrow(() -> new IllegalArgumentException("NoConsts wasn't set")); 628 } 629 630 private OperatorKind getOperatorKind() { 631 return opKind.orElseThrow(() -> new IllegalArgumentException("Operator kind wasn't set")); 632 } 633 634 private int getLevel() { 635 return level.orElseThrow(() -> new IllegalArgumentException("Level wasn't set")); 636 } 637 638 private String getPrefix() { 639 return prefix.orElseThrow(() -> new IllegalArgumentException("Prefix wasn't set")); 640 } 641 642 private int getMemberFunctionsLimit() { 643 return memberFunctionsLimit.orElseThrow(() -> new IllegalArgumentException( 644 "memberFunctions limit wasn't set")); 645 } 646 647 private int getMemberFunctionsArgLimit() { 648 return memberFunctionsArgLimit.orElseThrow(() -> new IllegalArgumentException( 649 "memberFunctionsArg limit wasn't set")); 650 } 651 652 private LocalVariable getLocalVariable() { 653 return localVariable.orElseThrow(() -> new IllegalArgumentException( 654 "local variable wasn't set")); 655 } 656 657 private boolean getIsLocal() { 658 return isLocal.orElseThrow(() -> new IllegalArgumentException("isLocal wasn't set")); 659 } 660 661 private boolean getIsStatic() { 662 return isStatic.orElseThrow(() -> new IllegalArgumentException("isStatic wasn't set")); 663 } 664 665 private boolean getIsInitialized() { 666 return isInitialized.orElseThrow(() -> new IllegalArgumentException( 667 "isInitialized wasn't set")); 668 } 669 670 private boolean getIsConstant() { 671 return isConstant.orElseThrow(() -> new IllegalArgumentException("isConstant wasn't set")); 672 } 673 674 private boolean getCanHaveReturn() { 675 return canHaveReturn.orElseThrow(() -> new IllegalArgumentException( 676 "canHaveReturn wasn't set")); 677 } 678 679 private boolean getCanHaveBreaks() { 680 return canHaveBreaks.orElseThrow(() -> new IllegalArgumentException( 681 "canHaveBreaks wasn't set")); 682 } 683 684 private boolean getCanHaveContinues() { 685 return canHaveContinues.orElseThrow(() -> new IllegalArgumentException( 686 "canHaveContinues wasn't set")); 687 } 688 689 private String getName() { 690 return name.orElseThrow(() -> new IllegalArgumentException("Name wasn't set")); 691 } 692 693 private int getFlags() { 694 return flags.orElseThrow(() -> new IllegalArgumentException("Flags wasn't set")); 695 } 696 697 private FunctionInfo getFunctionInfo() { 698 return functionInfo.orElseThrow(() -> new IllegalArgumentException( 699 "FunctionInfo wasn't set")); 700 } 701 702 private String getPrinterName() { 703 return printerName.orElseThrow(() -> new IllegalArgumentException( 704 "printerName wasn't set")); 705 } 706 }