コード例 #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);
        }
コード例 #2
0
 public override void CaseAThisArrayPropertyDecl(AThisArrayPropertyDecl node)
 {
     InAThisArrayPropertyDecl(node);
     if (node.GetSetter() != null)
     {
         node.GetSetter().Apply(this);
     }
     if (node.GetGetter() != null)
     {
         node.GetGetter().Apply(this);
     }
     if (node.GetArgName() != null)
     {
         node.GetArgName().Apply(this);
     }
     if (node.GetArgType() != null)
     {
         node.GetArgType().Apply(this);
     }
     if (node.GetToken() != null)
     {
         node.GetToken().Apply(this);
     }
     if (node.GetType() != null)
     {
         node.GetType().Apply(this);
     }
     if (node.GetVisibilityModifier() != null)
     {
         node.GetVisibilityModifier().Apply(this);
     }
     OutAThisArrayPropertyDecl(node);
 }
コード例 #3
0
        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);
        }