Example #1
0
        public override object VisitPackageVariableStatement([NotNull] PackageVariableStatementContext context)
        {
            var    r1        = (Result)Visit(context.id());
            var    isMutable = context.m != null;
            var    typ       = "";
            Result r2        = null;

            if (context.expression() != null)
            {
                r2  = (Result)Visit(context.expression());
                typ = (string)r2.data;
            }
            if (context.type() != null)
            {
                typ = (string)Visit(context.type());
            }
            var obj = "";

            if (context.annotationSupport() != null)
            {
                obj += Visit(context.annotationSupport());
            }

            obj += $"{r1.permission} {typ} {r1.text}";
            if (r2 != null)
            {
                obj += $" = {r2.text} {Terminate} {Wrap}";
            }
            else
            {
                obj += Terminate + Wrap;
            }
            return(obj);
        }
Example #2
0
        public override object VisitPackageVariableStatement(PackageVariableStatementContext context)
        {
            var r1        = (Result)(Visit(context.id()));
            var isMutable = r1.isVirtual;
            var isVirtual = "";

            if (r1.isVirtual)
            {
                isVirtual = " virtual ";
            }
            var    typ = "";
            Result r2  = null;

            if (context.expression() != null)
            {
                r2  = (Result)(Visit(context.expression()));
                typ = (string)(r2.data);
            }
            if (context.typeType() != null)
            {
                typ = (string)(Visit(context.typeType()));
            }
            var obj = "";

            if (context.annotationSupport() != null)
            {
                this.selfPropertyID = r1.text;
                obj += Visit(context.annotationSupport());
            }
            if (this.selfPropertyContent.len > 0)
            {
                var pri = "";
                if (this.selfPropertyVariable)
                {
                    pri = (new System.Text.StringBuilder().Append("private ").Append(typ).Append(" _").Append(r1.text)).to_str();
                    if (r2 != null)
                    {
                        pri += " = " + r2.text;
                    }
                    pri += Terminate + Wrap;
                }
                obj  = pri + obj;
                obj += (new System.Text.StringBuilder().Append(r1.permission).Append(" ").Append(isVirtual).Append(" ").Append(typ).Append(" ").Append(r1.text).Append(BlockLeft)).to_str();
                foreach (var v in this.selfPropertyContent)
                {
                    obj += v;
                }
                obj += BlockRight + Wrap;
                this.selfPropertyContent.clear();
                this.selfPropertyID       = "";
                this.selfPropertyVariable = false;
            }
            else
            {
                obj += (new System.Text.StringBuilder().Append(r1.permission).Append(" ").Append(typ).Append(" ").Append(r1.text)).to_str();
                if (r2 != null)
                {
                    obj += (new System.Text.StringBuilder().Append(" = ").Append(r2.text).Append(Terminate).Append(Wrap)).to_str();
                }
                else
                {
                    obj += Terminate + Wrap;
                }
            }
            return(obj);
        }