(SemanticsVisitor visitor, Node[] args, FormulaSemantics semantics)
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public FormatManager<?> allowArgs(SemanticsVisitor visitor, Node[] args, FormulaSemantics semantics) |
| 68 | { |
| 69 | int argCount = args.length; |
| 70 | if (argCount != 3) |
| 71 | { |
| 72 | throw new SemanticsFailureException("Function " + getFunctionName() |
| 73 | + " received incorrect # of arguments, expected: 3 got " + args.length + ' ' + Arrays.asList(args)); |
| 74 | } |
| 75 | |
| 76 | Node scopeNode = args[0]; |
| 77 | if (!(scopeNode instanceof ASTQuotString qs)) |
| 78 | { |
| 79 | throw new SemanticsFailureException( |
| 80 | "Parse Error: Invalid Scope Node: " |
| 81 | + scopeNode.getClass().getName() |
| 82 | + " found in location requiring a" |
| 83 | + " Static String (first arg cannot be evaluated)"); |
| 84 | } |
| 85 | String legalScopeName = qs.getText(); |
| 86 | FormulaManager formulaManager = semantics.get(FormulaSemantics.FMANAGER); |
| 87 | PCGenScope legalScope = (PCGenScope) formulaManager.getScopeInstanceFactory().getScope(legalScopeName); |
| 88 | if (legalScope == null) |
| 89 | { |
| 90 | throw new SemanticsFailureException( |
| 91 | "Parse Error: Invalid Scope Name: " + legalScopeName + " was not a defined scope"); |
| 92 | } |
| 93 | LoadContext context = semantics.get(ManagerKey.CONTEXT); |
| 94 | Optional<FormatManager<?>> formatManager = legalScope.getFormatManager(context); |
| 95 | if (formatManager.isEmpty()) |
| 96 | { |
| 97 | throw new SemanticsFailureException( |
| 98 | "Parse Error: Invalid Scope Name: " + legalScopeName |
| 99 | + " found in location requiring a deterministic scope"); |
| 100 | } |
| 101 | FormatManager<?> objectFormat = (FormatManager<?>) args[1].jjtAccept(visitor, |
| 102 | semantics.getWith(FormulaSemantics.ASSERTED, formatManager)); |
| 103 | if (!formatManager.get().equals(objectFormat)) |
| 104 | { |
| 105 | throw new SemanticsFailureException( |
| 106 | "Parse Error: Invalid Object Format: " |
| 107 | + objectFormat.getIdentifierType() |
| 108 | + " found in a getOther call that asserted " |
| 109 | + formatManager.get().getIdentifierType()); |
| 110 | } |
| 111 | if (VarScoped.class.isAssignableFrom(objectFormat.getManagedClass())) |
| 112 | { |
| 113 | return (FormatManager<?>) args[2].jjtAccept(visitor, |
| 114 | semantics.getWith(FormulaSemantics.SCOPE, legalScope)); |
| 115 | } |
| 116 | else |
| 117 | { |
| 118 | throw new SemanticsFailureException( |
| 119 | "Parse Error: Invalid Object Format: " + objectFormat |
| 120 | + " is not capable of holding variables"); |
| 121 | } |
| 122 | } |
| 123 |
nothing calls this directly
no test coverage detected