Ejemplo n.º 1
0
        public override void CaseAThisArrayPropertyDecl(AThisArrayPropertyDecl node)
        {
            if (!Util.HasAncestor<AStructDecl>(node))
            {
                /*if (node.GetVisibilityModifier() is AProtectedVisibilityModifier)
                    errors.Add(new ErrorCollection.Error(node.GetToken(),
                                                         "Only fields inside structs or classes can be marked as protected."));*/
                if (!Util.HasAncestor<AEnrichmentDecl>(node))
                    errors.Add(new ErrorCollection.Error(node.GetToken(), LocRM.GetString("ErrorText185")));
            }

            APropertyDecl replacer = new APropertyDecl(node.GetVisibilityModifier(), null, node.GetType(),
                                                       new TIdentifier("", node.GetToken().Line, node.GetToken().Pos),
                                                       node.GetGetter(), node.GetSetter());
            List<AALocalDecl> locals = new List<AALocalDecl>();
            if (replacer.GetGetter() != null)
            {
                AABlock block = (AABlock) replacer.GetGetter();
                AALocalDecl local = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                                    (PType) node.GetArgType().Clone(),
                                                    (TIdentifier) node.GetArgName().Clone(), null);
                block.GetStatements().Insert(0, new ALocalDeclStm(new TSemicolon(";"), local));
                locals.Add(local);
            }
            if (replacer.GetSetter() != null)
            {
                AABlock block = (AABlock)replacer.GetSetter();
                AALocalDecl local = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                                    (PType)node.GetArgType().Clone(),
                                                    (TIdentifier)node.GetArgName().Clone(), null);

                block.GetStatements().Insert(0, new ALocalDeclStm(new TSemicolon(";"), local));
                locals.Add(local);
            }
            data.ArrayPropertyLocals[replacer] = locals.ToArray();
            node.ReplaceBy(replacer);
            replacer.Apply(this);
        }
        public override void CaseAThisArrayPropertyDecl(AThisArrayPropertyDecl node)
        {
            APropertyDecl replacer = new APropertyDecl(node.GetVisibilityModifier(), null, node.GetType(),
                                                       new TIdentifier("array property", node.GetToken().Line, node.GetToken().Pos),
                                                       node.GetGetter(), node.GetSetter());
            List<AALocalDecl> locals = new List<AALocalDecl>();
            if (replacer.GetGetter() != null)
            {
                AABlock block = (AABlock)replacer.GetGetter();
                AALocalDecl local = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                                    (PType)node.GetArgType().Clone(),
                                                    (TIdentifier)node.GetArgName().Clone(), null);
                block.GetStatements().Insert(0, new ALocalDeclStm(new TSemicolon(";"), local));
                locals.Add(local);
            }
            if (replacer.GetSetter() != null)
            {
                AABlock block = (AABlock)replacer.GetSetter();
                AALocalDecl local = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                                    (PType)node.GetArgType().Clone(),
                                                    (TIdentifier)node.GetArgName().Clone(), null);

                block.GetStatements().Insert(0, new ALocalDeclStm(new TSemicolon(";"), local));
                locals.Add(local);
            }
            node.ReplaceBy(replacer);
            replacer.Apply(this);
        }