astbuilder: Add a `create_callsite` method
authorFlorian Deljarry <deljarry.florian@gmail.com>
Tue, 13 Aug 2019 16:13:30 +0000 (12:13 -0400)
committerFlorian Deljarry <deljarry.florian@gmail.com>
Tue, 13 Aug 2019 16:13:30 +0000 (12:13 -0400)
Add a `create_callsite` method to facilitate the construction of callsite.

Signed-off-by: Florian Deljarry <deljarry.florian@gmail.com>

src/astbuilder.nit

index 36f157f..d81ac6b 100644 (file)
@@ -157,6 +157,14 @@ class ASTBuilder
        do
                return new AReturnExpr.make(expr)
        end
+       # Create a callsite with the given `mproperty`. Take the current method `actual_method` as a context
+       fun create_callsite(modelbuilder: ModelBuilder, actual_method : AMethPropdef, mproperty: MMethod, is_self_call: Bool): CallSite
+       do
+               var type_visitor = new TypeVisitor(modelbuilder, actual_method.mpropdef.as(not null))
+               var callsite = type_visitor.build_callsite_by_property(actual_method, mproperty.intro_mclassdef.bound_mtype, mproperty, is_self_call)
+               assert callsite != null
+               return callsite
+       end
 end
 
 redef class AExpr