internal InstructionParser(SourceMethodBody sourceMethodBody) {
      Contract.Requires(sourceMethodBody != null);

      this.sourceMethodBody = sourceMethodBody;
      this.host = sourceMethodBody.host; Contract.Assume(this.host != null);
      this.ilMethodBody = sourceMethodBody.ilMethodBody; Contract.Assume(this.ilMethodBody != null);
      this.MethodDefinition = sourceMethodBody.MethodDefinition;
      this.nameTable = sourceMethodBody.nameTable; Contract.Assume(this.nameTable != null);
      this.sourceLocationProvider = sourceMethodBody.sourceLocationProvider;
      this.localScopeProvider = sourceMethodBody.localScopeProvider;
      this.options = sourceMethodBody.options;
      this.platformType = sourceMethodBody.platformType; Contract.Assume(this.platformType != null);
      this.numberOfAssignmentsToLocal = sourceMethodBody.numberOfAssignmentsToLocal; Contract.Assume(this.numberOfAssignmentsToLocal != null);
      this.numberOfReferencesToLocal = sourceMethodBody.numberOfReferencesToLocal; Contract.Assume(this.numberOfReferencesToLocal != null);
      this.gotosThatTarget = sourceMethodBody.gotosThatTarget; Contract.Assume(this.gotosThatTarget != null);
      this.cdfg = sourceMethodBody.cdfg; Contract.Assume(this.cdfg != null);
      this.bindingsThatMakeALastUseOfALocalVersion = sourceMethodBody.bindingsThatMakeALastUseOfALocalVersion; Contract.Assume(this.bindingsThatMakeALastUseOfALocalVersion != null);

      if (this.localScopeProvider != null) {
        var syncInfo = this.localScopeProvider.GetSynchronizationInformation(sourceMethodBody);
        if (syncInfo != null) {
          var syncPointFor = this.synchronizatonPointLocationFor = new Hashtable<SynchronizationPointLocation>();
          IDocument doc = Dummy.Document;
          foreach (var loc in this.MethodDefinition.Locations) { doc = loc.Document; break; }
          foreach (var syncPoint in syncInfo.SynchronizationPoints) {
            Contract.Assume(syncPoint != null);
            var syncLoc = new SynchronizationPointLocation(doc, syncPoint);
            syncPointFor[syncPoint.SynchronizeOffset] = syncLoc;
            if (syncPoint.ContinuationMethod == null)
              syncPointFor[syncPoint.ContinuationOffset] = syncLoc;
          }
        }
      }
    }
Esempio n. 2
0
        internal DeclarationUnifier(SourceMethodBody sourceMethodBody)
        {
            Contract.Requires(sourceMethodBody != null);

              this.numberOfReferencesToLocal = sourceMethodBody.numberOfReferencesToLocal; Contract.Assume(this.numberOfReferencesToLocal != null);
              this.numberOfAssignmentsToLocal = sourceMethodBody.numberOfAssignmentsToLocal; Contract.Assume(this.numberOfAssignmentsToLocal != null);
        }
        internal LocalReadAndWriteCounter(HashtableForUintValues <object> numberOfAssignmentsToLocal, HashtableForUintValues <object> numberOfReferencesToLocal)
        {
            Contract.Requires(numberOfAssignmentsToLocal != null);
            Contract.Requires(numberOfReferencesToLocal != null);

            this.numberOfAssignmentsToLocal = numberOfAssignmentsToLocal;
            this.numberOfReferencesToLocal  = numberOfReferencesToLocal;
        }
Esempio n. 4
0
    internal LockReplacer(SourceMethodBody sourceMethodBody) {
      Contract.Requires(sourceMethodBody != null);
      this.host = sourceMethodBody.host; Contract.Assume(sourceMethodBody.host != null);
      this.sourceLocationProvider = sourceMethodBody.sourceLocationProvider;
      this.numberOfReferencesToLocal = sourceMethodBody.numberOfReferencesToLocal; Contract.Assume(sourceMethodBody.numberOfReferencesToLocal != null);
      this.numberOfAssignmentsToLocal = sourceMethodBody.numberOfAssignmentsToLocal; Contract.Assume(sourceMethodBody.numberOfAssignmentsToLocal != null);
      this.bindingsThatMakeALastUseOfALocalVersion = sourceMethodBody.bindingsThatMakeALastUseOfALocalVersion; Contract.Assume(sourceMethodBody.bindingsThatMakeALastUseOfALocalVersion != null);
      var systemThreading = new Immutable.NestedUnitNamespaceReference(this.host.PlatformType.SystemObject.ContainingUnitNamespace,
        this.host.NameTable.GetNameFor("Threading"));
      var systemThreadingMonitor = new Immutable.NamespaceTypeReference(this.host, systemThreading, this.host.NameTable.GetNameFor("Monitor"), 0,
        isEnum: false, isValueType: false, typeCode: PrimitiveTypeCode.NotPrimitive);
      var parameters = new IParameterTypeInformation[2];
      this.monitorEnter = new MethodReference(this.host, systemThreadingMonitor, CallingConvention.Default, this.host.PlatformType.SystemVoid,
        this.host.NameTable.GetNameFor("Enter"), 0, parameters);
      parameters[0] = new SimpleParameterTypeInformation(monitorEnter, 0, this.host.PlatformType.SystemObject);
      parameters[1] = new SimpleParameterTypeInformation(monitorEnter, 1, this.host.PlatformType.SystemBoolean, isByReference: true);
      this.monitorExit = new MethodReference(this.host, systemThreadingMonitor, CallingConvention.Default, this.host.PlatformType.SystemVoid,
        this.host.NameTable.GetNameFor("Exit"), 0, this.host.PlatformType.SystemObject);

    }
