Exemplo n.º 1
0
func (pp *packageParser) tParseIdent(t *ast.Ident) (result st.ITypeSymbol) {

	if sym, found := pp.CurrentSymbolTable.LookUp(t.Name, pp.CurrentFileName); found {
		result = sym.(st.ITypeSymbol)
	} else {
		result = st.MakeUnresolvedType(t.Name, pp.CurrentSymbolTable, t)
		// 		fmt.Printf("%p it's Uunres Ident %s %p %s\n", t, result.Name(), result, pp.CurrentFileName)
		if pp.Mode != TYPES_MODE {
			fmt.Printf("**************** %s\n", t.Name)
		}
	}
	pp.registerIdent(result, t)
	return
}
Exemplo n.º 2
0
// using type from imported package
func (pp *packageParser) tParseSelector(t *ast.SelectorExpr) (result st.ITypeSymbol) {
	if pp.Mode == TYPES_MODE {
		if sym, found := pp.CurrentSymbolTable.LookUp(t.X.(*ast.Ident).Name, pp.CurrentFileName); found {
			pack := sym.(*st.PackageSymbol)
			pp.registerIdent(pack, t.X.(*ast.Ident))

			name := t.Sel.Name
			var res st.Symbol
			if res, found = pack.Package.Symbols.LookUp(name, ""); !found {
				res = st.MakeUnresolvedType(name, pack.Package.Symbols, t)
				// 				fmt.Printf("%p it's Uunres %s %p %s\n", t.Sel, res.Name(), res, pp.CurrentFileName)
				pack.Package.Symbols.AddSymbol(res)
			}

			pp.registerIdent(res, t.Sel)

			result = res.(st.ITypeSymbol)
		} else {
			panic("Can't find package " + pp.Package.QualifiedPath + " " + pp.CurrentFileName + " " + t.X.(*ast.Ident).Name + "." + t.Sel.Name + "\n")
		}

	} else {
		pref := pp.parseTypeSymbol(t.X)

		switch p := pref.(type) {
		case *st.PackageSymbol:
			if sym, found := p.Package.Symbols.LookUp(t.Sel.Name, ""); found {

				result = sym.(st.ITypeSymbol)
				pp.registerIdent(sym, t.Sel)
			} else {
				panic("Can't find symbol " + t.Sel.Name + " in package " + pp.Package.QualifiedPath + " " + pp.CurrentFileName + "\n")
			}
		case *st.UnresolvedTypeSymbol:
			panic("Can't find package " + pp.Package.QualifiedPath + " " + pp.CurrentFileName + " " + pref.Name() + "." + t.Sel.Name + "\n")
		}
	}
	return
}