예제 #1
0
 public SerializedType VisitEnum(EnumeratorTypeSpec e)
 {
     if (e.Tag == null || !symbolTable.EnumsSeen.TryGetValue(e.Tag, out var _))
     {
         var en = new SerializedEnumType {
             Name = e.Tag ?? string.Format("enum_{0}", symbolTable.EnumsSeen.Count)
         };
         symbolTable.EnumsSeen.Add(en.Name, en);
         var enumEvaluator = new EnumEvaluator(new CConstantEvaluator(platform, symbolTable.Constants));
         var listMembers   = new List <SerializedEnumValue>();
         foreach (var item in e.Enums)
         {
             var ee = new SerializedEnumValue
             {
                 Name  = item.Name,
                 Value = enumEvaluator.GetValue(item.Value),
             };
             symbolTable.Constants.Add(ee.Name, ee.Value);
             listMembers.Add(ee);
         }
         en.Values = listMembers.ToArray();
         symbolTable.Types.Add(en);
         return(new SerializedEnumType {
             Name = en.Name
         });
     }
     else
     {
         return(new SerializedEnumType {
             Name = e.Tag
         });
     }
 }
예제 #2
0
 public void Setup()
 {
     this.mr = new MockRepository();
     var platform = mr.Stub<IPlatform>();
     platform.Stub(p => p.GetByteSizeFromCBasicType(CBasicType.Int)).Return(4);
     platform.Replay();
     constants = new Dictionary<string, int>();
     enev = new EnumEvaluator(new CConstantEvaluator(platform, constants));
 }