/// <summary> /// Finds the matching nodes of a <see cref="IOldExpression"/>. /// </summary> /// <param name="node">The agent expression to check.</param> /// <param name="errorList">The list of errors found.</param> /// <param name="resolvedExpression">The result of the search.</param> public static bool ResolveCompilerReferences(IOldExpression node, IErrorList errorList, out ResolvedExpression resolvedExpression) { resolvedExpression = new ResolvedExpression(); IClass EmbeddingClass = node.EmbeddingClass; IQualifiedName Query = (IQualifiedName)node.Query; IList <IIdentifier> ValidPath = Query.ValidPath.Item; IClassType BaseType = EmbeddingClass.ResolvedClassType.Item; if (!Expression.IsLanguageTypeAvailable(LanguageClasses.Boolean.Guid, node, out ITypeName BooleanTypeName, out ICompiledType BooleanType)) { errorList.AddError(new ErrorBooleanTypeMissing(node)); return(false); } ISealableDictionary <string, IScopeAttributeFeature> LocalScope = Scope.CurrentScope(node); Debug.Assert(LocalScope != null); if (node.EmbeddingBody == null && node.EmbeddingAssertion == null) { errorList.AddError(new ErrorInvalidOldExpression(node)); return(false); } if (!ObjectType.GetQualifiedPathFinalType(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, errorList, out ICompiledFeature FinalFeature, out IDiscrete FinalDiscrete, out ITypeName FinalTypeName, out ICompiledType FinalType, out bool InheritBySideAttribute)) { return(false); } if (FinalFeature == null) { errorList.AddError(new ErrorInvalidOldExpression(node)); return(false); } ObjectType.FillResultPath(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, Query.ValidResultTypePath.Item); resolvedExpression.ResolvedFinalFeature = FinalFeature; resolvedExpression.ResolvedResult = new ResultType(FinalTypeName, FinalType, string.Empty); resolvedExpression.ResolvedException = new ResultException(); #if COVERAGE Debug.Assert(!node.IsComplex); #endif return(true); }
/// <summary> /// Finds the matching nodes of a <see cref="INewExpression"/>. /// </summary> /// <param name="node">The agent expression to check.</param> /// <param name="errorList">The list of errors found.</param> /// <param name="resolvedResult">The expression result types upon return.</param> /// <param name="resolvedException">Exceptions the expression can throw upon return.</param> /// <param name="constantSourceList">Sources of the constant expression upon return, if any.</param> /// <param name="expressionConstant">The expression constant upon return.</param> /// <param name="resolvedFinalFeature">The matching feature upon return.</param> public static bool ResolveCompilerReferences(INewExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant, out ICompiledFeature resolvedFinalFeature) { resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; resolvedFinalFeature = null; IClass EmbeddingClass = node.EmbeddingClass; IQualifiedName Object = (IQualifiedName)node.Object; IList <IIdentifier> ValidPath = Object.ValidPath.Item; IClassType BaseType = EmbeddingClass.ResolvedClassType.Item; if (!Expression.IsLanguageTypeAvailable(LanguageClasses.Boolean.Guid, node, out ITypeName BooleanTypeName, out ICompiledType BooleanType)) { errorList.AddError(new ErrorBooleanTypeMissing(node)); return(false); } ISealableDictionary <string, IScopeAttributeFeature> LocalScope = Scope.CurrentScope(node); if (!ObjectType.GetQualifiedPathFinalType(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, errorList, out ICompiledFeature FinalFeature, out IDiscrete FinalDiscrete, out ITypeName FinalTypeName, out ICompiledType FinalType, out bool InheritBySideAttribute)) { return(false); } if (FinalFeature == null) { errorList.AddError(new ErrorConstantNewExpression(node)); return(false); } ObjectType.FillResultPath(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, Object.ValidResultTypePath.Item); resolvedResult = new ResultType(BooleanTypeName, BooleanType, string.Empty); resolvedException = new ResultException(); resolvedFinalFeature = FinalFeature; #if COVERAGE Debug.Assert(!node.IsComplex); #endif return(true); }
/// <summary> /// Finds the matching nodes of a <see cref="IQueryExpression"/>. /// </summary> /// <param name="node">The agent expression to check.</param> /// <param name="errorList">The list of errors found.</param> /// <param name="resolvedExpression">The result of the search.</param> public static bool ResolveCompilerReferences(IQueryExpression node, IErrorList errorList, out ResolvedExpression resolvedExpression) { resolvedExpression = new ResolvedExpression(); IQualifiedName Query = (IQualifiedName)node.Query; IList <IArgument> ArgumentList = node.ArgumentList; IClass EmbeddingClass = node.EmbeddingClass; IClassType BaseType = EmbeddingClass.ResolvedClassType.Item; IList <IIdentifier> ValidPath = Query.ValidPath.Item; ISealableDictionary <string, IScopeAttributeFeature> LocalScope = Scope.CurrentScope(node); if (!ObjectType.GetQualifiedPathFinalType(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, errorList, out ICompiledFeature FinalFeature, out IDiscrete FinalDiscrete, out ITypeName FinalTypeName, out ICompiledType FinalType, out bool InheritBySideAttribute)) { return(false); } Debug.Assert(FinalFeature != null || FinalDiscrete != null); #if COVERAGE Debug.Assert(!node.IsComplex); #endif if (FinalFeature != null) { resolvedExpression.ResolvedFinalFeature = FinalFeature; return(ResolveFeature(node, errorList, FinalFeature, FinalTypeName, FinalType, ref resolvedExpression)); } else { Debug.Assert(FinalDiscrete != null); resolvedExpression.ResolvedFinalDiscrete = FinalDiscrete; return(ResolveDiscrete(node, errorList, FinalDiscrete, ref resolvedExpression)); } }
/// <summary> /// Finds the matching nodes of a <see cref="IEntityExpression"/>. /// </summary> /// <param name="node">The agent expression to check.</param> /// <param name="errorList">The list of errors found.</param> /// <param name="resolvedResult">The expression result types upon return.</param> /// <param name="resolvedException">Exceptions the expression can throw upon return.</param> /// <param name="constantSourceList">Sources of the constant expression upon return, if any.</param> /// <param name="expressionConstant">The expression constant upon return.</param> /// <param name="resolvedFinalFeature">The feature if the end of the path is a feature.</param> /// <param name="resolvedFinalDiscrete">The discrete if the end of the path is a discrete.</param> public static bool ResolveCompilerReferences(IEntityExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant, out ICompiledFeature resolvedFinalFeature, out IDiscrete resolvedFinalDiscrete) { resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; resolvedFinalFeature = null; resolvedFinalDiscrete = null; IQualifiedName Query = (IQualifiedName)node.Query; IClass EmbeddingClass = (Class)node.EmbeddingClass; IClassType BaseType = EmbeddingClass.ResolvedClassType.Item; if (!Expression.IsLanguageTypeAvailable(LanguageClasses.Entity.Guid, node, out ITypeName ResultTypeName, out ICompiledType ResultType)) { errorList.AddError(new ErrorEntityTypeMissing(node)); return(false); } IList <IIdentifier> ValidPath = Query.ValidPath.Item; IIdentifier LastIdentifier = ValidPath[ValidPath.Count - 1]; string ValidText = LastIdentifier.ValidText.Item; ISealableDictionary <string, IScopeAttributeFeature> LocalScope = Scope.CurrentScope(node); if (!ObjectType.GetQualifiedPathFinalType(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, errorList, out ICompiledFeature FinalFeature, out IDiscrete FinalDiscrete, out ITypeName FinalTypeName, out ICompiledType FinalType, out bool InheritBySideAttribute)) { return(false); } Guid EntityGuid; if (FinalFeature is IFeatureWithEntity AsFeatureWithEntity) { ObjectType.FillResultPath(EmbeddingClass, BaseType, LocalScope, ValidPath, 0, Query.ValidResultTypePath.Item); resolvedFinalFeature = FinalFeature; EntityGuid = AsFeatureWithEntity.EntityGuid; expressionConstant = new EntityLanguageConstant(AsFeatureWithEntity); } else { Debug.Assert(FinalDiscrete != null); resolvedFinalDiscrete = FinalDiscrete; EntityGuid = LanguageClasses.NamedFeatureEntity.Guid; expressionConstant = new EntityLanguageConstant(resolvedFinalDiscrete); } ITypeName EntityTypeName = EmbeddingClass.ImportedLanguageTypeTable[EntityGuid].Item1; ICompiledType EntityType = EmbeddingClass.ImportedLanguageTypeTable[EntityGuid].Item2; resolvedResult = new ResultType(EntityTypeName, EntityType, ValidText); resolvedException = new ResultException(); #if COVERAGE Debug.Assert(!node.IsComplex); #endif return(true); }