Ejemplo n.º 1
0
 private VariantSymbol ImportField(FieldInfo field)
 {
     var elem = new VariantSymbol();
     if (ImportDictionary.ContainsKey(field))
     {
         return (VariantSymbol)ImportDictionary[field];
     }
     ImportDictionary.Add(field, elem);
     VariantType type;
     var attribute = new List<AttributeSymbol>();
     AppendEmbededAttribute(attribute, field, out type);
     var dt = ImportType(field.FieldType);
     elem.Initialize(field.Name, type, attribute, dt);
     return elem;
 }
Ejemplo n.º 2
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;
 }