public override void OnMethodInvocationExpression(MethodInvocationExpression node)
{
IEntity entity = TypeSystemServices.GetEntity(node.Target);
switch (entity.EntityType)
{
case EntityType.BuiltinFunction:
{
OnBuiltinFunction((BuiltinFunction)entity, node);
break;
}
case EntityType.Method:
{
var methodInfo = (IMethod)entity;
if (node.Target.NodeType == NodeType.SuperLiteralExpression)
InvokeSuperMethod(methodInfo, node);
else
InvokeMethod(methodInfo, node);
break;
}
case EntityType.Constructor:
{
IConstructor constructorInfo = (IConstructor)entity;
ConstructorInfo ci = GetConstructorInfo(constructorInfo);
if (NodeType.SuperLiteralExpression == node.Target.NodeType || node.Target.NodeType == NodeType.SelfLiteralExpression)
{
// super constructor call
_il.Emit(OpCodes.Ldarg_0);
PushArguments(constructorInfo, node.Arguments);
_il.Emit(OpCodes.Call, ci);
PushVoid();
}
else
{
PushArguments(constructorInfo, node.Arguments);
_il.Emit(OpCodes.Newobj, ci);
// constructor invocation resulting type is
PushType(constructorInfo.DeclaringType);
}
break;
}
default:
{
NotImplemented(node, entity.ToString());
break;
}
}
}