protected override ICode VisitJsDelegateCtor(ExprJsDelegateCtor e) { var methodName = this.resolver.MethodNames[e.Method]; if (e.Obj == null) { this.js.Append(methodName); } else { // TODO improve naming - can share names with enclosing function var nameGen = new NameGenerator(); var argList = string.Join(", ", e.Method.Parameters.Select(x => "_" + nameGen.GetNewName())); this.js.Append("(function("); this.js.Append(argList); this.js.Append(") { "); if (!e.Type.IsVoid()) { this.js.Append("return "); } this.js.Append(methodName); this.js.Append("("); this.Visit(e.Obj); if (argList.Any()) { this.js.Append(", "); this.js.Append(argList); } this.js.Append("); })"); } return(e); }
protected virtual ICode VisitJsDelegateCtor(ExprJsDelegateCtor e) { this.ThrowOnNoOverride(); var obj = (Expr)this.Visit(e.Obj); if (obj != e.Obj) { return(new ExprJsDelegateCtor(e.Ctx, e.Type, obj, e.Method)); } else { return(e); } }
protected virtual ICode VisitJsDelegateCtor(ExprJsDelegateCtor e) { this.ThrowOnNoOverride(); var obj = (Expr)this.Visit(e.Obj); if (obj != e.Obj) { return new ExprJsDelegateCtor(e.Ctx, e.Type, obj, e.Method); } else { return e; } }
protected override ICode VisitJsDelegateCtor(ExprJsDelegateCtor e) { this.calls.Add(new ExprMethodReference(e.Ctx, e.Method)); return(base.VisitJsDelegateCtor(e)); }
protected override ICode VisitJsDelegateCtor(ExprJsDelegateCtor e) { var methodName = this.resolver.MethodNames[e.Method]; if (e.Obj == null) { this.js.Append(methodName); } else { // TODO improve naming - can share names with enclosing function var nameGen = new NameGenerator(); var argList = string.Join(", ", e.Method.Parameters.Select(x => "_" + nameGen.GetNewName())); this.js.Append("(function("); this.js.Append(argList); this.js.Append(") { "); if (!e.Type.IsVoid()) { this.js.Append("return "); } this.js.Append(methodName); this.js.Append("("); this.Visit(e.Obj); if (argList.Any()) { this.js.Append(", "); this.js.Append(argList); } this.js.Append("); })"); } return e; }
protected override ICode VisitJsDelegateCtor(ExprJsDelegateCtor e) { this.code.Append(e.Method.Name); return e; }