/// <summary> /// Performs the semantic analysis of the statement /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance) { bool retVal = base.SemanticAnalysis(instance); if (retVal) { ListExpression.SemanticAnalysis(instance); Types.Collection collectionType = ListExpression.GetExpressionType() as Types.Collection; if (collectionType != null) { IteratorVariable.Type = collectionType.Type; } Value.SemanticAnalysis(instance); Types.Type valueType = Value.GetExpressionType(); if (valueType != null) { if (!valueType.Match(collectionType.Type)) { AddError("Type of " + Value + " does not match collection type " + collectionType); } } else { AddError("Cannot determine type of " + Value); } if (Condition != null) { Condition.SemanticAnalysis(instance); } } return(retVal); }
/// <summary> /// Provides the predefined item, based on its name /// </summary> /// <param name="name"></param> /// <returns></returns> public Utils.INamable getPredefinedItem(string name) { Utils.INamable namable = null; PredefinedItems.TryGetValue(name, out namable); return(namable); }
/// <summary> /// Performs the semantic analysis of the statement /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <returns>true if semantical analysis should be performed</returns> public virtual bool SemanticAnalysis(Utils.INamable instance = null) { bool retVal = !SemanticalAnalysisDone; SemanticalAnalysisDone = true; return(retVal); }
/// <summary> /// Provides the possible references types for this expression (used in semantic analysis) /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <param name="last">indicates that this is the last element in a dereference chain</param> /// <returns></returns> public virtual ReturnValue getReferenceTypes(Utils.INamable instance, Filter.AcceptableChoice expectation, bool last) { ReturnValue retVal = new ReturnValue(this); SemanticAnalysis(instance, Filter.AllMatches); retVal.Add(GetExpressionType()); return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation) { bool retVal = base.SemanticAnalysis(instance, expectation); if (retVal) { Value = new Values.StringValue(EFSSystem.StringType, Image); } return(retVal); }
/// <summary> /// Performs the semantic analysis of the statement /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance) { bool retVal = base.SemanticAnalysis(instance); if (retVal) { Call.SemanticAnalysis(instance); } return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <returns>True if semantic analysis should be continued</returns> public virtual bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation) { bool retVal = !SemanticAnalysisDone; if (retVal) { SemanticAnalysisDone = true; } return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation) { bool retVal = base.SemanticAnalysis(instance, expectation); if (retVal) { IteratorExpression.SemanticAnalysis(instance, Filter.AllMatches); } return(retVal); }
/// <summary> /// Performs the semantic analysis of the term /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <param name="expectation">Indicates the kind of element we are looking for</paraparam> /// <param name="lastElement">Indicates that this element is the last one in a dereference chain</param> /// <returns>True if semantic analysis should be continued</returns> public void SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation, bool lastElement) { if (Designator != null) { Designator.SemanticAnalysis(instance, expectation, lastElement); } else if (LiteralValue != null) { LiteralValue.SemanticAnalysis(instance, expectation); } }
/// <summary> /// Performs the semantic analysis of the statement /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance) { bool retVal = base.SemanticAnalysis(instance); if (retVal) { VariableIdentification.SemanticAnalysis(instance, Filter.IsLeftSide); Expression.SemanticAnalysis(instance, Filter.IsRightSide); } return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation) { bool retVal = base.SemanticAnalysis(instance, expectation); if (retVal) { Left.SemanticAnalysis(instance, Filter.IsRightSide); Right.SemanticAnalysis(instance, Filter.IsRightSide); } return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation) { bool retVal = base.SemanticAnalysis(instance, expectation); if (retVal) { AccumulatorVariable.Type = IteratorExpression.GetExpressionType(); Accumulator.SemanticAnalysis(instance, Filter.AllMatches); } return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation) { bool retVal = base.SemanticAnalysis(instance, expectation); if (retVal) { if (Condition != null) { Condition.SemanticAnalysis(instance, expectation); } } return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation) { bool retVal = base.SemanticAnalysis(instance, expectation); if (retVal) { Structure.SemanticAnalysis(instance, Filter.IsStructure); foreach (Expression expr in Associations.Values) { expr.SemanticAnalysis(instance, Filter.IsRightSide); } } return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation) { bool retVal = base.SemanticAnalysis(instance, expectation); if (retVal) { Value = Type.getValue(Image); if (Value == null) { AddError("Cannot evaluate " + ToString() + " as a number"); } } return(retVal); }
/// <summary> /// Provides the possible references for this term (only available during semantic analysis) /// </summary> /// <param name="instance">the instance on which this element should be found.</param> /// <param name="expectation">the expectation on the element found</param> /// <param name="last">indicates that this is the last element in a dereference chain</param> /// <returns></returns> public ReturnValue getReferences(Utils.INamable instance, Filter.AcceptableChoice expectation, bool last) { ReturnValue retVal = null; if (Designator != null) { retVal = Designator.getReferences(instance, expectation, last); } else if (LiteralValue != null) { retVal = LiteralValue.getReferences(instance, expectation, last); } return(retVal); }
/// <summary> /// Performs the semantic analysis of the statement /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance) { bool retVal = base.SemanticAnalysis(instance); if (retVal) { Value.SemanticAnalysis(instance); ListExpression.SemanticAnalysis(instance, Filter.IsLeftSide); if (ReplaceElement != null) { ReplaceElement.SemanticAnalysis(instance); } } return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation) { bool retVal = base.SemanticAnalysis(instance, expectation); if (retVal) { InitialValue.SemanticAnalysis(instance, Filter.IsRightSide); Expression.SemanticAnalysis(instance, Filter.AllMatches); Condition.SemanticAnalysis(instance, Filter.AllMatches); LastIteration.Type = InitialValue.GetExpressionType(); CurrentIteration.Type = InitialValue.GetExpressionType(); } return(retVal); }
/// <summary> /// Finds all namable which match the full name provided /// </summary> /// <param name="fullname">The full name used to search the namable</param> public Utils.INamable findByFullName(string fullname) { Utils.INamable retVal = null; foreach (Dictionary dictionary in Dictionaries) { retVal = dictionary.findByFullName(fullname); if (retVal != null) { // TODO : only finds the first occurence of the namable in all opened dictionaries. break; } } return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation) { bool retVal = base.SemanticAnalysis(instance, expectation); if (retVal) { Called.SemanticAnalysis(instance, Filter.IsCallable); foreach (Expression actual in AllParameters) { actual.SemanticAnalysis(instance, Filter.IsActualParameter); } ParameterAssociation = createParameterAssociation(Called.Ref as ICallable); } return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <param name="expectation">Indicates the kind of element we are looking for</paraparam> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation) { bool retVal = base.SemanticAnalysis(instance, expectation); if (retVal) { if (Term != null) { Term.SemanticAnalysis(instance, expectation, true); } else if (Expression != null) { Expression.SemanticAnalysis(instance, expectation); } } return(retVal); }
/// <summary> /// Provides the possible references for this dereference expression (only available during semantic analysis) /// </summary> /// <param name="instance">the instance on which this element should be found.</param> /// <param name="expectation">the expectation on the element found</param> /// <param name="last">indicates that this is the last element in a dereference chain</param> /// <returns></returns> public override ReturnValue getReferences(Utils.INamable instance, Filter.AcceptableChoice expectation, bool last) { ReturnValue retVal = ReturnValue.Empty; if (Term != null) { retVal = Term.getReferences(instance, expectation, last); } else { if (UnaryOp == null) { retVal = Expression.getReferences(instance, expectation, last); } } return(retVal); }
/// <summary> /// Adds a new value in the set of return values /// </summary> /// <param name="value">The value to add</param> /// <param name="previous">The previous element in the chain</param> public void Add(Utils.INamable value, ReturnValueElement previous = null) { if (value != null) { bool found = false; foreach (ReturnValueElement elem in Values) { if (elem.Value == value) { found = true; break; } } if (!found) { Values.Add(new ReturnValueElement(value, previous)); } } }
/// <summary> /// Performs the semantic analysis of the statement /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance) { bool retVal = base.SemanticAnalysis(instance); if (retVal) { ListExpression.SemanticAnalysis(instance); Types.Collection collectionType = ListExpression.GetExpressionType() as Types.Collection; if (collectionType != null) { IteratorVariable.Type = collectionType.Type; } if (Condition != null) { Condition.SemanticAnalysis(instance); } } return(retVal); }
/// <summary> /// Provides the graph associated to the namable /// </summary> /// <param name="namable"></param> /// <returns></returns> public static Graph createGraph(Utils.INamable namable, Parameter parameter) { Graph retVal = null; Functions.Function function = namable as Functions.Function; if (function != null) { retVal = function.createGraphForParameter(new Interpreter.InterpretationContext(), parameter); } if (retVal == null) { Values.IValue value = namable as Values.IValue; if (value != null) { retVal = createGraph(Function.getDoubleValue(value), parameter); } } return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <returns>True if semantic analysis should be continued</returns> public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation) { bool retVal = base.SemanticAnalysis(instance, expectation); if (retVal) { Types.Type elementType = null; foreach (Expression expr in ListElements) { expr.SemanticAnalysis(instance, expectation); Types.Type current = expr.GetExpressionType(); if (elementType == null) { elementType = current; } else { if (current != elementType) { AddError("Cannot mix types " + current.ToString() + " and " + elementType.ToString() + "in collection"); } } } if (elementType != null) { ExpressionType = (Types.Collection)Generated.acceptor.getFactory().createCollection(); ExpressionType.Type = elementType; ExpressionType.Name = "ListOf_" + elementType.FullName; ExpressionType.Enclosing = Root.EFSSystem; } else { ExpressionType = new Types.GenericCollection(EFSSystem); } } return(retVal); }
/// <summary> /// Provides the possible references types for this expression (used in semantic analysis) /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam> /// <param name="last">indicates that this is the last element in a dereference chain</param> /// <returns></returns> public ReturnValue getReferenceTypes(Utils.INamable instance, Filter.AcceptableChoice expectation, bool last) { ReturnValue retVal = null; if (Designator != null) { retVal = new ReturnValue(); foreach (ReturnValueElement element in Designator.getReferences(instance, expectation, last).Values) { if (element.Value is Types.Type) { retVal.Add(element.Value); } } } else if (LiteralValue != null) { retVal = LiteralValue.getReferenceTypes(instance, expectation, true); } return(retVal); }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <returns>True if semantic analysis should be continued</returns> public bool SemanticAnalysis(Utils.INamable instance = null) { return(SemanticAnalysis(instance, Filter.AllMatches)); }
/// <summary> /// Constructor /// </summary> /// <param name="value"></param> /// <param name="previous"></param> public ReturnValueElement(Utils.INamable value, ReturnValueElement previous = null) { PreviousElement = previous; Value = value; }
/// <summary> /// Provides the possible references for this expression (only available during semantic analysis) /// </summary> /// <param name="instance">the instance on which this element should be found.</param> /// <param name="expectation">the expectation on the element found</param> /// <param name="last">indicates that this is the last element in a dereference chain</param> /// <returns></returns> public virtual ReturnValue getReferences(Utils.INamable instance, Filter.AcceptableChoice expectation, bool last) { return(ReturnValue.Empty); }