protected static IExpressionStatement InvokeStmt(string varName, IMethodName method) { return(new ExpressionStatement { Expression = Invoke(varName, method) }); }
private static IInvocationExpression InvokeStatic(IMethodName method) { return(new InvocationExpression { MethodName = method }); }
public void RegisterCallsite(string id, IMethodName callsite) { // TODO @seb fix analysis and then remove this check! if (Equals("", callsite.Name)) { return; } if (NameResolver.IsExisting(id)) { var q = NameResolver.Find(id); q.sites.Add(CallSites.CreateReceiverCallSite(callsite)); } else { var type = callsite.DeclaringType.ToCoReName(); if (NameResolver.IsExisting(type)) { var q = NameResolver.Find(type); q.sites.Add(CallSites.CreateReceiverCallSite(callsite)); } else { var q = NewQueryFor(type, DefinitionSites.CreateUnknownDefinitionSite()); q.sites.Add(CallSites.CreateReceiverCallSite(callsite)); NameResolver.Register(type, q); } } }
protected void SetupEnclosingMethod(IMethodName enclosingMethod, params IStatement[] statements) { Context.TypeShape.TypeHierarchy = new TypeHierarchy { Element = DefaultClassContext }; Context.TypeShape.MethodHierarchies.Add( new MethodHierarchy { Element = enclosingMethod }); Context.SST = new SST { EnclosingType = enclosingMethod.DeclaringType, Methods = { new MethodDeclaration { Name = enclosingMethod, Body = Lists.NewListFrom(statements) } } }; }
public static CoReMethodName ToCoReName([NotNull] this IMethodName name) { var builder = new StringBuilder(); if (name.IsConstructor) { builder.Append(name.DeclaringType.ToName(), ".<init>("); StringBuilderUtils.Append(builder, name.Parameters.Select(n => n.ValueType.ToName() + ";").ToArray()); builder.Append(")LSystem/Void;"); } else { builder.Append(name.DeclaringType.ToName(), "."); builder.Append(name.IsUnknown ? "unknown" : name.Name); builder.Append("("); // TODO @seb: fix analysis and remove check; if (name.Parameters != null) { StringBuilderUtils.Append( builder, name.Parameters.Select(n => n.ValueType.ToName() + ";").ToArray()); } builder.Append(")", name.ReturnType.ToName(), ";"); } return(new CoReMethodName(builder.ToString())); }
protected static IInvocationExpression Invoke(string varName, IMethodName method) { return(new InvocationExpression { Reference = VarRef(varName), MethodName = method }); }
internal static IMethodName AddLambda(IMethodName method) { var oldName = "." + method.Name + "("; var newName = "." + method.Name + "$Lambda("; var newId = method.Identifier.Replace(oldName, newName); return(Names.Method(newId)); }
public static IExpressionStatement InvocationStatement(IMethodName name, IEnumerable <ISimpleExpression> parameters) { return(new ExpressionStatement { Expression = InvocationExpression(name, parameters) }); }
private static bool ShouldInclude(IMethodName name) { if (name.IsUnknown) { return(false); } return(!name.DeclaringType.Assembly.IsLocalProject); }
public static Event NewInvocation(IMethodName name) { return(new Event { Kind = EventKind.Invocation, Method = name.RemoveGenerics() }); }
public static Event NewMethodEvent(IMethodName name) { return(new Event { Kind = EventKind.MethodDeclaration, Method = name.RemoveGenerics() }); }
public static InvocationExpression InvokeStatic(IMethodName methodName, params ISimpleExpression[] parameters) { Assert.True(methodName.IsStatic); return(new InvocationExpression { MethodName = methodName, Parameters = Lists.NewList(parameters) }); }
protected void AssertQueries(ITypeName enclosingClass, IMethodName enclosingMethod, params Query[] expecteds) { foreach (var expected in expecteds) { expected.classCtx = enclosingClass.ToCoReName(); expected.methodCtx = enclosingMethod.ToCoReName(); } AssertQueriesWithoutSettingContexts(expecteds); }
protected InvocationExpression InvokeCtor(IMethodName methodName, params ISimpleExpression[] parameters) { Assert.That(methodName.IsConstructor); return(new InvocationExpression { MethodName = methodName, Parameters = Lists.NewList(parameters) }); }
public void Setup() { _nA = MockName(); _nB = MockName(); _dA = MockDeclaration(); _dB = MockDeclaration(); _mA = MockMethod(); _mB = MockMethod(); }
private void AddMethodIf(IList <Event> events) { if (_currentName != null) { //events.Add(Events.NewStopEvent()); events.Add(Events.NewMethodEvent(_currentName)); _currentName = null; } }
protected static IStatement InvokeStaticStmt(IMethodName methodName, params ISimpleExpression[] parameters) { Asserts.That(methodName.IsStatic); return(ExprStmt( new InvocationExpression { MethodName = methodName, Parameters = Lists.NewList(parameters) })); }
public static DefinitionSite CreateDefinitionByReturn(IMethodName methodName) { var definitionSite = new DefinitionSite { kind = DefinitionSiteKind.RETURN, method = methodName.ToCoReName() }; return(definitionSite); }
private static IMemberHierarchy <IMethodName> FindEnclosingMethodHierarchy(Context context) { IMethodName enclosingMethod = null; //context.EnclosingMethod; var enclosingMethodHierarchies = context.TypeShape.MethodHierarchies.Where(hierarchy => hierarchy.Element.Equals(enclosingMethod)) .ToList(); Assert.AreEqual(1, enclosingMethodHierarchies.Count()); return(enclosingMethodHierarchies.First()); }
public static IInvocationExpression InvocationExpression(IMethodName name, IEnumerable <ISimpleExpression> parameters) { Asserts.That(name.IsStatic || name.IsConstructor); return(new InvocationExpression { MethodName = name, Parameters = Lists.NewListFrom(parameters) }); }
public static MethodRef CreateConstructorReference(IMethodName methodName, IConstructor ctor, IConstructorDeclaration ctorDecl) { return(new MethodRef { Name = methodName, Constructor = ctor, ConstructorDeclaration = ctorDecl, IsAssemblyReference = false }); }
public static MethodRef CreateAssemblyReference(IMethodName methodName, IMethod method) { return(new MethodRef { Name = methodName, Declaration = null, Method = method, IsAssemblyReference = true }); }
protected static IStatement InvokeStmt(string id, IMethodName methodName, params ISimpleExpression[] parameters) { Asserts.That(!methodName.IsStatic); return(ExprStmt( new InvocationExpression { Reference = VarRef(id), MethodName = methodName, Parameters = Lists.NewList(parameters) })); }
public static DefinitionSite CreateDefinitionByParam(IMethodName methodName, int argIndex) { var definitionSite = new DefinitionSite { kind = DefinitionSiteKind.PARAM, method = methodName.ToCoReName(), argIndex = argIndex }; return(definitionSite); }
private void GenerateMethodTest(int counter, int counter2, IMethodName sut) { OpenTestAndDeclareSut(counter, counter2, sut); _sb.AppendAreEqual(sut.ReturnType, "sut.getReturnType()"); _sb.AppendAreEqual(sut.IsConstructor, "sut.isConstructor()"); _sb.AppendAreEqual(sut.IsInit, "sut.isInit()"); _sb.AppendAreEqual(sut.IsExtensionMethod, "sut.isExtensionMethod()"); _sb.AppendParameterizedNameAssert(sut); _sb.CloseTest(); }
public static MethodRef CreateLocalReference(IMethodName methodName, IMethod method, IMethodDeclaration methodDecl) { return(new MethodRef { Name = methodName, Declaration = methodDecl, Method = method, IsAssemblyReference = false }); }
public static InvocationExpression Invoke(string id, IMethodName methodName, params ISimpleExpression[] parameters) { Assert.False(methodName.IsStatic); return(new InvocationExpression { Reference = VarRef(id), MethodName = methodName, Parameters = Lists.NewList(parameters) }); }
private static IStatement InvokeStmt(string id, IMethodName method) { return(new ExpressionStatement { Expression = new InvocationExpression { Reference = new VariableReference { Identifier = id }, MethodName = method } }); }
private static Query CreateQuery(ITypeName classCtx, IMethodName methodCtx) { return(new Query { type = Fix.Int.ToCoReName(), classCtx = classCtx.ToCoReName(), methodCtx = methodCtx.ToCoReName(), definition = DefinitionSites.CreateDefinitionByConstant(), sites = { CallSites.CreateReceiverCallSite(Fix.Int_GetHashCode) } }); }
public static IInvocationExpression InvocationExpression(string id, IMethodName name, IEnumerable <ISimpleExpression> parameters) { Asserts.Not(name.IsStatic || name.IsConstructor); return(new InvocationExpression { Reference = new VariableReference { Identifier = id }, MethodName = name, Parameters = Lists.NewListFrom(parameters) }); }