/// <summary> /// Return zero or more locations in primary source documents that correspond to the definition of the given local. /// </summary> public IEnumerable<IPrimarySourceLocation> GetPrimarySourceLocationsForDefinitionOf(ILocalDefinition localDefinition) { ISourceLocationProvider/*?*/ provider = this.GetProvider(localDefinition); if (provider == null) return Enumerable<IPrimarySourceLocation>.Empty; else return provider.GetPrimarySourceLocationsForDefinitionOf(localDefinition); }
public override void Visit(ILocalDefinition localDefinition) { NewLineAddIndent(); AppendElementType(localDefinition); //output.Append(localDefinition.Name.Value); //AppendSpace(); base.Visit(localDefinition); }
/// <summary> /// Returns the source name of the given local definition, if this is available. /// Otherwise returns the value of the Name property and sets isCompilerGenerated to true. /// </summary> public string GetSourceNameFor(ILocalDefinition localDefinition, out bool isCompilerGenerated) { ISourceLocationProvider/*?*/ provider = this.GetProvider(localDefinition); if (provider == null) { isCompilerGenerated = false; return ""; } else { return provider.GetSourceNameFor(localDefinition, out isCompilerGenerated); } }
/// <summary> /// /// </summary> /// <param name="local"></param> /// <returns></returns> public Bpl.Variable FindOrCreateLocalVariable(ILocalDefinition local) { Bpl.LocalVariable v; Bpl.IToken tok = local.Token(); Bpl.Type t = TranslationHelper.CciTypeToBoogie(local.Type.ResolvedType); if (!localVarMap.TryGetValue(local, out v)) { v = new Bpl.LocalVariable(tok, new Bpl.TypedIdent(tok, local.Name.Value, t)); localVarMap.Add(local, v); } return v; }
private void SerializeDynamicLocalInfo(ILocalDefinition local, EntityHandle parent) { var dynamicFlags = local.DynamicTransformFlags; if (dynamicFlags.IsDefault) { return; } var value = SerializeBitVector(dynamicFlags); _debugMetadataOpt.AddCustomDebugInformation( parent: parent, kind: _debugMetadataOpt.GetOrAddGuid(PortableCustomDebugInfoKinds.DynamicLocalVariables), value: _debugMetadataOpt.GetOrAddBlob(value)); }
protected virtual string GetLocalName(ILocalDefinition local) { string localName = local.Name.Value; if (this.pdbReader != null) { foreach (IPrimarySourceLocation psloc in this.pdbReader.GetPrimarySourceLocationsForDefinitionOf(local)) { if (psloc.Source.Length > 0) { localName = psloc.Source; break; } } } return(localName); }
private bool TryGetLocalName(ILocalDefinition local, out string localNameFromPDB) { string localName = local.Name.Value; localNameFromPDB = null; if (this.pdbReader != null) { foreach (IPrimarySourceLocation psloc in this.pdbReader.GetPrimarySourceLocationsForDefinitionOf(local)) { if (psloc.Source.Length > 0) { localNameFromPDB = psloc.Source; break; } } } return(localNameFromPDB != null); }
private bool MatchMethodCall(IExpression expression, ILocalDefinition variable, string methodName) { var methodCall = expression as IMethodCall; if (methodCall == null || methodCall.MethodToCall.Name.Value != methodName) { return(false); } var addressOf = methodCall.ThisArgument as IAddressOf; if (addressOf == null || addressOf.Expression.Definition != variable) { return(false); } return(true); }
public override void TraverseChildren(IBoundExpression boundExpression) { base.TraverseChildren(boundExpression); ITypeReference type = Dummy.TypeReference; ILocalDefinition /*?*/ local = boundExpression.Definition as ILocalDefinition; if (local != null) { type = local.Type; if (local.IsReference) { if (local.IsPinned) { type = Immutable.PointerType.GetPointerType(type, this.host.InternFactory); } else { type = Immutable.ManagedPointerType.GetManagedPointerType(type, this.host.InternFactory); } } } else { IParameterDefinition /*?*/ parameter = boundExpression.Definition as IParameterDefinition; if (parameter != null) { type = parameter.Type; if (parameter.IsByReference) { type = Immutable.ManagedPointerType.GetManagedPointerType(type, this.host.InternFactory); } } else { IFieldReference /*?*/ field = boundExpression.Definition as IFieldReference; if (field != null) { type = field.Type; } } } ((BoundExpression)boundExpression).Type = type; }
private static void SerializeTupleElementNames(ArrayBuilder <LocalAndScope> locals, BlobBuilder cmw) { cmw.WriteInt32(locals.Count); foreach (LocalAndScope localAndScope in locals) { ILocalDefinition local = localAndScope.Local; LocalScope scope = localAndScope.Scope; System.Collections.Immutable.ImmutableArray <TypedConstant> tupleElementNames = local.TupleElementNames; cmw.WriteInt32(tupleElementNames.Length); foreach (TypedConstant tupleElementName in tupleElementNames) { WriteUtf8String(cmw, (string)tupleElementName.Value ?? string.Empty); } cmw.WriteInt32(local.SlotIndex); cmw.WriteInt32(scope.StartOffset); cmw.WriteInt32(scope.EndOffset); WriteUtf8String(cmw, local.Name); } }
private PdbFunction GetPdbFunctionFor(ILocalDefinition localDefinition) { PdbFunction /*?*/ result = null; foreach (ILocation location in localDefinition.Locations) { IILLocation /*?*/ mbLocation = location as IILLocation; if (mbLocation != null) { var doc = mbLocation.Document as MethodBodyDocument; if (doc != null) { this.pdbFunctionMap.TryGetValue(doc.MethodToken, out result); break; } } } return(result); }
public override IStatement Rewrite(IExpressionStatement expressionStatement) { this.currentSingleUseSingleReferenceLocal = null; var result = base.Rewrite(expressionStatement); if (this.currentSingleUseSingleReferenceLocal != null) { var exprStat = result as IExpressionStatement; if (exprStat != null) { var assign = exprStat.Expression as IAssignment; if (assign != null && assign.Target.Definition == this.currentSingleUseSingleReferenceLocal) { this.expressionToSubstituteForSingleUseSingleReferenceLocal = assign.Source; } } } return(result); }
private static HLLocal CreateLocal(ILocalDefinition pDefinition) { HLLocal local = new HLLocal(); //local.Definition = pDefinition; local.Name = pDefinition.Name.Value; local.Signature = HLDomain.GetLocalSignature(pDefinition); sLocals[local.Signature] = local; //local.Container = GetOrCreateMethod(pDefinition.MethodDefinition); ITypeReference type = pDefinition.Type; if (pDefinition.IsReference) { type = MutableModelHelper.GetManagedPointerTypeReference(type, Host.InternFactory, type); } local.IsReference = pDefinition.IsReference; local.Type = GetOrCreateType(type); return(local); }
private static bool IsAssignmentOfLocalToLocal(IStatement s, out ILocalDefinition local) { Contract.Ensures(!Contract.Result <bool>() || Contract.ValueAtReturn <ILocalDefinition>(out local) != null); var es = s as IExpressionStatement; if (es != null) { var assign = es.Expression as IAssignment; if (assign != null) { var be = assign.Source as IBoundExpression; if (be != null && (local = be.Definition as ILocalDefinition) != null) { return(be.Definition == assign.Target.Definition); } } } local = null; return(false); }
public override ILocalDefinition Rewrite(ILocalDefinition localDefinition) { if (localDefinition.MethodDefinition != this.moveNext) // might happen to visit an already replaced local { return(localDefinition); } ILocalDefinition loc; if (!this.localTable.TryGetValue(localDefinition, out loc)) { loc = new LocalDefinition() { MethodDefinition = this.iterator, Name = localDefinition.Name, Type = localDefinition.Type, }; this.localTable.Add(localDefinition, loc); } return(loc); }
private void SerializeDynamicLocalInfo(ILocalDefinition local, int rowId, bool isConstant) { var dynamicFlags = local.DynamicTransformFlags; if (dynamicFlags.IsDefault) { return; } var value = SerializeBitVector(dynamicFlags); var tag = isConstant ? HasCustomDebugInformationTag.LocalConstant : HasCustomDebugInformationTag.LocalVariable; _customDebugInformationTable.Add(new CustomDebugInformationRow { Parent = HasCustomDebugInformation(tag, rowId), Kind = (uint)_debugHeapsOpt.GetGuidIndex(PortableCustomDebugInfoKinds.DynamicLocalVariables), Value = _debugHeapsOpt.GetBlobIndex(value), }); }
protected override void EmitOperation(IOperation operation) { base.EmitOperation(operation); switch (operation.OperationCode) { case OperationCode.Stloc: case OperationCode.Stloc_0: case OperationCode.Stloc_1: case OperationCode.Stloc_2: case OperationCode.Stloc_3: case OperationCode.Stloc_S: base.TrackLocal(operation.Value); ILocalDefinition loc = operation.Value as ILocalDefinition; string localName; if (TryGetLocalName(loc, out localName)) { CallWriteLine(localName); } break; } }
ILocalDefinition getSuitableDeadLocal(string targetType) { var matchingLocals = new List <ILocalDefinition>(); ILocalDefinition result = null; foreach (var local in deadLocals) { if (local.Type.ToString() == targetType) { matchingLocals.Add(local); } } if (matchingLocals.Count() > 0) { int index = prng.Next(matchingLocals.Count()); result = matchingLocals.ElementAt(index); } return(result); }
public override void TraverseChildren(IAddressableExpression addressableExpression) { base.TraverseChildren(addressableExpression); ITypeReference type = Dummy.TypeReference; ILocalDefinition /*?*/ local = addressableExpression.Definition as ILocalDefinition; if (local != null) { type = local.Type; } else { IParameterDefinition /*?*/ parameter = addressableExpression.Definition as IParameterDefinition; if (parameter != null) { type = parameter.Type; if (parameter.IsByReference) { type = Immutable.ManagedPointerType.GetManagedPointerType(type, this.host.InternFactory); } } else { IFieldReference /*?*/ field = addressableExpression.Definition as IFieldReference; if (field != null) { type = field.Type; } else { IExpression /*?*/ expression = addressableExpression.Definition as IExpression; if (expression != null) { type = expression.Type; } } } } ((AddressableExpression)addressableExpression).Type = type; }
protected virtual string GetLocalName(ILocalDefinition local) { string localName = local.Name.Value; if (this.pdbReader != null) { bool isCompilerGenerated; localName = this.pdbReader.GetSourceNameFor(local, out isCompilerGenerated); if (object.ReferenceEquals(localName, local.Name.Value)) { foreach (IPrimarySourceLocation psloc in this.pdbReader.GetPrimarySourceLocationsForDefinitionOf(local)) { if (psloc.Source.Length > 0) { localName = psloc.Source; break; } } } } return(localName); }
public override void TraverseChildren(ILocalDefinition localDefinition) { if (localDefinition.IsConstant) { this.sourceEmitterOutput.Write("const "); } string type = TypeHelper.GetTypeName(localDefinition.Type, NameFormattingOptions.ContractNullable | NameFormattingOptions.UseTypeKeywords); this.sourceEmitterOutput.Write(type); if (localDefinition.IsReference) { if (localDefinition.IsPinned) { this.sourceEmitterOutput.Write("*"); } else { this.sourceEmitterOutput.Write("&"); } } this.sourceEmitterOutput.Write(" "); this.PrintLocalName(localDefinition); }
public override void PrintLocalName(ILocalDefinition local) { this.sourceEmitterOutput.Write(this.GetLocalName(local)); }
public virtual void PrintLocalName(ILocalDefinition local) { this.sourceEmitterOutput.Write(local.Name.Value); }
/// <summary> /// Performs some computation with the given local definition. /// </summary> public void VisitReference(ILocalDefinition localDefinition) { }
delegate void Action(); //not defined in CLR v2. /// <summary> /// Saves the current closure fields. Allocates a new closure and updates the fields. Then calls the given delegate and /// restores the earlier state. /// </summary> private void AllocateClosureFor(object scope, List<IStatement> statements, Action rewriteScope) { Contract.Assume(!this.isInsideAnonymousMethod); var savedCurrentClosure = this.currentClosureClass; var savedCurrentClosureSelfInstance = this.currentClosureSelfInstance; var savedCurrentClosureInstance = this.currentClosureInstance; var savedCurrentClosureObject = this.currentClosureObject; var savedCurrentClosureLocal = this.currentClosureLocal; this.CreateClosureClass(); IFieldReference outerClosure = null; if (savedCurrentClosureLocal != null) { this.CreateClosureField(this.currentClosureSelfInstance, savedCurrentClosureSelfInstance, savedCurrentClosureInstance, savedCurrentClosureLocal.Name.Value); outerClosure = this.fieldReferencesForUseInsideThisMethod[this.currentClosureSelfInstance]; } var closureLocal = new LocalDefinition() { Type = this.currentClosureInstance, Name = this.host.NameTable.GetNameFor("CS$<>__locals"+this.closureClasses.Count) }; this.currentClosureObject = new BoundExpression() { Definition = closureLocal, Type = this.currentClosureInstance }; this.currentClosureLocal = closureLocal; if (this.closureLocalInstances == null) this.closureLocalInstances = new List<IExpression>(); this.closureLocalInstances.Add(this.currentClosureObject); rewriteScope(); Statement createClosure = new ExpressionStatement() { Expression = new Assignment() { Target = new TargetExpression() { Definition = closureLocal, Type = closureLocal.Type }, Source = new CreateObjectInstance() { MethodToCall = this.GetReferenceToDefaultConstructor(this.currentClosureInstance), Type = currentClosureSelfInstance, } } }; ILabeledStatement labeledStatement = null; for (int i = 0, n = statements.Count; i < n; i++) { labeledStatement = statements[i] as ILabeledStatement; if (labeledStatement != null) { createClosure = new LabeledStatement() { Label = labeledStatement.Label, Statement = createClosure }; createClosure.Locations.AddRange(labeledStatement.Locations); statements[i] = labeledStatement.Statement; break; } else if (statements[i] is IEmptyStatement) { continue; } else { var declSt = statements[i] as ILocalDeclarationStatement; if (declSt != null && declSt.InitialValue == null) continue; break; } } statements.Insert(0, createClosure); if (outerClosure != null) { statements.Insert(1, new ExpressionStatement() { Expression = new Assignment() { Target = new TargetExpression() { Instance = new BoundExpression() { Definition = closureLocal, Type = closureLocal.Type }, Definition = outerClosure, Type = closureLocal.Type }, Source = new BoundExpression() { Definition = savedCurrentClosureLocal, Type = savedCurrentClosureLocal.Type }, Type = closureLocal.Type, } }); } this.currentClosureClass = savedCurrentClosure; this.currentClosureSelfInstance = savedCurrentClosureSelfInstance; this.currentClosureInstance = savedCurrentClosureInstance; this.currentClosureObject = savedCurrentClosureObject; this.currentClosureLocal = savedCurrentClosureLocal; }
/// <summary> /// Return zero or more locations in primary source documents that correspond to the definition of the given local. /// </summary> public virtual IEnumerable <IPrimarySourceLocation> GetPrimarySourceLocationsForDefinitionOf(ILocalDefinition localDefinition) { return(IteratorHelper.GetEmptyEnumerable <IPrimarySourceLocation>()); }
/// <summary> /// Return zero or more locations in primary source documents that correspond to the definition of the given local. /// </summary> public IEnumerable <IPrimarySourceLocation> GetPrimarySourceLocationsForDefinitionOf(ILocalDefinition localDefinition) { ISourceLocationProvider /*?*/ provider = this.GetProvider(localDefinition); if (provider == null) { return(Enumerable <IPrimarySourceLocation> .Empty); } else { return(provider.GetPrimarySourceLocationsForDefinitionOf(localDefinition)); } }
/*?*/ private ILocalScopeProvider GetProvider(ILocalDefinition localDefinition) { return this.GetProvider(localDefinition.MethodDefinition); }
/// <summary> /// Performs some computation with the given local definition. /// </summary> public virtual void Visit(ILocalDefinition localDefinition) { }
public void VisitReference(ILocalDefinition localDefinition) { Contract.Assume(false); }
/// <summary> /// Visits the specified local definition. /// </summary> /// <param name="localDefinition">The local definition.</param> public virtual void Visit(ILocalDefinition localDefinition) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(localDefinition); if (localDefinition.IsModified) this.Visit(localDefinition.CustomModifiers); this.Visit(localDefinition.Type); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not to decrease this.path.Count. this.path.Pop(); }
/// <summary> /// Traverses the children of the specified local definition. /// </summary> public virtual void TraverseChildren(ILocalDefinition localDefinition) { Contract.Requires(localDefinition != null); if (localDefinition.IsConstant) this.Traverse(localDefinition.CompileTimeValue); if (localDefinition.IsModified) this.Traverse(localDefinition.CustomModifiers); if (this.stopTraversal) return; this.Traverse(localDefinition.Type); }
/// <summary> /// Traverses the specified local definition. /// </summary> public void Traverse(ILocalDefinition localDefinition) { Contract.Requires(localDefinition != null); if (!this.objectsThatHaveAlreadyBeenTraversed.Add(localDefinition)) return; if (this.preorderVisitor != null) this.preorderVisitor.Visit(localDefinition); if (this.stopTraversal) return; this.TraverseChildren(localDefinition); if (this.stopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(localDefinition); }
public override void TraverseChildren(ILocalDefinition localDefinition) { base.TraverseChildren(localDefinition); }
private PdbFunction GetPdbFunctionFor(ILocalDefinition localDefinition) { PdbFunction/*?*/ result = null; foreach (ILocation location in localDefinition.Locations) { MethodBodyLocation/*?*/ mbLocation = location as MethodBodyLocation; if (mbLocation != null) { this.pdbFunctionMap.TryGetValue(mbLocation.Document.MethodToken, out result); break; } } return result; }
private void PrintLocalName(ILocalDefinition local) { this.writer.Write(this.GetLocalName(local)); }
public virtual void onMetadataElement(ILocalDefinition localDefinition) { }
public override void TraverseChildren(ILocalDefinition localDefinition) { if (!foundLocals.Contains(localDefinition)) foundLocals.Add(localDefinition); base.TraverseChildren(localDefinition); }
/// <summary> /// /// </summary> /// <param name="localDefinition"></param> /// <param name="isCompilerGenerated"></param> /// <returns></returns> public string GetSourceNameFor(ILocalDefinition localDefinition, out bool isCompilerGenerated) { isCompilerGenerated = true; PdbFunction/*?*/ pdbFunction = this.GetPdbFunctionFor(localDefinition); if (pdbFunction != null) { uint index = 0; foreach (ILocation location in localDefinition.Locations) { MethodBodyLocation/*?*/ mbLocation = location as MethodBodyLocation; if (mbLocation != null) { index = mbLocation.Offset; break; } } PdbSlot/*?*/ slot = this.GetSlotFor(pdbFunction.scopes, index); if (slot != null) { isCompilerGenerated = (slot.flags & 0x4) != 0; return slot.name; } } return localDefinition.Name.Value; }
private BlobIdx SerializeLocalConstantSignature(ILocalDefinition localConstant) { var writer = new BlobBuilder(); // CustomMod* SerializeCustomModifiers(localConstant.CustomModifiers, writer); var type = localConstant.Type; var typeCode = type.TypeCode(Context); object value = localConstant.CompileTimeValue.Value; // PrimitiveConstant or EnumConstant if (value is decimal) { writer.WriteByte(0x11); writer.WriteCompressedInteger(GetTypeDefOrRefCodedIndex(type, treatRefAsPotentialTypeSpec: true)); writer.WriteDecimal((decimal)value); } else if (value is DateTime) { writer.WriteByte(0x11); writer.WriteCompressedInteger(GetTypeDefOrRefCodedIndex(type, treatRefAsPotentialTypeSpec: true)); writer.WriteDateTime((DateTime)value); } else if (typeCode == PrimitiveTypeCode.String) { writer.WriteByte((byte)ConstantTypeCode.String); if (value == null) { writer.WriteByte(0xff); } else { writer.WriteUTF16((string)value); } } else if (value != null) { // TypeCode writer.WriteByte((byte)GetConstantTypeCode(value)); // Value writer.WriteConstant(value); // EnumType if (type.IsEnum) { writer.WriteCompressedInteger(GetTypeDefOrRefCodedIndex(type, treatRefAsPotentialTypeSpec: true)); } } else if (this.module.IsPlatformType(type, PlatformType.SystemObject)) { writer.WriteByte(0x1c); } else { writer.WriteByte((byte)(type.IsValueType ? 0x11 : 0x12)); writer.WriteCompressedInteger(GetTypeDefOrRefCodedIndex(type, treatRefAsPotentialTypeSpec: true)); } return(_debugHeapsOpt.GetBlobIndex(writer)); }
/// <summary> /// Return zero or more locations in primary source documents that correspond to the definition of the given local. /// </summary> public IEnumerable <IPrimarySourceLocation> GetPrimarySourceLocationsForDefinitionOf(ILocalDefinition localDefinition) { PdbFunction /*?*/ pdbFunction = this.GetPdbFunctionFor(localDefinition); if (pdbFunction != null) { uint index = 0; foreach (ILocation location in localDefinition.Locations) { IILLocation /*?*/ mbLocation = location as IILLocation; if (mbLocation != null) { index = mbLocation.Offset; break; } } PdbSlot /*?*/ slot = this.GetSlotFor(pdbFunction.scopes, index); if (slot != null && (slot.flags & 0x4) == 0) { return(IteratorHelper.GetSingletonEnumerable <IPrimarySourceLocation>(new LocalNameSourceLocation(slot.name))); } } return(Enumerable <IPrimarySourceLocation> .Empty); }
public override IStatement Rewrite(IExpressionStatement expressionStatement) { this.currentSingleUseSingleReferenceLocal = null; var result = base.Rewrite(expressionStatement); if (this.currentSingleUseSingleReferenceLocal != null) { var exprStat = result as IExpressionStatement; if (exprStat != null) { var assign = exprStat.Expression as IAssignment; if (assign != null && assign.Target.Definition == this.currentSingleUseSingleReferenceLocal) this.expressionToSubstituteForSingleUseSingleReferenceLocal = assign.Source; } } return result; }
/// <summary> /// When given a method definition and a block of statements that represents the Block property of the body of the method /// this method returns a semantically equivalent SourceMethod with a body that no longer has any anonymous delegate expressions. /// The given block of statements is mutated in place. /// Any types that get defined in order to implement the body semantics are returned (null if no such types are defined). /// </summary> /// <param name="method">The method containing the block that is to be rewritten.</param> /// <param name="body">The block to be rewritten. /// The entire tree rooted at the block must be mutable and the nodes must not be shared with anything else.</param> public ICollection<ITypeDefinition>/*?*/ RemoveAnonymousDelegates(IMethodDefinition method, BlockStatement body) { this.method = method; var finder = new CapturedParameterAndLocalFinder(); finder.TraverseChildren(body); this.fieldReferencesForUseInsideAnonymousMethods = finder.captures; this.anonymousDelegatesThatCaptureLocalsOrParameters = finder.anonymousDelegatesThatCaptureLocalsOrParameters; this.anonymousDelegatesThatCaptureThis = finder.anonymousDelegatesThatCaptureThis; finder = null; var blockFinder = new ScopesWithCapturedLocalsFinder(this.fieldReferencesForUseInsideAnonymousMethods); blockFinder.TraverseChildren(body); this.scopesWithCapturedLocals = blockFinder.scopesWithCapturedLocals; blockFinder = null; this.fieldReferencesForUseInsideThisMethod = new Dictionary<object, IFieldReference>(this.fieldReferencesForUseInsideAnonymousMethods); this.GenerateTopLevelClosure(); if (this.currentClosureClass != null) { //declare a local to keep the parameter closure class var closureLocal = new LocalDefinition() { Type = this.currentClosureInstance, Name = this.host.NameTable.GetNameFor("CS$<>8__locals"+this.closureClasses.Count) }; this.currentClosureLocal = closureLocal; this.currentClosureObject = new BoundExpression() { Definition = closureLocal, Type = closureLocal.Type }; this.closureLocalInstances = new List<IExpression>(); this.closureLocalInstances.Add(this.currentClosureObject); this.scopesWithCapturedLocals.Remove(body); //otherwise it will introduce its own closure class if any of its locals were captured. this.RewriteChildren(body); //do this after rewriting so that parameter references are not rewritten into closure field references. this.InsertStatementsToAllocateAndInitializeTopLevelClosure(body); } else { this.RewriteChildren(body); } return this.closureClasses == null ? null : this.closureClasses.AsReadOnly(); }
public override IExpression Rewrite(IAssignment assignment) { var binOp = assignment.Source as BinaryOperation; if (binOp != null) { var addressDeref = binOp.LeftOperand as IAddressDereference; if (addressDeref != null) { var dupValue = addressDeref.Address as IDupValue; if (dupValue != null && assignment.Target.Definition is IAddressDereference) { if (binOp is IAddition || binOp is IBitwiseAnd || binOp is IBitwiseOr || binOp is IDivision || binOp is IExclusiveOr || binOp is ILeftShift || binOp is IModulus || binOp is IMultiplication || binOp is IRightShift || binOp is ISubtraction) { binOp.LeftOperand = assignment.Target; return binOp; } } } else { var boundExpr = binOp.LeftOperand as IBoundExpression; if (boundExpr != null && boundExpr.Definition == assignment.Target.Definition && boundExpr.Instance is IDupValue) { if (binOp is IAddition || binOp is IBitwiseAnd || binOp is IBitwiseOr || binOp is IDivision || binOp is IExclusiveOr || binOp is ILeftShift || binOp is IModulus || binOp is IMultiplication || binOp is IRightShift || binOp is ISubtraction) { binOp.LeftOperand = assignment.Target; return binOp; } } } } else { var assign2 = assignment.Source as Assignment; if (assign2 != null) { var targetLocal = assign2.Target.Definition as ILocalDefinition; if (targetLocal != null) { binOp = assign2.Source as BinaryOperation; if (binOp != null) { var addressDeref = binOp.LeftOperand as IAddressDereference; if (addressDeref != null) { var dupValue = addressDeref.Address as IDupValue; if (dupValue != null && assignment.Target.Definition is IAddressDereference) { if (binOp is IAddition || binOp is IBitwiseAnd || binOp is IBitwiseOr || binOp is IDivision || binOp is IExclusiveOr || binOp is ILeftShift || binOp is IModulus || binOp is IMultiplication || binOp is IRightShift || binOp is ISubtraction) { binOp.LeftOperand = assignment.Target; if (this.numberOfReferencesToLocal[targetLocal] == 1 && this.numberOfAssignmentsToLocal[targetLocal] == 1) this.currentSingleUseSingleReferenceLocal = targetLocal; return assign2; } } } } } } else { var conversion = assignment.Source as IConversion; if (conversion != null) { binOp = conversion.ValueToConvert as BinaryOperation; if (binOp != null) { var addressDeref = binOp.LeftOperand as IAddressDereference; if (addressDeref != null) { var dupValue = addressDeref.Address as IDupValue; if (dupValue != null && assignment.Target.Definition is IAddressDereference) { if (binOp is IAddition || binOp is IBitwiseAnd || binOp is IBitwiseOr || binOp is IDivision || binOp is IExclusiveOr || binOp is ILeftShift || binOp is IModulus || binOp is IMultiplication || binOp is IRightShift || binOp is ISubtraction) { binOp.LeftOperand = assignment.Target; return binOp; } } } else { var boundExpr = binOp.LeftOperand as IBoundExpression; if (boundExpr != null && boundExpr.Definition == assignment.Target.Definition && boundExpr.Instance is IDupValue) { if (binOp is IAddition || binOp is IBitwiseAnd || binOp is IBitwiseOr || binOp is IDivision || binOp is IExclusiveOr || binOp is ILeftShift || binOp is IModulus || binOp is IMultiplication || binOp is IRightShift || binOp is ISubtraction) { binOp.LeftOperand = assignment.Target; binOp.RightOperand = TypeInferencer.Convert(binOp.RightOperand, assignment.Target.Type); return binOp; } } } } else { // For a character-typed field, c, the C# source expressions: // o.c += (char)0, o.c -= (char)0, and o.c *= (char)1 // produce the IL: "load o; dup; ldfld c; stfld c;". // (For some reason, the C# compiler does not do the same thing for "o.c /= (char)1".) // Such IL shows up here as "o.c = convert(ushort, dup.c)". // Arbitrarily turn it back into "o.c += (char)0". if (IsBoundExpressionWithDupInstance(conversion.ValueToConvert)) { var t = conversion.ValueToConvert.Type; if (t.TypeCode == PrimitiveTypeCode.Char) { return new Addition() { LeftOperand = assignment.Target, RightOperand = new Conversion() { TypeAfterConversion = t, ValueToConvert = new CompileTimeConstant() { Value = 0, Type = assignment.Type, }, }, ResultIsUnmodifiedLeftOperand = false, Type = assignment.Type, }; } } } } else { // There are several C# source expressions that produce the IL: "load o; dup; ldfld f; stfld f;". // Examples are: o.f += 0, o.f -= 0, o.f *= 1, o.f &= true, o.f |= false. // (For some reason, the C# compiler does not do the same thing for "o.f /= 1".) // Such IL shows up here as "o.f = dup.f". // Arbitrarily turn it back into "o.f += 0" for arithmetic types and "o.f |= false" for boolean. if (IsBoundExpressionWithDupInstance(assignment.Source)) { if (TypeHelper.IsPrimitiveInteger(assignment.Type) && assignment.Type.TypeCode != PrimitiveTypeCode.Char) { return new Addition() { LeftOperand = assignment.Target, RightOperand = new CompileTimeConstant() { Value = 0, Type = assignment.Type, }, ResultIsUnmodifiedLeftOperand = false, Type = assignment.Type, }; } else if (assignment.Type.TypeCode == PrimitiveTypeCode.Boolean) { return new BitwiseOr() { LeftOperand = assignment.Target, RightOperand = new CompileTimeConstant() { Value = false, Type = assignment.Type, }, ResultIsUnmodifiedLeftOperand = false, Type = assignment.Type, }; } } } } } return base.Rewrite(assignment); }
/// <summary> /// Performs some computation with the given local definition. /// </summary> public void Visit(ILocalDefinition localDefinition) { }
private ILocalScopeProvider/*?*/ GetProvider(ILocalDefinition localDefinition) { Contract.Requires(localDefinition != null); return this.GetProvider(localDefinition.MethodDefinition); }
public virtual void Visit(ILocalDefinition localDefinition) { this.Visit(localDefinition.CustomModifiers); this.Visit(localDefinition.Type); }
private ILocalDefinition GetCorrespondingLocal(ILocalDefinition originalLocalDef) { Contract.Requires(originalLocalDef != null); Contract.Ensures(Contract.Result<ILocalDefinition>() != null); return (this.mapFromOriginalToCopy[originalLocalDef] as ILocalDefinition)??originalLocalDef; }
private ILocalDefinition GetLocalWithSourceName(ILocalDefinition localDef) { if (this.sourceLocationProvider == null) return localDef; var mutableLocal = this.localMap[localDef]; if (mutableLocal != null) return mutableLocal; mutableLocal = localDef as LocalDefinition; if (mutableLocal == null) { mutableLocal = new LocalDefinition(); mutableLocal.Copy(localDef, this.host.InternFactory); } this.localMap.Add(localDef, mutableLocal); bool isCompilerGenerated; var sourceName = this.sourceLocationProvider.GetSourceNameFor(localDef, out isCompilerGenerated); if (sourceName != localDef.Name.Value) { mutableLocal.Name = this.host.NameTable.GetNameFor(sourceName); } return mutableLocal; }
public virtual void Visit(ILocalDefinition localDefinition) { this.Visit(localDefinition.CustomModifiers); this.Visit(localDefinition.Type); }
private BlobHandle SerializeLocalConstantSignature(ILocalDefinition localConstant) { var builder = new BlobBuilder(); // TODO: BlobEncoder.LocalConstantSignature // CustomMod* var encoder = new CustomModifiersEncoder(builder); SerializeCustomModifiers(encoder, localConstant.CustomModifiers); var type = localConstant.Type; var typeCode = type.TypeCode(Context); object value = localConstant.CompileTimeValue.Value; // PrimitiveConstant or EnumConstant if (value is decimal) { builder.WriteByte((byte)SignatureTypeKind.ValueType); builder.WriteCompressedInteger(CodedIndex.TypeDefOrRefOrSpec(GetTypeHandle(type))); builder.WriteDecimal((decimal)value); } else if (value is DateTime) { builder.WriteByte((byte)SignatureTypeKind.ValueType); builder.WriteCompressedInteger(CodedIndex.TypeDefOrRefOrSpec(GetTypeHandle(type))); builder.WriteDateTime((DateTime)value); } else if (typeCode == PrimitiveTypeCode.String) { builder.WriteByte((byte)ConstantTypeCode.String); if (value == null) { builder.WriteByte(0xff); } else { builder.WriteUTF16((string)value); } } else if (value != null) { // TypeCode builder.WriteByte((byte)GetConstantTypeCode(value)); // Value builder.WriteConstant(value); // EnumType if (type.IsEnum) { builder.WriteCompressedInteger(CodedIndex.TypeDefOrRefOrSpec(GetTypeHandle(type))); } } else if (this.module.IsPlatformType(type, PlatformType.SystemObject)) { builder.WriteByte((byte)SignatureTypeCode.Object); } else { builder.WriteByte((byte)(type.IsValueType ? SignatureTypeKind.ValueType : SignatureTypeKind.Class)); builder.WriteCompressedInteger(CodedIndex.TypeDefOrRefOrSpec(GetTypeHandle(type))); } return(_debugMetadataOpt.GetOrAddBlob(builder)); }
private ILocalDefinition GetLocalWithSourceName(ILocalDefinition localDef) { Contract.Requires(localDef != null); Contract.Ensures(Contract.Result<ILocalDefinition>() != null); return this.sourceMethodBody.GetLocalWithSourceName(localDef); }
private static IEnumerable<string> GetTypesOfVariable(ILocalDefinition variable) { return from t in variable.Type.GetAllRealTypeReferences() select t.ToString(); }
private ISourceLocationProvider /*?*/ GetProvider(ILocalDefinition localDefinition) { return(this.GetProvider(localDefinition.MethodDefinition)); }
public override void TraverseChildren(ILocalDefinition localDefinition) { MethodEnter(localDefinition); base.TraverseChildren(localDefinition); MethodExit(); }
private ILocalScopeProvider /*?*/ GetProvider(ILocalDefinition localDefinition) { return(this.GetProvider(localDefinition.MethodDefinition)); }
/*?*/ private ISourceLocationProvider GetProvider(ILocalDefinition localDefinition) { return this.GetProvider(localDefinition.MethodDefinition); }
/// <summary> /// Return zero or more locations in primary source documents that correspond to the definition of the given local. /// </summary> public IEnumerable<IPrimarySourceLocation> GetPrimarySourceLocationsForDefinitionOf(ILocalDefinition localDefinition) { PdbFunction/*?*/ pdbFunction = this.GetPdbFunctionFor(localDefinition); if (pdbFunction != null) { uint index = 0; foreach (ILocation location in localDefinition.Locations) { MethodBodyLocation/*?*/ mbLocation = location as MethodBodyLocation; if (mbLocation != null) { index = mbLocation.Offset; break; } } PdbSlot/*?*/ slot = this.GetSlotFor(pdbFunction.scopes, index); if (slot != null && (slot.flags & 0x4) == 0) return IteratorHelper.GetSingletonEnumerable<IPrimarySourceLocation>(new LocalNameSourceLocation(slot.name)); } return IteratorHelper.GetEmptyEnumerable<IPrimarySourceLocation>(); }
internal void SetLocalVariables(ILocalDefinition[] localVariables) { this.LocalVariables = localVariables; }
// Interpret the instruction in the given abstract state and return the resulting abstract state private LocalsAndOperands <V> InterpretInstructionInState(Instruction instruction, LocalsAndOperands <V> preState, IMethodDefinition method) { LocalsAndOperands <V> currentState = preState.Copy(); // Switch cases copied directly from Cci's DataFlowInferencer NotePreStateBeforeInterpretingInstruction(currentState, instruction); switch (instruction.Operation.OperationCode) { case OperationCode.Add: case OperationCode.Add_Ovf: case OperationCode.Add_Ovf_Un: case OperationCode.And: case OperationCode.Ceq: case OperationCode.Cgt: case OperationCode.Cgt_Un: case OperationCode.Clt: case OperationCode.Clt_Un: case OperationCode.Div: case OperationCode.Div_Un: case OperationCode.Ldelema: case OperationCode.Ldelem: case OperationCode.Ldelem_I: case OperationCode.Ldelem_I1: case OperationCode.Ldelem_I2: case OperationCode.Ldelem_I4: case OperationCode.Ldelem_I8: case OperationCode.Ldelem_R4: case OperationCode.Ldelem_R8: case OperationCode.Ldelem_Ref: case OperationCode.Ldelem_U1: case OperationCode.Ldelem_U2: case OperationCode.Ldelem_U4: case OperationCode.Mul: case OperationCode.Mul_Ovf: case OperationCode.Mul_Ovf_Un: case OperationCode.Or: case OperationCode.Rem: case OperationCode.Rem_Un: case OperationCode.Shl: case OperationCode.Shr: case OperationCode.Shr_Un: case OperationCode.Sub: case OperationCode.Sub_Ovf: case OperationCode.Sub_Ovf_Un: case OperationCode.Xor: //instruction.Operand2 = stack.Pop(); //instruction.Operand1 = stack.Pop(); //stack.Push(instruction); currentState.Pop(); currentState.Pop(); //currentState.Push(ValueAbstraction.Top); // Not right currentState.Push(ValueAbstraction.GetAbstractValueForType(FixupTypeForFlow(instruction.Type.ResolvedType))); // still not right break; case OperationCode.Ldarg: case OperationCode.Ldarg_0: case OperationCode.Ldarg_1: case OperationCode.Ldarg_2: case OperationCode.Ldarg_3: case OperationCode.Ldarg_S: { int argumentIndex = GetArgumentIndexFromParameterOperation(instruction.Operation, method); V argumentValue = currentState.Arguments.ElementAt(argumentIndex); currentState.Push(argumentValue); } break; case OperationCode.Ldloc: case OperationCode.Ldloc_0: case OperationCode.Ldloc_1: case OperationCode.Ldloc_2: case OperationCode.Ldloc_3: case OperationCode.Ldloc_S: { Contract.Assume(instruction.Operation.Value is ILocalDefinition); ILocalDefinition local = instruction.Operation.Value as ILocalDefinition; int localIndex = GetLocalIndexFromLocalOperation(instruction.Operation, method); V localValue = currentState.Locals.ElementAt(localIndex); currentState.Push(localValue); } break; case OperationCode.Ldsfld: case OperationCode.Ldarga: case OperationCode.Ldarga_S: case OperationCode.Ldsflda: case OperationCode.Ldloca: case OperationCode.Ldloca_S: case OperationCode.Ldftn: case OperationCode.Ldc_I4: case OperationCode.Ldc_I4_0: case OperationCode.Ldc_I4_1: case OperationCode.Ldc_I4_2: case OperationCode.Ldc_I4_3: case OperationCode.Ldc_I4_4: case OperationCode.Ldc_I4_5: case OperationCode.Ldc_I4_6: case OperationCode.Ldc_I4_7: case OperationCode.Ldc_I4_8: case OperationCode.Ldc_I4_M1: case OperationCode.Ldc_I4_S: case OperationCode.Ldc_I8: case OperationCode.Ldc_R4: case OperationCode.Ldc_R8: case OperationCode.Ldnull: case OperationCode.Ldstr: case OperationCode.Ldtoken: case OperationCode.Sizeof: case OperationCode.Arglist: //stack.Push(instruction); //currentState.Push(ValueAbstraction.Top); // not right currentState.Push(ValueAbstraction.GetAbstractValueForType(FixupTypeForFlow(instruction.Type.ResolvedType))); // Still not right break; case OperationCode.Array_Addr: case OperationCode.Array_Get: Contract.Assume(instruction.Operation.Value is IArrayTypeReference); //This is an informally specified property of the Metadata model. //InitializeArrayIndexerInstruction(instruction, stack, (IArrayTypeReference)instruction.Operation.Value); InitializeArrayIndexerInstruction(instruction, currentState, (IArrayTypeReference)instruction.Operation.Value); break; case OperationCode.Array_Create: case OperationCode.Array_Create_WithLowerBound: case OperationCode.Newarr: InitializeArrayCreateInstruction(instruction, currentState, instruction.Operation); break; case OperationCode.Array_Set: /*stack.Pop(); * Contract.Assume(instruction.Operation.Value is IArrayTypeReference); //This is an informally specified property of the Metadata model. * InitializeArrayIndexerInstruction(instruction, stack, (IArrayTypeReference)instruction.Operation.Value); */ currentState.Pop(); Contract.Assume(instruction.Operation.Value is IArrayTypeReference); //This is an informally specified property of the Metadata model. InitializeArrayIndexerInstruction(instruction, currentState, (IArrayTypeReference)instruction.Operation.Value); break; case OperationCode.Beq: case OperationCode.Beq_S: case OperationCode.Bge: case OperationCode.Bge_S: case OperationCode.Bge_Un: case OperationCode.Bge_Un_S: case OperationCode.Bgt: case OperationCode.Bgt_S: case OperationCode.Bgt_Un: case OperationCode.Bgt_Un_S: case OperationCode.Ble: case OperationCode.Ble_S: case OperationCode.Ble_Un: case OperationCode.Ble_Un_S: case OperationCode.Blt: case OperationCode.Blt_S: case OperationCode.Blt_Un: case OperationCode.Blt_Un_S: case OperationCode.Bne_Un: case OperationCode.Bne_Un_S: /*instruction.Operand2 = stack.Pop(); * instruction.Operand1 = stack.Pop(); */ currentState.Pop(); currentState.Pop(); break; case OperationCode.Box: case OperationCode.Castclass: case OperationCode.Ckfinite: case OperationCode.Conv_I: case OperationCode.Conv_I1: case OperationCode.Conv_I2: case OperationCode.Conv_I4: case OperationCode.Conv_I8: case OperationCode.Conv_Ovf_I: case OperationCode.Conv_Ovf_I_Un: case OperationCode.Conv_Ovf_I1: case OperationCode.Conv_Ovf_I1_Un: case OperationCode.Conv_Ovf_I2: case OperationCode.Conv_Ovf_I2_Un: case OperationCode.Conv_Ovf_I4: case OperationCode.Conv_Ovf_I4_Un: case OperationCode.Conv_Ovf_I8: case OperationCode.Conv_Ovf_I8_Un: case OperationCode.Conv_Ovf_U: case OperationCode.Conv_Ovf_U_Un: case OperationCode.Conv_Ovf_U1: case OperationCode.Conv_Ovf_U1_Un: case OperationCode.Conv_Ovf_U2: case OperationCode.Conv_Ovf_U2_Un: case OperationCode.Conv_Ovf_U4: case OperationCode.Conv_Ovf_U4_Un: case OperationCode.Conv_Ovf_U8: case OperationCode.Conv_Ovf_U8_Un: case OperationCode.Conv_R_Un: case OperationCode.Conv_R4: case OperationCode.Conv_R8: case OperationCode.Conv_U: case OperationCode.Conv_U1: case OperationCode.Conv_U2: case OperationCode.Conv_U4: case OperationCode.Conv_U8: case OperationCode.Isinst: case OperationCode.Ldind_I: case OperationCode.Ldind_I1: case OperationCode.Ldind_I2: case OperationCode.Ldind_I4: case OperationCode.Ldind_I8: case OperationCode.Ldind_R4: case OperationCode.Ldind_R8: case OperationCode.Ldind_Ref: case OperationCode.Ldind_U1: case OperationCode.Ldind_U2: case OperationCode.Ldind_U4: case OperationCode.Ldobj: case OperationCode.Ldflda: case OperationCode.Ldfld: case OperationCode.Ldlen: case OperationCode.Ldvirtftn: case OperationCode.Localloc: case OperationCode.Mkrefany: case OperationCode.Neg: case OperationCode.Not: case OperationCode.Refanytype: case OperationCode.Refanyval: case OperationCode.Unbox: case OperationCode.Unbox_Any: /*instruction.Operand1 = stack.Pop(); * stack.Push(instruction); */ currentState.Pop(); //currentState.Push(ValueAbstraction.Top); // Could be smarter than Top currentState.Push(ValueAbstraction.GetAbstractValueForType(FixupTypeForFlow(instruction.Type.ResolvedType))); // Still not right break; case OperationCode.Brfalse: case OperationCode.Brfalse_S: case OperationCode.Brtrue: case OperationCode.Brtrue_S: //instruction.Operand1 = stack.Pop(); currentState.Pop(); break; case OperationCode.Call: /*var signature = instruction.Operation.Value as ISignature; * Contract.Assume(signature != null); //This is an informally specified property of the Metadata model. * if (!signature.IsStatic) instruction.Operand1 = stack.Pop(); * InitializeArgumentsAndPushReturnResult(instruction, stack, signature); */ var signature = instruction.Operation.Value as ISignature; Contract.Assume(signature != null); //This is an informally specified property of the Metadata model. InterpretCallWithSignature(currentState, signature, !signature.IsStatic); break; case OperationCode.Callvirt: /* * instruction.Operand1 = stack.Pop(); * Contract.Assume(instruction.Operation.Value is ISignature); //This is an informally specified property of the Metadata model. * InitializeArgumentsAndPushReturnResult(instruction, stack, (ISignature)instruction.Operation.Value); */ Contract.Assume(instruction.Operation.Value is ISignature); //This is an informally specified property of the Metadata model. InterpretCallWithSignature(currentState, (ISignature)instruction.Operation.Value, true); break; case OperationCode.Calli: /* * Contract.Assume(instruction.Operation.Value is ISignature); //This is an informally specified property of the Metadata model. * InitializeArgumentsAndPushReturnResult(instruction, stack, (ISignature)instruction.Operation.Value); * instruction.Operand1 = stack.Pop(); */ currentState.Pop(); // the method pointer signature = instruction.Operation.Value as ISignature; Contract.Assume(signature != null); //This is an informally specified property of the Metadata model. InterpretCallWithSignature(currentState, (ISignature)instruction.Operation.Value, !signature.IsStatic); break; case OperationCode.Cpobj: case OperationCode.Stfld: case OperationCode.Stind_I: case OperationCode.Stind_I1: case OperationCode.Stind_I2: case OperationCode.Stind_I4: case OperationCode.Stind_I8: case OperationCode.Stind_R4: case OperationCode.Stind_R8: case OperationCode.Stind_Ref: case OperationCode.Stobj: /* * instruction.Operand2 = stack.Pop(); * instruction.Operand1 = stack.Pop(); */ currentState.Pop(); currentState.Pop(); break; case OperationCode.Cpblk: case OperationCode.Initblk: case OperationCode.Stelem: case OperationCode.Stelem_I: case OperationCode.Stelem_I1: case OperationCode.Stelem_I2: case OperationCode.Stelem_I4: case OperationCode.Stelem_I8: case OperationCode.Stelem_R4: case OperationCode.Stelem_R8: case OperationCode.Stelem_Ref: /*var indexAndValue = new Instruction[2]; * indexAndValue[1] = stack.Pop(); * indexAndValue[0] = stack.Pop(); * instruction.Operand2 = indexAndValue; * instruction.Operand1 = stack.Pop(); */ currentState.Pop(); currentState.Pop(); currentState.Pop(); break; case OperationCode.Dup: /* * var dupop = stack.Pop(); * instruction.Operand1 = dupop; * stack.Push(dupop); * stack.Push(instruction); */ // Pop the top and push it twice var dupValue = currentState.Pop(); currentState.Push(dupValue); currentState.Push(dupValue); break; case OperationCode.Starg: case OperationCode.Starg_S: { int argumentIndex = GetArgumentIndexFromParameterOperation(instruction.Operation, method); V newArgumentValue = currentState.Pop(); currentState.Arguments[argumentIndex] = newArgumentValue; } break; case OperationCode.Stloc: case OperationCode.Stloc_0: case OperationCode.Stloc_1: case OperationCode.Stloc_2: case OperationCode.Stloc_3: case OperationCode.Stloc_S: { Contract.Assume(instruction.Operation.Value is ILocalDefinition); ILocalDefinition local = instruction.Operation.Value as ILocalDefinition; int localIndex = GetLocalIndexFromLocalOperation(instruction.Operation, method); V newLocalValue = currentState.Pop(); currentState.Locals[localIndex] = newLocalValue; } break; case OperationCode.Endfilter: case OperationCode.Initobj: case OperationCode.Pop: case OperationCode.Stsfld: case OperationCode.Throw: case OperationCode.Switch: //instruction.Operand1 = stack.Pop(); currentState.Pop(); break; case OperationCode.Newobj: /* * Contract.Assume(instruction.Operation.Value is ISignature); //This is an informally specified property of the Metadata model. * InitializeArgumentsAndPushReturnResult(instruction, stack, (ISignature)instruction.Operation.Value); //won't push anything * stack.Push(instruction); */ Contract.Assume(instruction.Operation.Value is IMethodReference); //This is an informally specified property of the Metadata model. InterpretCallWithSignature(currentState, (ISignature)instruction.Operation.Value, false); //won't push anything, since return type is void currentState.Push(ValueAbstraction.GetAbstractValueForType(FixupTypeForFlow(((IMethodReference)instruction.Operation.Value).ResolvedMethod.ContainingTypeDefinition))); break; case OperationCode.Ret: /*if (this.cdfg.MethodBody.MethodDefinition.Type.TypeCode != PrimitiveTypeCode.Void) * instruction.Operand1 = stack.Pop(); */ if (method.Type.TypeCode != PrimitiveTypeCode.Void) { currentState.Pop(); } break; } return(currentState); }