Пример #1
0
        private AST.OclExpression CreateImplicitPropertyIterator(AST.OclExpression expr, IToken token, Classifier sourceType, Property property)
        {
            if (TestNull(expr, property))
            {
                return(new AST.ErrorExp(Library.Invalid));
            }

            var codeSource = new CodeSource(token);
            VariableDeclaration        varDecl = new VariableDeclaration("", sourceType, null);
            List <VariableDeclaration> varList = new List <VariableDeclaration>();

            varList.Add(varDecl);
            AST.VariableExp localVar = new AST.VariableExp(varDecl)
                                       .SetCodeSource(codeSource);
            AST.PropertyCallExp localProp = CheckAmbiguous(new AST.PropertyCallExp(localVar, false, null, null, property))
                                            .SetCodeSource(codeSource);
            //Napevno zafixovany navratovy typ collect
            // JM > kdyz je typ Set(Class) nebo Bag(Class) tak by mel implicit collect vracet Bag(Class)
            Classifier returnType;

            if (property.Type is CollectionType)
            {
                returnType = Library.CreateCollection(CollectionKind.Bag, ((CollectionType)property.Type).ElementType);
            }
            else
            {
                returnType = Library.CreateCollection(CollectionKind.Collection, property.Type);
            }
            return(new AST.IteratorExp(expr, localProp, @"collect", varList, returnType)
                   .SetCodeSource(codeSource));
        }
Пример #2
0
 AST.PropertyCallExp CheckAmbiguous(AST.PropertyCallExp prop)
 {
     if (prop.ReferredProperty.IsAmbiguous)
     {
         Errors.AddError(new ErrorItem(String.Format(CompilerErrors.AmbiguousNavigation,
                                                     prop.Source.Type.Name, prop.ReferredProperty.Name)));
     }
     return(prop);
 }
Пример #3
0
        public string Visit(PropertyCallExp node)
        {
            if (node.Source != null)
            {
                node.Source.Accept(this);
            }
            sb.Append(".");
            sb.Append(node.ReferredProperty.Name);


            return(string.Empty);
        }