Пример #1
0
 internal CopiedSynchronizationInformation(ISynchronizationInformation originalSyncrhonizationInformation, Hashtable <object, object> mapFromOriginaltoCopy)
 {
     Contract.Requires(originalSyncrhonizationInformation != null);
     Contract.Requires(mapFromOriginaltoCopy != null);
     this.originalSyncrhonizationInformation = originalSyncrhonizationInformation;
     this.mapFromOriginaltoCopy = mapFromOriginaltoCopy;
 }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="methodBody"></param>
        /// <returns></returns>
        public virtual IMethodBody Rewrite(IMethodBody methodBody)
        {
            Contract.Requires(methodBody != null);

            IMethodDefinition asyncMethodDefinition = null;

            if (this.localScopeProvider != null)
            {
                this.synchronizationInfo = this.localScopeProvider.GetSynchronizationInformation(methodBody);
                if (this.synchronizationInfo != null)
                {
                    asyncMethodDefinition = this.synchronizationInfo.AsyncMethod;
                }
            }
            this.generator = new ILGenerator(this.host, methodBody.MethodDefinition, asyncMethodDefinition);
            this.maxStack  = methodBody.MaxStack;
            this.labelFor.Clear();
            this.localIndex.Clear();
            this.localVariables.Clear();
            this.scopeStack.Count = 0;

            this.EmitMethodBody(methodBody);
            return(new ILGeneratorMethodBody(this.Generator, methodBody.LocalsAreZeroed, this.maxStack, methodBody.MethodDefinition,
                                             this.localVariables.ToArray(), Enumerable <ITypeDefinition> .Empty));
        }
Пример #3
0
 internal CopiedSynchronizationInformation(ISynchronizationInformation originalSyncrhonizationInformation, Hashtable<object, object> mapFromOriginaltoCopy) {
   Contract.Requires(originalSyncrhonizationInformation != null);
   Contract.Requires(mapFromOriginaltoCopy != null);
   this.originalSyncrhonizationInformation = originalSyncrhonizationInformation;
   this.mapFromOriginaltoCopy = mapFromOriginaltoCopy;
 }
Пример #4
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="methodBody"></param>
    /// <returns></returns>
    public virtual IMethodBody Rewrite(IMethodBody methodBody) {
      Contract.Requires(methodBody != null);

      IMethodDefinition asyncMethodDefinition = null;
      if (this.localScopeProvider != null) {
        this.synchronizationInfo = this.localScopeProvider.GetSynchronizationInformation(methodBody);
        if (this.synchronizationInfo != null) asyncMethodDefinition = this.synchronizationInfo.AsyncMethod;
      }
      this.generator = new ILGenerator(this.host, methodBody.MethodDefinition, asyncMethodDefinition);
      this.maxStack = methodBody.MaxStack;
      this.labelFor.Clear();
      this.localIndex.Clear();
      this.localVariables.Clear();
      this.scopeStack.Count = 0;

      this.EmitMethodBody(methodBody);
      return new ILGeneratorMethodBody(this.Generator, methodBody.LocalsAreZeroed, this.maxStack, methodBody.MethodDefinition,
        this.localVariables.ToArray(), Enumerable<ITypeDefinition>.Empty);
    }