@@ -285,7 +285,7 @@ type aliasCallback func(*parser.CallStmt, interface{}) bool
285
285
func noopAliasCallback (_ * parser.CallStmt , _ interface {}) bool { return true }
286
286
287
287
func isBreakpoint (call * parser.CallStmt ) bool {
288
- return call .Func .Ident != nil && call . Func . Ident . Name == "breakpoint"
288
+ return call .Func .Name () == "breakpoint"
289
289
}
290
290
291
291
func (cg * CodeGen ) EmitBlock (ctx context.Context , scope * parser.Scope , typ parser.ObjType , stmts []* parser.Stmt , ac aliasCallback , chainStart interface {}) (interface {}, error ) {
@@ -435,7 +435,7 @@ func (cg *CodeGen) EmitImageOptions(ctx context.Context, scope *parser.Scope, op
435
435
for _ , stmt := range stmts {
436
436
if stmt .Call != nil {
437
437
args := stmt .Call .Args
438
- switch stmt .Call .Func .Ident . Name {
438
+ switch stmt .Call .Func .Name () {
439
439
case "resolve" :
440
440
v , err := cg .MaybeEmitBoolExpr (ctx , scope , args )
441
441
if err != nil {
@@ -463,6 +463,15 @@ func (cg *CodeGen) EmitOptionLookup(ctx context.Context, scope *parser.Scope, ex
463
463
switch n := obj .Node .(type ) {
464
464
case * parser.FuncDecl :
465
465
return cg .EmitOptionFuncDecl (ctx , scope , n , args )
466
+ case * parser.ImportDecl :
467
+ importScope := obj .Data .(* parser.Scope )
468
+ importObj := importScope .Lookup (expr .Selector .Select .Name )
469
+ switch m := importObj .Node .(type ) {
470
+ case * parser.FuncDecl :
471
+ return cg .EmitOptionFuncDecl (ctx , scope , m , args )
472
+ default :
473
+ return opts , errors .WithStack (ErrCodeGen {expr , errors .Errorf ("unknown option decl kind" )})
474
+ }
466
475
default :
467
476
return opts , errors .WithStack (ErrCodeGen {expr , errors .Errorf ("unknown option decl kind" )})
468
477
}
@@ -480,7 +489,7 @@ func (cg *CodeGen) EmitHTTPOptions(ctx context.Context, scope *parser.Scope, op
480
489
for _ , stmt := range stmts {
481
490
if stmt .Call != nil {
482
491
args := stmt .Call .Args
483
- switch stmt .Call .Func .Ident . Name {
492
+ switch stmt .Call .Func .Name () {
484
493
case "checksum" :
485
494
dgst , err := cg .EmitStringExpr (ctx , scope , args [0 ])
486
495
if err != nil {
@@ -515,7 +524,7 @@ func (cg *CodeGen) EmitGitOptions(ctx context.Context, scope *parser.Scope, op s
515
524
for _ , stmt := range stmts {
516
525
if stmt .Call != nil {
517
526
args := stmt .Call .Args
518
- switch stmt .Call .Func .Ident . Name {
527
+ switch stmt .Call .Func .Name () {
519
528
case "keepGitDir" :
520
529
v , err := cg .MaybeEmitBoolExpr (ctx , scope , args )
521
530
if err != nil {
@@ -540,7 +549,7 @@ func (cg *CodeGen) EmitLocalOptions(ctx context.Context, scope *parser.Scope, op
540
549
for _ , stmt := range stmts {
541
550
if stmt .Call != nil {
542
551
args := stmt .Call .Args
543
- switch stmt .Call .Func .Ident . Name {
552
+ switch stmt .Call .Func .Name () {
544
553
case "includePatterns" :
545
554
patterns := make ([]string , len (args ))
546
555
for i , arg := range args {
@@ -598,7 +607,7 @@ func (cg *CodeGen) EmitFrontendOptions(ctx context.Context, scope *parser.Scope,
598
607
for _ , stmt := range stmts {
599
608
if stmt .Call != nil {
600
609
args := stmt .Call .Args
601
- switch stmt .Call .Func .Ident . Name {
610
+ switch stmt .Call .Func .Name () {
602
611
case "input" :
603
612
key , err := cg .EmitStringExpr (ctx , scope , args [0 ])
604
613
if err != nil {
@@ -639,7 +648,7 @@ func (cg *CodeGen) EmitMkdirOptions(ctx context.Context, scope *parser.Scope, op
639
648
for _ , stmt := range stmts {
640
649
if stmt .Call != nil {
641
650
args := stmt .Call .Args
642
- switch stmt .Call .Func .Ident . Name {
651
+ switch stmt .Call .Func .Name () {
643
652
case "createParents" :
644
653
v , err := cg .MaybeEmitBoolExpr (ctx , scope , args )
645
654
if err != nil {
@@ -680,7 +689,7 @@ func (cg *CodeGen) EmitMkfileOptions(ctx context.Context, scope *parser.Scope, o
680
689
for _ , stmt := range stmts {
681
690
if stmt .Call != nil {
682
691
args := stmt .Call .Args
683
- switch stmt .Call .Func .Ident . Name {
692
+ switch stmt .Call .Func .Name () {
684
693
case "chown" :
685
694
owner , err := cg .EmitStringExpr (ctx , scope , args [0 ])
686
695
if err != nil {
@@ -715,7 +724,7 @@ func (cg *CodeGen) EmitRmOptions(ctx context.Context, scope *parser.Scope, op st
715
724
for _ , stmt := range stmts {
716
725
if stmt .Call != nil {
717
726
args := stmt .Call .Args
718
- switch stmt .Call .Func .Ident . Name {
727
+ switch stmt .Call .Func .Name () {
719
728
case "allowNotFound" :
720
729
v , err := cg .MaybeEmitBoolExpr (ctx , scope , args )
721
730
if err != nil {
@@ -801,7 +810,7 @@ func (cg *CodeGen) EmitCopyOptions(ctx context.Context, scope *parser.Scope, op
801
810
for _ , stmt := range stmts {
802
811
if stmt .Call != nil {
803
812
args := stmt .Call .Args
804
- switch stmt .Call .Func .Ident . Name {
813
+ switch stmt .Call .Func .Name () {
805
814
case "followSymlinks" :
806
815
follow , err := cg .MaybeEmitBoolExpr (ctx , scope , args )
807
816
if err != nil {
@@ -882,7 +891,7 @@ func (cg *CodeGen) EmitTemplateOptions(ctx context.Context, scope *parser.Scope,
882
891
for _ , stmt := range stmts {
883
892
if stmt .Call != nil {
884
893
args := stmt .Call .Args
885
- switch stmt .Call .Func .Ident . Name {
894
+ switch stmt .Call .Func .Name () {
886
895
case "stringField" :
887
896
name , err := cg .EmitStringExpr (ctx , scope , args [0 ])
888
897
if err != nil {
@@ -1307,7 +1316,7 @@ func (cg *CodeGen) EmitSSHOptions(ctx context.Context, scope *parser.Scope, op s
1307
1316
for _ , stmt := range stmts {
1308
1317
if stmt .Call != nil {
1309
1318
args := stmt .Call .Args
1310
- switch stmt .Call .Func .Ident . Name {
1319
+ switch stmt .Call .Func .Name () {
1311
1320
case "target" :
1312
1321
target , err := cg .EmitStringExpr (ctx , scope , args [0 ])
1313
1322
if err != nil {
@@ -1399,7 +1408,7 @@ func (cg *CodeGen) EmitSecretOptions(ctx context.Context, scope *parser.Scope, o
1399
1408
for _ , stmt := range stmts {
1400
1409
if stmt .Call != nil {
1401
1410
args := stmt .Call .Args
1402
- switch stmt .Call .Func .Ident . Name {
1411
+ switch stmt .Call .Func .Name () {
1403
1412
case "id" :
1404
1413
id , err := cg .EmitStringExpr (ctx , scope , args [0 ])
1405
1414
if err != nil {
@@ -1476,7 +1485,7 @@ func (cg *CodeGen) EmitMountOptions(ctx context.Context, scope *parser.Scope, op
1476
1485
for _ , stmt := range stmts {
1477
1486
if stmt .Call != nil {
1478
1487
args := stmt .Call .Args
1479
- switch stmt .Call .Func .Ident . Name {
1488
+ switch stmt .Call .Func .Name () {
1480
1489
case "readonly" :
1481
1490
v , err := cg .MaybeEmitBoolExpr (ctx , scope , args )
1482
1491
if err != nil {
0 commit comments