Exemplo n.º 1
0
 protected ClassSymbol(TextPosition tp, string name, ClassType type, ProgramContext block)
     : base(tp)
 {
     Name = name;
     ClassType = type;
     Block = block;
     This = new ThisSymbol(this);
     Block.Append(This);
     AppendChild(Block);
     IsInitialize = true;
 }
Exemplo n.º 2
0
 private ClassSymbol ImportPureType(Type type)
 {
     var elem = new ClassSymbol();
     if (ImportDictionary.ContainsKey(type))
     {
         return (ClassSymbol)ImportDictionary[type];
     }
     ImportDictionary.Add(type, elem);
     ClassType classType;
     var attribute = new List<AttributeSymbol>();
     AppendEmbededAttribute(attribute, type, out classType);
     var generic = CreateGenericList(type.GetGenericArguments());
     var inherit = CreateInheritList(type);
     var block = new ProgramContext();
     var ctor = type.GetConstructors(Binding);
     foreach (var c in ctor)
     {
         if(c.IsAssembly || c.IsFamilyAndAssembly || c.IsPrivate)
         {
             continue;
         }
         block.Append(ImportConstructor(c));
     }
     //todo Eventのインポートに対応する。
     //var eve = type.GetEvents();
     //foreach (var e in eve)
     //{
     //    block.Append(ImportEvent(e));
     //}
     var property = type.GetProperties(Binding);
     foreach (var p in property)
     {
         var name = p.GetIndexParameters().Count() > 0 ? RoutineSymbol.AliasCallIdentifier : p.Name;
         var g = p.GetMethod;
         if (g != null && !g.IsAssembly && !g.IsFamilyAndAssembly && !g.IsPrivate)
         {
             block.Append(ImportProperty(p.GetMethod, name));
         }
         var s = p.SetMethod;
         if (s != null && !s.IsAssembly && !s.IsFamilyAndAssembly && !s.IsPrivate)
         {
             block.Append(ImportProperty(p.SetMethod, name));
         }
     }
     var method = type.GetMethods(Binding);
     foreach (var m in method)
     {
         if (m.IsAssembly || m.IsFamilyAndAssembly || m.IsPrivate)
         {
             continue;
         }
         if(ImportDictionary.ContainsKey(m))
         {
             continue;
         }
         block.Append(ImportMethod(m));
     }
     var field = type.GetFields(Binding);
     foreach (var f in field)
     {
         if (f.IsAssembly || f.IsFamilyAndAssembly || f.IsPrivate)
         {
             continue;
         }
         block.Append(ImportField(f));
     }
     var nested = type.GetNestedTypes(Binding);
     foreach (var n in nested)
     {
         if (n.IsNestedAssembly || n.IsNestedFamANDAssem || n.IsNestedPrivate)
         {
             continue;
         }
         block.Append(ImportType(n));
     }
     elem.Initialize(TrimTypeNameMangling(type.Name), classType, block, attribute, generic, inherit);
     return elem;
 }
Exemplo n.º 3
0
 private EnumSymbol ImportEnum(Type type)
 {
     var attribute = new List<AttributeSymbol>();
     AppendEmbededAttribute(attribute, type);
     var ut = ImportType(type.GetEnumUnderlyingType());
     var block = new ProgramContext();
     var elem = new EnumSymbol(type.Name, block, attribute, ut);
     if (ImportDictionary.ContainsKey(type))
     {
         return (EnumSymbol)ImportDictionary[type];
     }
     ImportDictionary.Add(type, elem);
     foreach(var v in type.GetFields())
     {
         if(!v.IsLiteral)
         {
             continue;
         }
         var f = new VariantSymbol();
         ImportDictionary.Add(v, f);
         VariantType t;
         var a = new List<AttributeSymbol>();
         AppendEmbededAttribute(a, v, out t);
         var dt = ImportType(v.FieldType);
         var def = new ValueSymbol(v.GetRawConstantValue());
         f.Initialize(v.Name, t, a, dt, def);
         block.Append(f);
     }
     return elem;
 }
Exemplo n.º 4
0
 public void Initialize(string name, ClassType type, ProgramContext block, IReadOnlyList<AttributeSymbol> attr, IReadOnlyList<GenericSymbol> gnr, IReadOnlyList<TypeSymbol> inherit)
 {
     if (IsInitialize)
     {
         throw new InvalidOperationException();
     }
     IsInitialize = true;
     Name = name;
     ClassType = type;
     Block = block;
     This = new ThisSymbol(this);
     Block.Append(This);
     AppendChild(Block);
     _Attribute = attr;
     _Generics = gnr;
     _Inherit = inherit;
 }