llgo/ssa: float Const fix; cl: replaceGoName runtime => llgo/internal/runtime
This commit is contained in:
15
cl/import.go
15
cl/import.go
@@ -359,8 +359,11 @@ const (
|
|||||||
func (p *context) varName(pkg *types.Package, v *ssa.Global) (vName string, vtype int) {
|
func (p *context) varName(pkg *types.Package, v *ssa.Global) (vName string, vtype int) {
|
||||||
name := llssa.FullName(pkg, v.Name())
|
name := llssa.FullName(pkg, v.Name())
|
||||||
if v, ok := p.link[name]; ok {
|
if v, ok := p.link[name]; ok {
|
||||||
if strings.HasPrefix(v, "py.") {
|
if pos := strings.IndexByte(v, '.'); pos >= 0 {
|
||||||
return v[3:], pyVar
|
if pos == 2 && v[0] == 'p' && v[1] == 'y' {
|
||||||
|
return v[3:], pyVar
|
||||||
|
}
|
||||||
|
return replaceGoName(v, pos), goVar
|
||||||
}
|
}
|
||||||
return v, cVar
|
return v, cVar
|
||||||
}
|
}
|
||||||
@@ -405,6 +408,14 @@ func pkgKindByPath(pkgPath string) int {
|
|||||||
return PkgNormal
|
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 (
|
const (
|
||||||
|
|||||||
1408
internal/runtime/panic.go
Normal file
1408
internal/runtime/panic.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -194,9 +194,8 @@ func (b Builder) Const(v constant.Value, typ Type) Expr {
|
|||||||
return prog.IntVal(v, typ)
|
return prog.IntVal(v, typ)
|
||||||
}
|
}
|
||||||
case kind == types.Float32 || kind == types.Float64:
|
case kind == types.Float32 || kind == types.Float64:
|
||||||
if v, exact := constant.Float64Val(v); exact {
|
v, _ := constant.Float64Val(v)
|
||||||
return prog.FloatVal(v, typ)
|
return prog.FloatVal(v, typ)
|
||||||
}
|
|
||||||
case kind == types.String:
|
case kind == types.String:
|
||||||
return Expr{b.Str(constant.StringVal(v)).impl, typ}
|
return Expr{b.Str(constant.StringVal(v)).impl, typ}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user