예제 #1
0
파일: Looker.cs 프로젝트: hesam/SketchSharp
 private void InjectStaticInitializerIfNoneSpecified(TypeNode typeNode){
   if (typeNode.NodeType == NodeType.EnumNode) return;
   MemberList staticCons = typeNode.GetMembersNamed(StandardIds.CCtor);
   if (staticCons != null && staticCons.Count > 0) return;
   StatementList statements = null;
   MemberList members = typeNode.Members;
   for (int i = 0, n = members == null ? 0 : members.Count; i < n; i++){
     Field f = members[i] as Field;
     if (f == null) continue;
     if (!f.IsStatic) continue;
     if (f.IsLiteral) continue;
     if (f.Initializer == null) continue;
     statements = new StatementList(1);
     break;
   }
   if (statements == null && typeNode.Contract != null && typeNode.Contract.FrameField != null)
     statements = new StatementList(1);
   if (statements != null){
     FieldInitializerBlock finitBlock = new FieldInitializerBlock(typeNode, true);
     statements.Add(finitBlock);
     StaticInitializer cctor = new StaticInitializer(typeNode, null, new Block(statements));
     typeNode.Members.Add(cctor);
     if (typeNode.PartiallyDefines != null){
       staticCons = typeNode.PartiallyDefines.GetMembersNamed(StandardIds.CCtor);
       if (staticCons == null || staticCons.Count == 0){
         finitBlock.Type = typeNode.PartiallyDefines;
         cctor.DeclaringType = typeNode.PartiallyDefines;
         typeNode.PartiallyDefines.Members.Add(cctor);
       }
     }
   }
 }
예제 #2
0
 public virtual Block VisitFieldInitializerBlock(FieldInitializerBlock block)
 {
     if (block == null) return null;
     block.Type = this.VisitTypeReference(block.Type);
     return this.VisitBlock(block);
 }
예제 #3
0
        public override Block VisitFieldInitializerBlock(FieldInitializerBlock block)
        {
            // TODO: is this ever interesting??

            return base.VisitFieldInitializerBlock(block);
        }
예제 #4
0
 public override Block VisitFieldInitializerBlock(FieldInitializerBlock block)
 {
     if (block == null) return null;
     return base.VisitFieldInitializerBlock((FieldInitializerBlock)block.Clone());
 }
예제 #5
0
 public EventingVisitor(Action<FieldInitializerBlock> visitFieldInitializerBlock) { VisitedFieldInitializerBlock += visitFieldInitializerBlock; } public event Action<FieldInitializerBlock> VisitedFieldInitializerBlock; public override Block VisitFieldInitializerBlock(FieldInitializerBlock block) { if (VisitedFieldInitializerBlock != null) VisitedFieldInitializerBlock(block); return base.VisitFieldInitializerBlock(block); }