func (linker *_Linker) linkTypes(script *ast.Script) { linker.D("create using symbol table for script : %s", script) linker.importTypes = make(map[string]ast.Type) script.UsingForeach(func(using *ast.Using) { name := path.Base(strings.Replace(using.Name(), ".", "/", -1)) linker.D("link using(%s) : %s", using, name) if gslangType, ok := linker.types[using.Name()]; ok { linker.importTypes[name] = gslangType using.Ref = gslangType linker.D("link using(%s:%p) : %s -- success", using, using, name) return } linker.errorf(ErrTypeNotFound, using, "using statment reference unknown type(%s)", using.Name()) }) linker.D("create using symbol table for script : %s -- success", script) script.TypeForeach(func(gslangType ast.Type) { linker.linkType(script, gslangType) }) }
func (linker *_Linker) createSymbolTable(script *ast.Script) { linker.D("create global symoble table , search script defined types: %s", script) script.TypeForeach(func(gslangType ast.Type) { fullname := _fullName(script.Package, gslangType) if previous, ok := linker.types[fullname]; ok { linker.duplicateTypeDef(gslangType, previous) return } linker.types[fullname] = gslangType }) linker.D("create global symoble table , search script defined types: %s -- success", script) }