NewBindMacro creates an AST expression representing the expanded bind() macro, and a macro expression representing the unexpanded call signature to be inserted into the source info macro call metadata.
(macroID int64, varName string, varInit, remaining ast.Expr)
| 320 | // NewBindMacro creates an AST expression representing the expanded bind() macro, and a macro expression |
| 321 | // representing the unexpanded call signature to be inserted into the source info macro call metadata. |
| 322 | func (opt *optimizerExprFactory) NewBindMacro(macroID int64, varName string, varInit, remaining ast.Expr) (astExpr, macroExpr ast.Expr) { |
| 323 | varID := opt.nextID() |
| 324 | remainingID := opt.nextID() |
| 325 | remaining = opt.fac.CopyExpr(remaining) |
| 326 | remaining.RenumberIDs(func(id int64) int64 { |
| 327 | if id == macroID { |
| 328 | return remainingID |
| 329 | } |
| 330 | return id |
| 331 | }) |
| 332 | if call, exists := opt.sourceInfo.GetMacroCall(macroID); exists { |
| 333 | opt.SetMacroCall(remainingID, opt.fac.CopyExpr(call)) |
| 334 | } |
| 335 | |
| 336 | astExpr = opt.fac.NewComprehension(macroID, |
| 337 | opt.fac.NewList(opt.nextID(), []ast.Expr{}, []int32{}), |
| 338 | "#unused", |
| 339 | varName, |
| 340 | opt.fac.CopyExpr(varInit), |
| 341 | opt.fac.NewLiteral(opt.nextID(), types.False), |
| 342 | opt.fac.NewIdent(varID, varName), |
| 343 | remaining) |
| 344 | |
| 345 | macroExpr = opt.fac.NewMemberCall(0, "bind", |
| 346 | opt.fac.NewIdent(opt.nextID(), "cel"), |
| 347 | opt.fac.NewIdent(varID, varName), |
| 348 | opt.fac.CopyExpr(varInit), |
| 349 | opt.fac.CopyExpr(remaining)) |
| 350 | opt.sanitizeMacro(macroID, macroExpr) |
| 351 | return |
| 352 | } |
| 353 | |
| 354 | // NewCall creates a global function call invocation expression. |
| 355 | // |
no test coverage detected