/// <summary> /// Merges two lists of exceptions if they are available. /// </summary> /// <param name="mergedResult">The list of exceptions to update.</param> /// <param name="other">The optional list of exceptions to merge.</param> public static void Merge(IResultException mergedResult, OnceReference <IResultException> other) { if (other.IsAssigned) { Merge(mergedResult, other.Item); } }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IInitializedObjectExpression node, object data) { IResultType ResolvedResult = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item1; IResultException ResolvedException = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item2; ISealableList <IExpression> ConstantSourceList = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item3; ILanguageConstant ExpressionConstant = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item4; ITypeName InitializedObjectTypeName = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item5; IClassType InitializedObjectType = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item6; ISealableDictionary <string, ICompiledFeature> AssignedFeatureTable = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item7; node.ResolvedResult.Item = ResolvedResult; node.ConstantSourceList.AddRange(ConstantSourceList); node.ConstantSourceList.Seal(); node.ResolvedClassTypeName.Item = InitializedObjectTypeName; node.ResolvedClassType.Item = InitializedObjectType; Debug.Assert(node.AssignedFeatureTable.Count == 0); node.AssignedFeatureTable.Merge(AssignedFeatureTable); node.AssignedFeatureTable.Seal(); IClass BaseClass = InitializedObjectType.BaseClass; BaseClass.InitializedObjectList.Add(node); }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IPrecursorIndexAssignmentInstruction node, object data) { IResultException ResolvedException = ((Tuple <IResultException, IFeatureCall>)data).Item1; IFeatureCall FeatureCall = ((Tuple <IResultException, IFeatureCall>)data).Item2; node.ResolvedException.Item = ResolvedException; node.FeatureCall.Item = FeatureCall; }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IKeywordEntityExpression node, object data) { IResultType ResolvedResult = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant>)data).Item1; IResultException ResolvedException = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant>)data).Item2; ISealableList <IExpression> ConstantSourceList = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant>)data).Item3; ILanguageConstant ExpressionConstant = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant>)data).Item4; node.ResolvedException.Item = ResolvedException; }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IAgentExpression node, object data) { IResultType ResolvedResult = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature>)data).Item1; IResultException ResolvedException = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature>)data).Item2; ISealableList <IExpression> ConstantSourceList = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature>)data).Item3; ILanguageConstant ExpressionConstant = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature>)data).Item4; ICompiledFeature ResolvedFeature = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature>)data).Item5; node.ResolvedException.Item = ResolvedException; }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IThrowInstruction node, object data) { ICompiledType ResolvedType = ((Tuple <ICompiledType, IResultException, IFeatureCall>)data).Item1; IResultException ResolvedException = ((Tuple <ICompiledType, IResultException, IFeatureCall>)data).Item2; IFeatureCall FeatureCall = ((Tuple <ICompiledType, IResultException, IFeatureCall>)data).Item3; node.ResolvedType.Item = ResolvedType; node.ResolvedException.Item = ResolvedException; node.FeatureCall.Item = FeatureCall; }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IAssertionTagExpression node, object data) { IResultType ResolvedResult = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant>)data).Item1; IResultException ResolvedException = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant>)data).Item2; ISealableList <IExpression> ConstantSourceList = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant>)data).Item3; ILanguageConstant ExpressionConstant = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant>)data).Item4; node.ResolvedResult.Item = ResolvedResult; node.ConstantSourceList.AddRange(ConstantSourceList); node.ConstantSourceList.Seal(); }
/// <summary> /// Propagates a list of exceptions if they are available. /// </summary> /// <param name="other">The optionally assigned list of exception.</param> /// <param name="result">The list of exceptions if available; Otherwise, null.</param> public static void Propagate(OnceReference <IResultException> other, out IResultException result) { if (other.IsAssigned) { result = other.Item; } else { result = null; } }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IUnaryOperatorExpression node, object data) { IResultType ResolvedResult = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IQueryOverloadType>)data).Item1; IResultException ResolvedException = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IQueryOverloadType>)data).Item2; ISealableList <IExpression> ConstantSourceList = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IQueryOverloadType>)data).Item3; ILanguageConstant ExpressionConstant = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IQueryOverloadType>)data).Item4; IFunctionFeature SelectedFeature = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IQueryOverloadType>)data).Item5; IQueryOverload SelectedOverload = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IQueryOverloadType>)data).Item6; IQueryOverloadType SelectedOverloadType = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IQueryOverloadType>)data).Item7; node.ResolvedException.Item = ResolvedException; }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IInitializedObjectExpression node, object data) { IResultType ResolvedResult = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item1; IResultException ResolvedException = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item2; ISealableList <IExpression> ConstantSourceList = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item3; ILanguageConstant ExpressionConstant = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item4; ITypeName InitializedObjectTypeName = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item5; IClassType InitializedObjectType = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item6; ISealableDictionary <string, ICompiledFeature> AssignedFeatureTable = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ITypeName, IClassType, ISealableDictionary <string, ICompiledFeature> >)data).Item7; node.ResolvedException.Item = ResolvedException; }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(INewExpression node, object data) { IResultType ResolvedResult = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature>)data).Item1; IResultException ResolvedException = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature>)data).Item2; ISealableList <IExpression> ConstantSourceList = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature>)data).Item3; ILanguageConstant ExpressionConstant = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature>)data).Item4; ICompiledFeature ResolvedFinalFeature = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature>)data).Item5; node.ResolvedResult.Item = ResolvedResult; node.ConstantSourceList.AddRange(ConstantSourceList); node.ConstantSourceList.Seal(); node.ExpressionConstant.Item = ExpressionConstant; }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IPrecursorInstruction node, object data) { IResultException ResolvedException = ((Tuple <IResultException, IFeatureCall>)data).Item1; IFeatureCall FeatureCall = ((Tuple <IResultException, IFeatureCall>)data).Item2; node.ResolvedException.Item = ResolvedException; node.FeatureCall.Item = FeatureCall; IFeature EmbeddingFeature = node.EmbeddingFeature; IFeatureWithPrecursor ResolvedFeature = EmbeddingFeature.ResolvedFeature.Item as IFeatureWithPrecursor; Debug.Assert(ResolvedFeature != null); ResolvedFeature.MarkAsCallingPrecursor(); }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IClassConstantExpression node, object data) { IResultType ResolvedResult = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, Tuple <IConstantFeature, IDiscrete, ITypeName, IClassType> >)data).Item1; IResultException ResolvedException = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, Tuple <IConstantFeature, IDiscrete, ITypeName, IClassType> >)data).Item2; ISealableList <IExpression> ConstantSourceList = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, Tuple <IConstantFeature, IDiscrete, ITypeName, IClassType> >)data).Item3; ILanguageConstant ExpressionConstant = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, Tuple <IConstantFeature, IDiscrete, ITypeName, IClassType> >)data).Item4; Tuple <IConstantFeature, IDiscrete, ITypeName, IClassType> AdditionalData = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, Tuple <IConstantFeature, IDiscrete, ITypeName, IClassType> >)data).Item5; IConstantFeature ResolvedFinalFeature = AdditionalData.Item1; IDiscrete ResolvedFinalDiscrete = AdditionalData.Item2; ITypeName ResolvedClassTypeName = AdditionalData.Item3; IClassType ResolvedClassType = AdditionalData.Item4; node.ResolvedException.Item = ResolvedException; }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(ICommandInstruction node, object data) { IResultException ResolvedException = ((Tuple <IResultException, ICompiledFeature, ICommandOverloadType, IFeatureCall, IProcedureType>)data).Item1; ICompiledFeature SelectedFeature = ((Tuple <IResultException, ICompiledFeature, ICommandOverloadType, IFeatureCall, IProcedureType>)data).Item2; ICommandOverloadType SelectedOverload = ((Tuple <IResultException, ICompiledFeature, ICommandOverloadType, IFeatureCall, IProcedureType>)data).Item3; IFeatureCall FeatureCall = ((Tuple <IResultException, ICompiledFeature, ICommandOverloadType, IFeatureCall, IProcedureType>)data).Item4; IProcedureType CommandFinalType = ((Tuple <IResultException, ICompiledFeature, ICommandOverloadType, IFeatureCall, IProcedureType>)data).Item5; node.ResolvedException.Item = ResolvedException; node.SelectedFeature.Item = SelectedFeature; node.SelectedOverload.Item = SelectedOverload; node.FeatureCall.Item = FeatureCall; node.CommandFinalType.Item = CommandFinalType; }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IBinaryOperatorExpression node, object data) { IResultType ResolvedResult = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IFeatureCall>)data).Item1; IResultException ResolvedException = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IFeatureCall>)data).Item2; ISealableList <IExpression> ConstantSourceList = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IFeatureCall>)data).Item3; ILanguageConstant ExpressionConstant = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IFeatureCall>)data).Item4; IFunctionFeature SelectedFeature = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IFeatureCall>)data).Item5; IQueryOverload SelectedOverload = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IFeatureCall>)data).Item6; IFeatureCall FeatureCall = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, IFunctionFeature, IQueryOverload, IFeatureCall>)data).Item7; node.ResolvedResult.Item = ResolvedResult; node.ConstantSourceList.AddRange(ConstantSourceList); node.ConstantSourceList.Seal(); node.SelectedFeature.Item = SelectedFeature; node.SelectedOverload.Item = SelectedOverload; node.FeatureCall.Item = FeatureCall; }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IClassConstantExpression node, object data) { IResultType ResolvedResult = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, Tuple <IConstantFeature, IDiscrete, ITypeName, IClassType> >)data).Item1; IResultException ResolvedException = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, Tuple <IConstantFeature, IDiscrete, ITypeName, IClassType> >)data).Item2; ISealableList <IExpression> ConstantSourceList = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, Tuple <IConstantFeature, IDiscrete, ITypeName, IClassType> >)data).Item3; ILanguageConstant ExpressionConstant = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, Tuple <IConstantFeature, IDiscrete, ITypeName, IClassType> >)data).Item4; Tuple <IConstantFeature, IDiscrete, ITypeName, IClassType> AdditionalData = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, Tuple <IConstantFeature, IDiscrete, ITypeName, IClassType> >)data).Item5; IConstantFeature ResolvedFinalFeature = AdditionalData.Item1; IDiscrete ResolvedFinalDiscrete = AdditionalData.Item2; ITypeName ResolvedClassTypeName = AdditionalData.Item3; IClassType ResolvedClassType = AdditionalData.Item4; node.ResolvedResult.Item = ResolvedResult; node.ConstantSourceList.AddRange(ConstantSourceList); node.ConstantSourceList.Seal(); if (ConstantSourceList.Count == 0) { IDiscreteLanguageConstant DiscreteLanguageConstant = ExpressionConstant as IDiscreteLanguageConstant; Debug.Assert(DiscreteLanguageConstant != null); Debug.Assert(DiscreteLanguageConstant.IsValueKnown); node.ExpressionConstant.Item = ExpressionConstant; } else { Debug.Assert(ConstantSourceList.Count == 1); } node.ResolvedClassTypeName.Item = ResolvedClassTypeName; node.ResolvedClassType.Item = ResolvedClassType; Debug.Assert(ResolvedFinalFeature != null || ResolvedFinalDiscrete != null); if (ResolvedFinalFeature != null) { node.ResolvedFinalFeature.Item = ResolvedFinalFeature; } if (ResolvedFinalDiscrete != null) { node.ResolvedFinalDiscrete.Item = ResolvedFinalDiscrete; } }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IEntityExpression node, object data) { IResultType ResolvedResult = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature, IDiscrete>)data).Item1; IResultException ResolvedException = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature, IDiscrete>)data).Item2; ISealableList <IExpression> ConstantSourceList = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature, IDiscrete>)data).Item3; ILanguageConstant ExpressionConstant = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature, IDiscrete>)data).Item4; ICompiledFeature ResolvedFinalFeature = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature, IDiscrete>)data).Item5; IDiscrete ResolvedFinalDiscrete = ((Tuple <IResultType, IResultException, ISealableList <IExpression>, ILanguageConstant, ICompiledFeature, IDiscrete>)data).Item6; node.ResolvedException.Item = ResolvedException; if (ResolvedFinalFeature != null) { node.ResolvedFinalFeature.Item = ResolvedFinalFeature; } if (ResolvedFinalDiscrete != null) { node.ResolvedFinalDiscrete.Item = ResolvedFinalDiscrete; } }
/// <summary> /// Finds the matching nodes of a <see cref="IManifestNumberExpression"/>. /// </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 constant type upon return.</param> public static bool ResolveCompilerReferences(IManifestNumberExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant) { resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; IClass EmbeddingClass = node.EmbeddingClass; string NumberText = node.ValidText.Item; ISealableDictionary <ITypeName, ICompiledType> TypeTable = EmbeddingClass.TypeTable; if (!Expression.IsLanguageTypeAvailable(LanguageClasses.Number.Guid, node, out ITypeName NumberTypeName, out ICompiledType NumberType)) { errorList.AddError(new ErrorNumberTypeMissing(node)); return(false); } resolvedResult = new ResultType(NumberTypeName, NumberType, string.Empty); resolvedException = new ResultException(); FormattedNumber FormattedNumber = FormattedNumber.Parse(NumberText); Debug.Assert(string.IsNullOrEmpty(FormattedNumber.InvalidText)); expressionConstant = new NumberLanguageConstant(FormattedNumber.Value); #if COVERAGE Debug.Assert(!node.IsComplex); #endif return(true); }
/// <summary> /// Finds the matching nodes of a <see cref="IUnaryOperatorExpression"/>. /// </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 constant value upon return, if any.</param> /// <param name="selectedFeature">The matching feature upon return.</param> /// <param name="selectedOverload">The matching overload in <paramref name="selectedFeature"/> upon return.</param> /// <param name="selectedOverloadType">The matching overload type upon return.</param> public static bool ResolveCompilerReferences(IUnaryOperatorExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant, out IFunctionFeature selectedFeature, out IQueryOverload selectedOverload, out IQueryOverloadType selectedOverloadType) { resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; selectedFeature = null; selectedOverload = null; selectedOverloadType = null; IIdentifier Operator = (IIdentifier)node.Operator; string ValidText = Operator.ValidText.Item; IExpression RightExpression = (IExpression)node.RightExpression; IResultType RightResult = RightExpression.ResolvedResult.Item; if (!RightResult.TryGetResult(out ICompiledType RightExpressionType)) { errorList.AddError(new ErrorInvalidExpression(RightExpression)); return(false); } if (RightExpressionType is IClassType AsClassType) { ISealableDictionary <IFeatureName, IFeatureInstance> RightFeatureTable = AsClassType.FeatureTable; if (!FeatureName.TableContain(RightFeatureTable, ValidText, out IFeatureName Key, out IFeatureInstance Value)) { errorList.AddError(new ErrorUnknownIdentifier(RightExpression, ValidText)); return(false); } ICompiledFeature OperatorFeature = Value.Feature; ICompiledType OperatorType = OperatorFeature.ResolvedAgentType.Item; if (OperatorFeature is IFunctionFeature AsFunctionFeature && OperatorType is IFunctionType AsFunctionType) { IList <IQueryOverloadType> OperatorOverloadList = AsFunctionType.OverloadList; int SelectedOperatorIndex = -1; for (int i = 0; i < OperatorOverloadList.Count; i++) { IQueryOverloadType Overload = OperatorOverloadList[i]; if (Overload.ParameterList.Count == 0 && Overload.ResultList.Count == 1) { SelectedOperatorIndex = i; break; } } if (SelectedOperatorIndex < 0) { errorList.AddError(new ErrorInvalidOperator(Operator, ValidText)); return(false); } resolvedResult = Feature.CommonResultType(AsFunctionType.OverloadList); selectedFeature = AsFunctionFeature; selectedOverload = AsFunctionFeature.OverloadList[SelectedOperatorIndex]; selectedOverloadType = OperatorOverloadList[SelectedOperatorIndex]; resolvedException = new ResultException(selectedOverloadType.ExceptionIdentifierList); constantSourceList.Add(RightExpression); } else { errorList.AddError(new ErrorInvalidOperator(Operator, ValidText)); return(false); } }
/// <summary> /// Finds the matching nodes of a <see cref="IUnaryNotExpression"/>. /// </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 constant value upon return, if any.</param> public static bool ResolveCompilerReferences(IUnaryNotExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant) { resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; IExpression RightExpression = (IExpression)node.RightExpression; IClass EmbeddingClass = node.EmbeddingClass; bool IsRightClassType = Expression.GetClassTypeOfExpression(RightExpression, errorList, out IClassType RightExpressionClassType); if (!IsRightClassType) { return(false); } Expression.IsLanguageTypeAvailable(LanguageClasses.Boolean.Guid, node, out ITypeName BooleanTypeName, out ICompiledType BooleanType); Expression.IsLanguageTypeAvailable(LanguageClasses.Event.Guid, node, out ITypeName EventTypeName, out ICompiledType EventType); Debug.Assert(RightExpressionClassType == BooleanType || RightExpressionClassType == EventType); node.SetIsEventExpression(RightExpressionClassType != BooleanType); constantSourceList.Add(RightExpression); resolvedResult = new ResultType(BooleanTypeName, BooleanType, string.Empty); ResultException.Propagate(RightExpression.ResolvedException, out resolvedException); #if COVERAGE Debug.Assert(node.IsComplex); #endif return(true); }
/// <summary> /// Finds the matching nodes of a <see cref="IEqualityExpression"/>. /// </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 constant value upon return, if any.</param> public static bool ResolveCompilerReferences(IEqualityExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant) { resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; IExpression LeftExpression = (IExpression)node.LeftExpression; IExpression RightExpression = (IExpression)node.RightExpression; IClass EmbeddingClass = node.EmbeddingClass; IResultType LeftResult = LeftExpression.ResolvedResult.Item; IResultType RightResult = RightExpression.ResolvedResult.Item; if (LeftResult.Count != RightResult.Count) { errorList.AddError(new ErrorExpressionResultMismatch(node)); return(false); } if (!Expression.IsLanguageTypeAvailable(LanguageClasses.Boolean.Guid, node, out ITypeName ResultTypeName, out ICompiledType ResultType)) { errorList.AddError(new ErrorBooleanTypeMissing(node)); return(false); } if (LeftResult.Count > 1) { int MismatchingResultCount = 0; foreach (IExpressionType LeftItem in LeftResult) { ICompiledType LeftExpressionType = LeftItem.ValueType; bool MatchingNameFound = false; foreach (IExpressionType RightItem in RightResult) { if (LeftItem.Name == RightItem.Name) { MatchingNameFound = true; ICompiledType RightExpressionType = RightItem.ValueType; if (!ObjectType.TypeConformToBase(LeftExpressionType, RightExpressionType, isConversionAllowed: true) && !ObjectType.TypeConformToBase(RightExpressionType, LeftExpressionType, isConversionAllowed: true)) { MismatchingResultCount++; } break; } } if (!MatchingNameFound) { MismatchingResultCount++; } } if (MismatchingResultCount > 0) { errorList.AddError(new ErrorExpressionResultMismatch(node)); return(false); } } resolvedResult = new ResultType(ResultTypeName, ResultType, string.Empty); constantSourceList.Add(LeftExpression); constantSourceList.Add(RightExpression); resolvedException = new ResultException(); ResultException.Merge(resolvedException, LeftExpression.ResolvedException); ResultException.Merge(resolvedException, RightExpression.ResolvedException); #if COVERAGE Debug.Assert(node.IsComplex); #endif return(true); }
/// <summary> /// Finds the matching nodes of a <see cref="IAgentExpression"/>. /// </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 constant value upon return, if any.</param> /// <param name="resolvedFeature">The feature found upon return.</param> public static bool ResolveCompilerReferences(IAgentExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant, out ICompiledFeature resolvedFeature) { resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; resolvedFeature = null; IIdentifier Delegated = (IIdentifier)node.Delegated; Debug.Assert(Delegated.ValidText.IsAssigned); string ValidText = Delegated.ValidText.Item; IFeatureInstance FeatureInstance; if (node.BaseType.IsAssigned) { IObjectType BaseType = (IObjectType)node.BaseType.Item; ICompiledType ResolvedBaseType = BaseType.ResolvedType.Item; ISealableDictionary <IFeatureName, IFeatureInstance> FeatureTable = null; switch (ResolvedBaseType) { case IClassType AsClassType: FeatureTable = AsClassType.FeatureTable; break; case IFormalGenericType AsFormalGenericType: foreach (IConstraint Item in AsFormalGenericType.FormalGeneric.ConstraintList) { if (Item.ResolvedTypeWithRename.Item is IClassType Parent) { FeatureTable = Parent.FeatureTable; if (FeatureName.TableContain(FeatureTable, ValidText, out IFeatureName ParentKey, out IFeatureInstance ParentFeatureInstance)) { break; } } } break; } if (FeatureTable == null) { errorList.AddError(new ErrorClassTypeRequired(node)); return(false); } if (!FeatureName.TableContain(FeatureTable, ValidText, out IFeatureName Key, out FeatureInstance)) { errorList.AddError(new ErrorUnknownIdentifier(node, ValidText)); return(false); } } else { IClass EmbeddingClass = node.EmbeddingClass; if (!FeatureName.TableContain(EmbeddingClass.FeatureTable, ValidText, out IFeatureName Key, out FeatureInstance)) { errorList.AddError(new ErrorUnknownIdentifier(node, ValidText)); return(false); } } Debug.Assert(FeatureInstance.Feature != null); resolvedFeature = FeatureInstance.Feature; resolvedResult = new ResultType(resolvedFeature.ResolvedAgentTypeName.Item, resolvedFeature.ResolvedAgentType.Item, string.Empty); resolvedException = new ResultException(); expressionConstant = new AgentLanguageConstant(resolvedFeature); #if COVERAGE Debug.Assert(!node.IsComplex); #endif return(true); }
/// <summary> /// Finds the matching nodes of a <see cref="IKeywordExpression"/>. /// </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> public static bool ResolveCompilerReferences(IKeywordExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant) { resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; IClass EmbeddingClass = node.EmbeddingClass; BaseNode.Keyword Value = node.Value; if (!IsKeywordAvailable(Value, node, errorList, out ITypeName KeywordTypeName, out ICompiledType KeywordType)) { return(false); } resolvedResult = new ResultType(KeywordTypeName, KeywordType, Value.ToString()); resolvedException = new ResultException(); bool IsHandled = false; switch (Value) { case BaseNode.Keyword.True: case BaseNode.Keyword.False: expressionConstant = new BooleanLanguageConstant(Value == BaseNode.Keyword.True); IsHandled = true; break; case BaseNode.Keyword.Current: case BaseNode.Keyword.Value: case BaseNode.Keyword.Result: case BaseNode.Keyword.Retry: case BaseNode.Keyword.Exception: case BaseNode.Keyword.Indexer: IsHandled = true; break; } Debug.Assert(IsHandled); #if COVERAGE Debug.Assert(!node.IsComplex); #endif return(true); }
/// <summary> /// Finds the matching nodes of a <see cref="IBinaryConditionalExpression"/>. /// </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 constant value upon return, if any.</param> public static bool ResolveCompilerReferences(IBinaryConditionalExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant) { resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; IExpression LeftExpression = (IExpression)node.LeftExpression; BaseNode.ConditionalTypes Conditional = node.Conditional; IExpression RightExpression = (IExpression)node.RightExpression; IClass EmbeddingClass = node.EmbeddingClass; bool IsLeftClassType = Expression.GetClassTypeOfExpression(LeftExpression, errorList, out IClassType LeftExpressionClassType); bool IsRightClassType = Expression.GetClassTypeOfExpression(RightExpression, errorList, out IClassType RightExpressionClassType); if (!IsLeftClassType || !IsRightClassType) { return(false); } Expression.IsLanguageTypeAvailable(LanguageClasses.Boolean.Guid, node, out ITypeName BooleanTypeName, out ICompiledType BooleanType); Expression.IsLanguageTypeAvailable(LanguageClasses.Event.Guid, node, out ITypeName EventTypeName, out ICompiledType EventType); Debug.Assert(LeftExpressionClassType == BooleanType || LeftExpressionClassType == EventType); Debug.Assert(RightExpressionClassType == BooleanType || RightExpressionClassType == EventType); if (LeftExpressionClassType != RightExpressionClassType) { errorList.AddError(new ErrorInvalidExpression(LeftExpression)); return(false); } bool IsEventExpression = LeftExpressionClassType != BooleanType; if (IsEventExpression) { if (!((node.ParentSource is IBinaryConditionalExpression) || (node.ParentSource is IConditional) || (node.ParentSource is ICheckInstruction))) { errorList.AddError(new ErrorInvalidExpression(node)); return(false); } resolvedResult = new ResultType(EventTypeName, EventType, string.Empty); } else { resolvedResult = new ResultType(BooleanTypeName, BooleanType, string.Empty); } constantSourceList.Add(LeftExpression); constantSourceList.Add(RightExpression); resolvedException = new ResultException(); ResultException.Merge(resolvedException, LeftExpression.ResolvedException); ResultException.Merge(resolvedException, RightExpression.ResolvedException); #if COVERAGE Debug.Assert(node.IsComplex); #endif return(true); }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IScope node, object data) { IResultException ResolvedException = (IResultException)data; node.ResolvedException.Item = ResolvedException; }
/// <summary> /// Finds the matching nodes of a <see cref="IManifestCharacterExpression"/>. /// </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> public static bool ResolveCompilerReferences(IManifestCharacterExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant) { resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; IClass EmbeddingClass = node.EmbeddingClass; string ValidText = node.ValidText.Item; Debug.Assert(ValidText.Length == 1); char ValidChar = ValidText[0]; if (!Expression.IsLanguageTypeAvailable(LanguageClasses.Character.Guid, node, out ITypeName CharacterTypeName, out ICompiledType CharacterType)) { errorList.AddError(new ErrorCharacterTypeMissing(node)); return(false); } resolvedResult = new ResultType(CharacterTypeName, CharacterType, string.Empty); resolvedException = new ResultException(); expressionConstant = new CharacterLanguageConstant(ValidChar); #if COVERAGE Debug.Assert(!node.IsComplex); #endif return(true); }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IKeywordAssignmentInstruction node, object data) { IResultException ResolvedException = (IResultException)data; node.ResolvedException.Item = ResolvedException; }
/// <summary> /// Finds the matching nodes of a <see cref="IResultOfExpression"/>. /// </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> public static bool ResolveCompilerReferences(IResultOfExpression node, IErrorList errorList, out IResultType resolvedResult, out IResultException resolvedException, out ISealableList <IExpression> constantSourceList, out ILanguageConstant expressionConstant) { resolvedResult = null; resolvedException = null; constantSourceList = new SealableList <IExpression>(); expressionConstant = NeutralLanguageConstant.NotConstant; IExpression Source = (IExpression)node.Source; IResultType ResolvedSourceResult = Source.ResolvedResult.Item; int ResultNameIndex = ResolvedSourceResult.ResultNameIndex; if (ResultNameIndex < 0) { errorList.AddError(new ErrorInvalidExpression(node)); return(false); } Debug.Assert(ResolvedSourceResult.Preferred != null); resolvedResult = new ResultType(ResolvedSourceResult.Preferred); constantSourceList.Add(Source); ResultException.Propagate(Source.ResolvedException, out resolvedException); #if COVERAGE Debug.Assert(node.IsComplex); #endif return(true); }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IOverLoopInstruction node, object data) { IResultException ResolvedException = (IResultException)data; node.ResolvedException.Item = ResolvedException; }
/// <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); }