Esempio n. 1
0
        public override object VisitNamespaceConstantStatement(NamespaceConstantStatementContext context)
        {
            var id   = (Result)(Visit(context.id()));
            var expr = (Result)(Visit(context.expression()));
            var typ  = "";

            if (context.typeType() != null)
            {
                typ = (string)(Visit(context.typeType()));
            }
            else
            {
                typ = (string)(expr.data);
            }
            var obj = "";

            if (context.annotationSupport() != null)
            {
                obj += Visit(context.annotationSupport());
            }
            obj += (new System.Text.StringBuilder().Append(id.permission).Append(" const ").Append(typ).Append(" ").Append(id.text).Append(" = ").Append(expr.text).Append(Terminate).Append(Wrap)).to_str();
            return(obj);
        }
Esempio n. 2
0
        public override object VisitNamespaceConstantStatement([NotNull] NamespaceConstantStatementContext context)
        {
            var id   = (Result)Visit(context.id());
            var expr = (Result)Visit(context.expression());
            var typ  = "";

            if (context.type() != null)
            {
                typ = (string)Visit(context.type());
            }
            else
            {
                typ = (string)expr.data;
            }

            var obj = "";

            if (context.annotationSupport() != null)
            {
                obj += Visit(context.annotationSupport());
            }
            switch (typ)
            {
            case i8:
                typ = "ubyte";
                break;

            case i16:
                typ = "short";
                break;

            case i32:
                typ = "int";
                break;

            case i64:
                typ = "long";
                break;

            case u8:
                typ = "byte";
                break;

            case u16:
                typ = "ushort";
                break;

            case u32:
                typ = "uint";
                break;

            case u64:
                typ = "ulong";
                break;

            case f32:
                typ = "float";
                break;

            case f64:
                typ = "double";
                break;

            case str:
                typ = "string";
                break;

            default:
                break;
            }
            obj += $"{id.permission} const {typ} {id.text} = {expr.text} {Terminate} {Wrap}";
            return(obj);
        }