llgo/ssa: float Const fix; cl: replaceGoName runtime => llgo/internal/runtime

This commit is contained in:
xushiwei
2024-06-13 00:56:18 +08:00
parent 7dd740f51a
commit 18eecbe9f4
3 changed files with 1423 additions and 5 deletions

View File

@@ -359,8 +359,11 @@ const (
func (p *context) varName(pkg *types.Package, v *ssa.Global) (vName string, vtype int) {
name := llssa.FullName(pkg, v.Name())
if v, ok := p.link[name]; ok {
if strings.HasPrefix(v, "py.") {
return v[3:], pyVar
if pos := strings.IndexByte(v, '.'); pos >= 0 {
if pos == 2 && v[0] == 'p' && v[1] == 'y' {
return v[3:], pyVar
}
return replaceGoName(v, pos), goVar
}
return v, cVar
}
@@ -405,6 +408,14 @@ func pkgKindByPath(pkgPath string) int {
return PkgNormal
}
func replaceGoName(v string, pos int) string {
switch v[:pos] {
case "runtime":
return "github.com/goplus/llgo/internal/runtime" + v[pos:]
}
return v
}
// -----------------------------------------------------------------------------
const (