Exemplo n.º 1
0
        private Variable ParceType(TypeContext context)
        {
            var      typeName = context.typeName().GetText();
            Variable variable;

            if (PrimitiveVariable.PrimitiveTypes.Contains(typeName))
            {
                variable = new PrimitiveVariable(typeName);
            }
            else
            {
                var type = GetType(context);
                if (type is Class)
                {
                    variable = new ClassVariable((Class)type);
                }
                else if (type is Delegate)
                {
                    variable = new DelegateVariable((Delegate)type);
                }
                else if (type is Enum)
                {
                    variable = new EnumVariable((Enum)type);
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }

            variable.IsConst     = context.FoundChild <IsConstContext>();
            variable.IsPointer   = context.FoundChild <IsPtrQuantContext>();
            variable.IsReference = context.FoundChild <IsRefQuantContext>();

            return(variable);
        }