Index: mark unreachable

This commit is contained in:
xushiwei
2024-05-25 08:40:04 +08:00
parent 5eac8d860a
commit c7abc03fee
4 changed files with 71 additions and 54 deletions

View File

@@ -183,9 +183,12 @@ func (b Builder) Index(x, idx Expr, addr func(Expr) Expr) Expr {
if addr != nil {
ptr = addr(x)
} else {
size := SizeOf(prog, telem, t.Len())
ptr = b.Alloca(size)
b.Store(ptr, x)
/*
size := SizeOf(prog, telem, t.Len())
ptr = b.Alloca(size)
b.Store(ptr, x)
*/
panic("unreachable")
}
}
idx = b.checkIndex(idx)

View File

@@ -85,6 +85,7 @@ func (p Package) NewVar(name string, typ types.Type, bg Background) Global {
return p.doNewVar(name, t)
}
/*
// NewVarFrom creates a new global variable.
func (p Package) NewVarFrom(name string, t Type) Global {
if v, ok := p.vars[name]; ok {
@@ -92,6 +93,7 @@ func (p Package) NewVarFrom(name string, t Type) Global {
}
return p.doNewVar(name, t)
}
*/
func (p Package) doNewVar(name string, t Type) Global {
var gbl llvm.Value