コード例 #1
0
 protected static IExpressionStatement InvokeStmt(string varName, IMethodName method)
 {
     return(new ExpressionStatement
     {
         Expression = Invoke(varName, method)
     });
 }
コード例 #2
0
 private static IInvocationExpression InvokeStatic(IMethodName method)
 {
     return(new InvocationExpression
     {
         MethodName = method
     });
 }
コード例 #3
0
        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);
                }
            }
        }
コード例 #4
0
        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)
                    }
                }
            };
        }
コード例 #5
0
        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()));
        }
コード例 #6
0
 protected static IInvocationExpression Invoke(string varName, IMethodName method)
 {
     return(new InvocationExpression
     {
         Reference = VarRef(varName),
         MethodName = method
     });
 }
コード例 #7
0
        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));
        }
コード例 #8
0
 public static IExpressionStatement InvocationStatement(IMethodName name,
                                                        IEnumerable <ISimpleExpression> parameters)
 {
     return(new ExpressionStatement
     {
         Expression = InvocationExpression(name, parameters)
     });
 }
コード例 #9
0
 private static bool ShouldInclude(IMethodName name)
 {
     if (name.IsUnknown)
     {
         return(false);
     }
     return(!name.DeclaringType.Assembly.IsLocalProject);
 }
コード例 #10
0
 public static Event NewInvocation(IMethodName name)
 {
     return(new Event
     {
         Kind = EventKind.Invocation,
         Method = name.RemoveGenerics()
     });
 }
コード例 #11
0
 public static Event NewMethodEvent(IMethodName name)
 {
     return(new Event
     {
         Kind = EventKind.MethodDeclaration,
         Method = name.RemoveGenerics()
     });
 }
コード例 #12
0
 public static InvocationExpression InvokeStatic(IMethodName methodName, params ISimpleExpression[] parameters)
 {
     Assert.True(methodName.IsStatic);
     return(new InvocationExpression
     {
         MethodName = methodName,
         Parameters = Lists.NewList(parameters)
     });
 }
コード例 #13
0
 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);
 }
コード例 #14
0
 protected InvocationExpression InvokeCtor(IMethodName methodName, params ISimpleExpression[] parameters)
 {
     Assert.That(methodName.IsConstructor);
     return(new InvocationExpression
     {
         MethodName = methodName,
         Parameters = Lists.NewList(parameters)
     });
 }
コード例 #15
0
 public void Setup()
 {
     _nA = MockName();
     _nB = MockName();
     _dA = MockDeclaration();
     _dB = MockDeclaration();
     _mA = MockMethod();
     _mB = MockMethod();
 }
コード例 #16
0
 private void AddMethodIf(IList <Event> events)
 {
     if (_currentName != null)
     {
         //events.Add(Events.NewStopEvent());
         events.Add(Events.NewMethodEvent(_currentName));
         _currentName = null;
     }
 }
コード例 #17
0
 protected static IStatement InvokeStaticStmt(IMethodName methodName, params ISimpleExpression[] parameters)
 {
     Asserts.That(methodName.IsStatic);
     return(ExprStmt(
                new InvocationExpression
     {
         MethodName = methodName,
         Parameters = Lists.NewList(parameters)
     }));
 }
コード例 #18
0
        public static DefinitionSite CreateDefinitionByReturn(IMethodName methodName)
        {
            var definitionSite = new DefinitionSite
            {
                kind   = DefinitionSiteKind.RETURN,
                method = methodName.ToCoReName()
            };

            return(definitionSite);
        }
コード例 #19
0
        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());
        }
コード例 #20
0
 public static IInvocationExpression InvocationExpression(IMethodName name,
                                                          IEnumerable <ISimpleExpression> parameters)
 {
     Asserts.That(name.IsStatic || name.IsConstructor);
     return(new InvocationExpression
     {
         MethodName = name,
         Parameters = Lists.NewListFrom(parameters)
     });
 }
コード例 #21
0
ファイル: MethodRef.cs プロジェクト: feedbag-stats/feedbag
 public static MethodRef CreateConstructorReference(IMethodName methodName, IConstructor ctor, IConstructorDeclaration ctorDecl)
 {
     return(new MethodRef
     {
         Name = methodName,
         Constructor = ctor,
         ConstructorDeclaration = ctorDecl,
         IsAssemblyReference = false
     });
 }
コード例 #22
0
ファイル: MethodRef.cs プロジェクト: feedbag-stats/feedbag
 public static MethodRef CreateAssemblyReference(IMethodName methodName, IMethod method)
 {
     return(new MethodRef
     {
         Name = methodName,
         Declaration = null,
         Method = method,
         IsAssemblyReference = true
     });
 }
コード例 #23
0
 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)
     }));
 }
コード例 #24
0
        public static DefinitionSite CreateDefinitionByParam(IMethodName methodName, int argIndex)
        {
            var definitionSite = new DefinitionSite
            {
                kind     = DefinitionSiteKind.PARAM,
                method   = methodName.ToCoReName(),
                argIndex = argIndex
            };

            return(definitionSite);
        }
コード例 #25
0
        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();
        }
コード例 #26
0
ファイル: MethodRef.cs プロジェクト: feedbag-stats/feedbag
 public static MethodRef CreateLocalReference(IMethodName methodName,
                                              IMethod method,
                                              IMethodDeclaration methodDecl)
 {
     return(new MethodRef
     {
         Name = methodName,
         Declaration = methodDecl,
         Method = method,
         IsAssemblyReference = false
     });
 }
コード例 #27
0
 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)
     });
 }
コード例 #28
0
 private static IStatement InvokeStmt(string id, IMethodName method)
 {
     return(new ExpressionStatement
     {
         Expression = new InvocationExpression
         {
             Reference = new VariableReference {
                 Identifier = id
             },
             MethodName = method
         }
     });
 }
コード例 #29
0
 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)
         }
     });
 }
コード例 #30
0
 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)
     });
 }