public JsExpression CreateObject(JsExpression containingType, IMethodSymbol constructor, params JsExpression[] arguments) { var constructorReference = containingType.Member("prototype").Member(constructor.GetMemberName()); if (constructor.IsBuiltIn()) { // If the constructor is built-in, then we don't want it invoked at all, since it's just a shim for the built-in // version. Therefore, just call the types constructor passing in the arguments as usual for a normal JS new. return Js.New(containingType, arguments); } else { // Object creation gets transformed into: // new T(T.prototype.ctor, arg1, arg2, arg3...) return constructorReference.Member(SpecialNames.New).Invoke(arguments); } }