func analyzeTry(gs *GoState, owner GoMethodOwner, try *grammar.JTry) *GoTry { gt := &GoTry{block: analyzeBlock(NewGoState(gs), owner, try.Block)} if try.Catches != nil && len(try.Catches) > 0 { gs2 := NewGoState(gs) gt.catches = make([]*GoTryCatch, len(try.Catches)) for i, c := range try.Catches { var exc *grammar.JTypeName if len(c.TypeList) == 1 { exc = c.TypeList[0] } else { exc = grammar.NewJTypeName("Exception", false) } govar := gs.addVariable(c.Name, c.Modifiers, 0, grammar.NewJReferenceType(exc, nil, 0), false) if len(c.TypeList) != 1 { log.Printf("//ERR// Ignoring catch#%d long typelist (len=%d)\n", i, len(c.TypeList)) } gt.catches[i] = &GoTryCatch{govar: govar, block: analyzeBlock(gs2, owner, c.Block)} } } if try.Finally != nil { gt.finally = analyzeBlock(NewGoState(gs), owner, try.Finally) } return gt }
func analyzeObjectDotName(gs *GoState, owner GoMethodOwner, odn *grammar.JObjectDotName) GoVar { switch o := odn.Obj.(type) { case *grammar.JKeyword: if o.Token == grammar.THIS && gs.Receiver() != "" { rvar := gs.findVariable(grammar.NewJTypeName(gs.Receiver(), false)) if rvar == nil { rvar = gs.addVariable(gs.Receiver(), nil, 0, nil, false) } ref := gs.findVariable(odn.Name) if ref == nil { ref = gs.addVariable(gs.Receiver(), nil, 0, nil, false) } return NewGoSelector(rvar, ref) } else if o.Token == grammar.SUPER && gs.Receiver() != "" { log.Printf("//ERR// Not converting odnobj super\n") return NewFakeVar("<<super>>", nil, 0) } else { log.Printf("//ERR// Not converting odnobj %T (kwd %s)\n", odn.Obj, o.Name) return NewFakeVar(fmt.Sprintf("<<%v>>", o.Name), nil, 0) } default: return NewObjectDotName(odn, analyzeExpr(gs, owner, odn.Obj), gs) } }