/// <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); }
/// <summary> /// Finds the matching nodes of a <see cref="IKeywordEntityExpression"/>. /// </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> public static bool ResolveCompilerReferences(IKeywordEntityExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant, out ICompiledFeature resolvedFinalFeature) { if (node == null) { throw new ArgumentNullException(nameof(node)); } if (errorList == null) { throw new ArgumentNullException(nameof(errorList)); } resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; resolvedFinalFeature = null; IClass EmbeddingClass = node.EmbeddingClass; BaseNode.Keyword Value = node.Value; if (!Expression.IsLanguageTypeAvailable(LanguageClasses.Entity.Guid, node, out ITypeName ResultTypeName, out ICompiledType ResultType)) { errorList.AddError(new ErrorEntityTypeMissing(node)); return(false); } Guid EntityGuid = Guid.Empty; switch (node.Value) { case BaseNode.Keyword.Indexer: if (EmbeddingClass.ClassIndexer.IsAssigned) { IIndexerFeature ClassIndexer = EmbeddingClass.ClassIndexer.Item; resolvedFinalFeature = ClassIndexer; EntityGuid = ClassIndexer.EntityGuid; expressionConstant = new EntityLanguageConstant(ClassIndexer); } else { errorList.AddError(new ErrorMissingIndexer(node)); return(false); } break; default: errorList.AddError(new ErrorInvalidExpression(node)); return(false); } Debug.Assert(EntityGuid != Guid.Empty); ITypeName EntityTypeName = EmbeddingClass.ImportedLanguageTypeTable[EntityGuid].Item1; ICompiledType EntityType = EmbeddingClass.ImportedLanguageTypeTable[EntityGuid].Item2; resolvedResult = new ResultType(EntityTypeName, EntityType, string.Empty); resolvedException = new ResultException(); #if COVERAGE Debug.Assert(!node.IsComplex); #endif return(true); }