Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 public override string ToString()
 {
     return($"INSERT INTO Moves {MoveID.ToString()}, {Cost.ToString()},{Power.ToString()},{Type.ToString()}");
 }