(ctx *parser.ArrayInitializerContext)
| 353 | } |
| 354 | |
| 355 | func (v *Visitor) VisitArrayInitializer(ctx *parser.ArrayInitializerContext) interface{} { |
| 356 | lenAndCap := make([]int, 2) |
| 357 | var ( |
| 358 | len, cap int |
| 359 | ) |
| 360 | |
| 361 | if ctx.LBRACK() != nil && ctx.RBRACK() != nil { |
| 362 | length := v.Visit(ctx.Expr(0)) |
| 363 | switch length.(type) { |
| 364 | case int: |
| 365 | //return length.(int) |
| 366 | len = length.(int) |
| 367 | case *LeftValue: |
| 368 | value := length.(*LeftValue).GetValue() |
| 369 | switch value.(type) { |
| 370 | case int: |
| 371 | //return value.(int) |
| 372 | len = value.(int) |
| 373 | default: |
| 374 | log.RuntimePanic(ctx, fmt.Sprintf("non-int len argument in Initialization function")) |
| 375 | } |
| 376 | default: |
| 377 | log.RuntimePanic(ctx, fmt.Sprintf("non-int len argument in Initialization function")) |
| 378 | } |
| 379 | |
| 380 | if ctx.Expr(1) != nil { |
| 381 | capacity := v.Visit(ctx.Expr(0)) |
| 382 | switch capacity.(type) { |
| 383 | case int: |
| 384 | //return length.(int) |
| 385 | cap = capacity.(int) |
| 386 | case *LeftValue: |
| 387 | value := capacity.(*LeftValue).GetValue() |
| 388 | switch value.(type) { |
| 389 | case int: |
| 390 | //return value.(int) |
| 391 | cap = value.(int) |
| 392 | default: |
| 393 | log.RuntimePanic(ctx, fmt.Sprintf("non-int cap argument in Initialization function")) |
| 394 | } |
| 395 | default: |
| 396 | log.RuntimePanic(ctx, fmt.Sprintf("non-int cap argument in Initialization function")) |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | lenAndCap[0] = len |
| 401 | lenAndCap[1] = cap |
| 402 | return lenAndCap |
| 403 | } |
| 404 | |
| 405 | func (v *Visitor) VisitBlockStm(ctx *parser.BlockStmContext) interface{} { |
| 406 | return v.Visit(ctx.Statement()) |
no test coverage detected