The Labs \ Source Viewer \ SSCLI \ Microsoft.JScript \ AssemblyCustomAttributeList

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. namespace Microsoft.JScript
  16. {
  17.    
  18.     using System;
  19.     using System.Collections;
  20.     using System.Reflection;
  21.     using System.Reflection.Emit;
  22.    
  23.     public sealed class AssemblyCustomAttributeList : AST
  24.     {
  25.         private CustomAttributeList list;
  26.         internal bool okToUse;
  27.        
  28.         internal AssemblyCustomAttributeList(CustomAttributeList list) : base(list.context)
  29.         {
  30.             this.list = list;
  31.             this.okToUse = false;
  32.         }
  33.        
  34.         internal override object Evaluate()
  35.         {
  36.             return null;
  37.         }
  38.        
  39.         internal void Process()
  40.         {
  41.             this.okToUse = true;
  42.             this.list.SetTarget(this);
  43.             this.list.PartiallyEvaluate();
  44.         }
  45.        
  46.         internal override AST PartiallyEvaluate()
  47.         {
  48.             if (!this.okToUse)
  49.                 this.context.HandleError(JSError.AssemblyAttributesMustBeGlobal);
  50.             return this;
  51.         }
  52.        
  53.         internal override void TranslateToIL(ILGenerator il, Type rtype)
  54.         {
  55.             foreach (CustomAttributeBuilder ca in this.list.GetCustomAttributeBuilders(false))
  56.                 this.compilerGlobals.assemblyBuilder.SetCustomAttribute(ca);
  57.             if (rtype != Typeob.Void) {
  58.                 il.Emit(OpCodes.Ldnull);
  59.                 if (rtype.IsValueType)
  60.                     Convert.Emit(this, il, Typeob.Object, rtype);
  61.             }
  62.         }
  63.        
  64.         internal override void TranslateToILInitializer(ILGenerator il)
  65.         {
  66.         }
  67.        
  68.     }
  69. }

Developer Fusion