private bool IsStackVariable(VariableReference varRef) { return methodContext.StackData.VariableToDefineUseInfo.ContainsKey(varRef.Resolve()); }
protected string GetVariableName(VariableReference variable) { VariableDefinition variableDefinition = variable.Resolve(); string result; if (!GetCurrentMethodContext().VariableDefinitionToNameMap.TryGetValue(variableDefinition, out result)) { result = variableDefinition.Name; } return result; }
public void RemoveVariable (VariableReference reference) { RemoveVariable (reference.Resolve ()); }
/// <summary> /// A cecil variable reference will be directed to this method. /// </summary> /// <param name="item">Cecil reference.</param> /// <param name="resolvedItem">Output parameter that will be populated with the resolved cecil definition.</param> /// <returns><c>true</c></returns> private static bool TryResolve(VariableReference item, out object resolvedItem) { resolvedItem = item.Resolve(); return true; }
private bool IsTempVariable(VariableReference variable) { var name = methodContext.VariableDefinitionToNameMap[variable.Resolve()]; if (name.StartsWith("CS$") || name.StartsWith("VB$") || name.IndexOf("__init") > 0 || name.StartsWith("stackVariable") || name.StartsWith("exception_")) { return true; } return false; }
internal void RemoveVariable(VariableReference reference) { RemoveVariable(reference.Resolve()); }
private Expression GetIdentifierReference(VariableReference identifierReference, ref Expression target) { MethodInvocationExpression targetInvocation = target as MethodInvocationExpression; if (targetInvocation != null && targetInvocation.MethodExpression.MethodDefinition != null && targetInvocation.MethodExpression.MethodDefinition.IsStatic && (targetInvocation.MethodExpression.MethodDefinition.DeclaringType.FullName == "System.Linq.Enumerable" || targetInvocation.MethodExpression.MethodDefinition.DeclaringType.FullName == "System.Linq.Queryable") && targetInvocation.MethodExpression.Method.Name == "Cast") { target = targetInvocation.Arguments[0]; methodContext.UndeclaredLinqVariables.Remove(identifierReference.Resolve()); return new VariableDeclarationExpression(identifierReference.Resolve(), null); } return new VariableReferenceExpression(identifierReference, null); }