* This method maintains a resolution cache, so once we have returned a result, we will keep on returning the same - * result without performing any lookups, solely to support {@link SubstatementContext#isConfiguration()}. + * result without performing any lookups, solely to support {@link #effectiveConfig()}. * *
* Note: use of this method implies that {@link #isIgnoringConfig()} is realized with
* {@link #isIgnoringConfig(StatementContextBase)}.
*/
- final boolean isConfiguration(final StatementContextBase, ?, ?> parent) {
- final int fl = flags & SET_CONFIGURATION;
- if (fl != 0) {
- return fl == SET_CONFIGURATION;
- }
- if (isIgnoringConfig(parent)) {
- // Note: SET_CONFIGURATION has been stored in flags
- return true;
- }
-
- final boolean isConfig;
- final Optional
* Note: use of this method implies that {@link #isConfiguration()} is realized with
- * {@link #isConfiguration(StatementContextBase)}.
+ * {@link #effectiveConfig(StatementContextBase)}.
*/
final boolean isIgnoringConfig(final StatementContextBase, ?, ?> parent) {
- final int fl = flags & SET_IGNORE_CONFIG;
- if (fl != 0) {
- return fl == SET_IGNORE_CONFIG;
- }
- if (definition().support().isIgnoringConfig() || parent.isIgnoringConfig()) {
- flags |= SET_IGNORE_CONFIG;
- return true;
- }
-
- flags |= HAVE_IGNORE_CONFIG;
- return false;
+ return EffectiveConfig.IGNORED == effectiveConfig(parent);
}
protected abstract boolean isIgnoringIfFeatures();
@@ -471,7 +509,7 @@ abstract class ReactorStmtCtx, E extends Effec
return false;
}
- // These two exists only due to memory optimization, should live in AbstractResumedStatement. We are also reusing
+ // These two exist only due to memory optimization, should live in AbstractResumedStatement. We are also reusing
// this for ReplicaStatementContext's refcount tracking.
final boolean fullyDefined() {
return fullyDefined;
@@ -481,6 +519,37 @@ abstract class ReactorStmtCtx, E extends Effec
fullyDefined = true;
}
+ // These two exist only for StatementContextBase. Since we are squeezed for size, with only a single bit available
+ // in flags, we default to 'false' and only set the flag to true when we are absolutely sure -- and all other cases
+ // err on the side of caution by taking the time to evaluate each substatement separately.
+ final boolean allSubstatementsContextIndependent() {
+ return (flags & ALL_INDEPENDENT) != 0;
+ }
+
+ final void setAllSubstatementsContextIndependent() {
+ flags |= ALL_INDEPENDENT;
+ }
+
+ //
+ //
+ // Various functionality from AbstractTypeStatementSupport. This used to work on top of SchemaPath, now it still
+ // lives here. Ultimate future is either proper graduation or (more likely) move to AbstractTypeStatementSupport.
+ //
+ //
+
+ @Override
+ public final QName argumentAsTypeQName() {
+ final Object argument = argument();
+ verify(argument instanceof String, "Unexpected argument %s", argument);
+ return interpretAsQName((String) argument);
+ }
+
+ @Override
+ public final QNameModule effectiveNamespace() {
+ // FIXME: there has to be a better way to do this
+ return getSchemaPath().getLastComponent().getModule();
+ }
+
//
//
// Common SchemaPath cache. All of this is bound to be removed once YANGTOOLS-1066 is done.
@@ -489,26 +558,17 @@ abstract class ReactorStmtCtx, E extends Effec
// Exists only to support {SubstatementContext,InferredStatementContext}.schemaPath()
@Deprecated
- final @NonNull Optional