Esempio n. 5
0
        internal LockReplacer(SourceMethodBody sourceMethodBody)
        {
            Contract.Requires(sourceMethodBody != null);
            this.host = sourceMethodBody.host; Contract.Assume(sourceMethodBody.host != null);
            this.sourceLocationProvider     = sourceMethodBody.sourceLocationProvider;
            this.numberOfReferencesToLocal  = sourceMethodBody.numberOfReferencesToLocal; Contract.Assume(sourceMethodBody.numberOfReferencesToLocal != null);
            this.numberOfAssignmentsToLocal = sourceMethodBody.numberOfAssignmentsToLocal; Contract.Assume(sourceMethodBody.numberOfAssignmentsToLocal != null);
            this.bindingsThatMakeALastUseOfALocalVersion = sourceMethodBody.bindingsThatMakeALastUseOfALocalVersion; Contract.Assume(sourceMethodBody.bindingsThatMakeALastUseOfALocalVersion != null);
            var systemThreading = new Immutable.NestedUnitNamespaceReference(this.host.PlatformType.SystemObject.ContainingUnitNamespace,
                                                                             this.host.NameTable.GetNameFor("Threading"));
            var systemThreadingMonitor = new Immutable.NamespaceTypeReference(this.host, systemThreading, this.host.NameTable.GetNameFor("Monitor"), 0,
                                                                              isEnum: false, isValueType: false, typeCode: PrimitiveTypeCode.NotPrimitive);
            var parameters = new IParameterTypeInformation[2];

            this.monitorEnter = new MethodReference(this.host, systemThreadingMonitor, CallingConvention.Default, this.host.PlatformType.SystemVoid,
                                                    this.host.NameTable.GetNameFor("Enter"), 0, parameters);
            parameters[0]    = new SimpleParameterTypeInformation(monitorEnter, 0, this.host.PlatformType.SystemObject);
            parameters[1]    = new SimpleParameterTypeInformation(monitorEnter, 1, this.host.PlatformType.SystemBoolean, isByReference: true);
            this.monitorExit = new MethodReference(this.host, systemThreadingMonitor, CallingConvention.Default, this.host.PlatformType.SystemVoid,
                                                   this.host.NameTable.GetNameFor("Exit"), 0, this.host.PlatformType.SystemObject);
        }
Esempio n. 6
0
    internal SingleAssignmentLocalReplacer(IMetadataHost host, SetOfObjects bindingsThatMakeALastUseOfALocalVersion, HashtableForUintValues<object> numberOfAssignmentsToLocal)
      : base(host) {
      Contract.Requires(host != null);
      Contract.Requires(bindingsThatMakeALastUseOfALocalVersion != null);
      Contract.Requires(numberOfAssignmentsToLocal != null);

      this.bindingsThatMakeALastUseOfALocalVersion = bindingsThatMakeALastUseOfALocalVersion;
      this.numberOfAssignmentsToLocal = numberOfAssignmentsToLocal;
      this.local = Dummy.LocalVariable;
      this.expressionToSubstituteForLocal = CodeDummy.Expression;
    }
Esempio n. 7
0
    internal SingleAssignmentSingleReferenceFinder(SetOfObjects bindingsThatMakeALastUseOfALocalVersion, HashtableForUintValues<object> numberOfReferencesToLocal) {
      Contract.Requires(bindingsThatMakeALastUseOfALocalVersion != null);
      Contract.Requires(numberOfReferencesToLocal != null);

      this.bindingsThatMakeALastUseOfALocalVersion = bindingsThatMakeALastUseOfALocalVersion;
      this.numberOfReferencesToLocal = numberOfReferencesToLocal;
      this.local = Dummy.LocalVariable;
    }