LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2013 The Go Authors. All rights reserved. | 1 // Copyright 2013 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Package ssa/interp defines an interpreter for the SSA | 5 // Package ssa/interp defines an interpreter for the SSA |
6 // representation of Go programs. | 6 // representation of Go programs. |
7 // | 7 // |
8 // This interpreter is provided as an adjunct for testing the SSA | 8 // This interpreter is provided as an adjunct for testing the SSA |
9 // construction algorithm. Its purpose is to provide a minimal | 9 // construction algorithm. Its purpose is to provide a minimal |
10 // metacircular implementation of the dynamic semantics of each SSA | 10 // metacircular implementation of the dynamic semantics of each SSA |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 if fr.i.mode&DisableRecover != 0 { | 548 if fr.i.mode&DisableRecover != 0 { |
549 return // let interpreter crash | 549 return // let interpreter crash |
550 } | 550 } |
551 fr.panicking = true | 551 fr.panicking = true |
552 fr.panic = recover() | 552 fr.panic = recover() |
553 if fr.i.mode&EnableTracing != 0 { | 553 if fr.i.mode&EnableTracing != 0 { |
554 fmt.Fprintf(os.Stderr, "Panicking: %T %v.\n", fr.panic,
fr.panic) | 554 fmt.Fprintf(os.Stderr, "Panicking: %T %v.\n", fr.panic,
fr.panic) |
555 } | 555 } |
556 fr.runDefers() | 556 fr.runDefers() |
557 fr.block = fr.fn.Recover | 557 fr.block = fr.fn.Recover |
558 if fr.block == nil { | |
559 fr.result = zero(fr.fn.Signature.Results()) | |
560 } | |
561 }() | 558 }() |
562 | 559 |
563 for { | 560 for { |
564 if fr.i.mode&EnableTracing != 0 { | 561 if fr.i.mode&EnableTracing != 0 { |
565 fmt.Fprintf(os.Stderr, ".%s:\n", fr.block) | 562 fmt.Fprintf(os.Stderr, ".%s:\n", fr.block) |
566 } | 563 } |
567 block: | 564 block: |
568 for _, instr := range fr.block.Instrs { | 565 for _, instr := range fr.block.Instrs { |
569 if fr.i.mode&EnableTracing != 0 { | 566 if fr.i.mode&EnableTracing != 0 { |
570 if v, ok := instr.(ssa.Value); ok { | 567 if v, ok := instr.(ssa.Value); ok { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 } | 719 } |
723 | 720 |
724 // deref returns a pointer's element type; otherwise it returns typ. | 721 // deref returns a pointer's element type; otherwise it returns typ. |
725 // TODO(adonovan): Import from ssa? | 722 // TODO(adonovan): Import from ssa? |
726 func deref(typ types.Type) types.Type { | 723 func deref(typ types.Type) types.Type { |
727 if p, ok := typ.Underlying().(*types.Pointer); ok { | 724 if p, ok := typ.Underlying().(*types.Pointer); ok { |
728 return p.Elem() | 725 return p.Elem() |
729 } | 726 } |
730 return typ | 727 return typ |
731 } | 728 } |
LEFT | RIGHT |