Ejemplo n.º 1
0
        public UnitBuilder AddMemberDeclaration(IClassMember memberDecl)
        {
            if (classDeclStack.Count == 0)
            {
                throw new InvalidOperationException("No hay ninguna declaracion de clase abierta.");
            }

            ClassDeclaration classDecl = classDeclStack.Peek();

            classDecl.Members.Add(memberDecl);

            return(this);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="field">The information for this field.</param>
        /// <param name="attribute">The field's <see cref="FixedWidthFieldAttribute"/> attribute.</param>
        /// <exception cref="ArgumentNullException"></exception>
        public MemberDescriptor(FieldInfo field, FixedWidthFieldAttribute attribute)
            : base(attribute)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field));
            }
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }

            Member    = new FieldMember(field);
            Converter = GetConverter(attribute.ConverterType);
            Debug.Assert(Converter != null);
        }
Ejemplo n.º 3
0
 private static string ResolveClassMemberModifier(IClassMember info)
 {
     if (info.IsAbstract)
     {
         return("abstract");
     }
     if (info.IsVirtual)
     {
         return("virtual");
     }
     if (info.IsOverride)
     {
         return("override");
     }
     return(null);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="property">The information for this property.</param>
        /// <param name="attribute">The property's <see cref="FixedWidthFieldAttribute"/> attribute.</param>
        /// <exception cref="ArgumentNullException"></exception>
        public MemberDescriptor(PropertyInfo property, FixedWidthFieldAttribute attribute)
            : base(attribute)
        {
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }

            Member    = new PropertyMember(property);
            Converter = GetConverter(attribute.ConverterType);
            Debug.Assert(Converter != null);
        }
Ejemplo n.º 5
0
        public static string GetAccessModifiers(IClassMember m)
        {
            var modifiers = new List<string>();
            switch (m.Visibility)
            {
                case Visibility.Private:
                    modifiers.Add("private");
                    break;
                case Visibility.Protected:
                    modifiers.Add("protected");
                    break;
                default:
                    modifiers.Add("public");
                    break;
            }
            if (m.IsStatic)
                modifiers.Add("static");
            return string.Join(" ", modifiers);

        }
Ejemplo n.º 6
0
        public static string GetAccessModifiers(IClassMember m)
        {
            var modifiers = new List <string>();

            switch (m.Visibility)
            {
            case Visibility.Private:
                modifiers.Add("private");
                break;

            case Visibility.Protected:
                modifiers.Add("protected");
                break;

            default:
                modifiers.Add("public");
                break;
            }
            if (m.IsStatic)
            {
                modifiers.Add("static");
            }
            return(string.Join(" ", modifiers));
        }
Ejemplo n.º 7
0
        public override void GenerateLua(Class c, string root, StringBuilder builder, int depth)
        {
            IClassMember classMember = c.GetElementInParent(this.Identifier.Symbol, c) as IClassMember;

            if (classMember != null)
            {
                if ((classMember.Access & AccessType.Global) > 0)
                {
                    builder.Append(this.Identifier.Symbol);
                }
                else if ((classMember.Access & AccessType.Static) > 0)
                {
                    builder.Append(string.Format("{0}.{1}", c.ClassName, this.Identifier.Symbol));
                }
                else
                {
                    builder.Append(string.Format("self.{0}", this.Identifier.Symbol));
                }
            }
            else
            {
                builder.Append(this.Identifier.Symbol);
            }
        }
Ejemplo n.º 8
0
 public ClassMember(IClassMember member)
 {
     this._Member = member;
 }
Ejemplo n.º 9
0
 private void AddMember(IClassMember member)
 {
     Members.Add(member.Name, member);
 }