to MakeClosure

This commit is contained in:
xushiwei
2024-05-04 19:44:52 +08:00
parent 889fc8b6a9
commit 52018cd424
2 changed files with 25 additions and 1 deletions

View File

@@ -523,6 +523,12 @@ func (p *context) compileInstrOrValue(b llssa.Builder, iv instrOrValue, asValue
nReserve = p.compileValue(b, v.Reserve) nReserve = p.compileValue(b, v.Reserve)
} }
ret = b.MakeMap(p.prog.Type(t), nReserve) ret = b.MakeMap(p.prog.Type(t), nReserve)
/*
case *ssa.MakeClosure:
fn := p.compileValue(b, v.Fn)
bindings := p.compileValues(b, v.Bindings, 0)
ret = b.MakeClosure(fn, bindings)
*/
case *ssa.TypeAssert: case *ssa.TypeAssert:
x := p.compileValue(b, v.X) x := p.compileValue(b, v.X)
ret = b.TypeAssert(x, p.prog.Type(v.AssertedType), v.CommaOk) ret = b.TypeAssert(x, p.prog.Type(v.AssertedType), v.CommaOk)

View File

@@ -484,7 +484,7 @@ func (b Builder) Store(ptr, val Expr) Builder {
// aggregateValue yields the value of the aggregate X with the fields // aggregateValue yields the value of the aggregate X with the fields
func (b Builder) aggregateValue(t Type, flds ...llvm.Value) Expr { func (b Builder) aggregateValue(t Type, flds ...llvm.Value) Expr {
if debugInstr { if debugInstr {
log.Printf("AggregateValue %v, %v\n", t, flds) log.Printf("AggregateValue %v, %v\n", t.t, flds)
} }
impl := b.impl impl := b.impl
tll := t.ll tll := t.ll
@@ -495,6 +495,24 @@ func (b Builder) aggregateValue(t Type, flds ...llvm.Value) Expr {
return Expr{llvm.CreateLoad(b.impl, tll, ptr), t} return Expr{llvm.CreateLoad(b.impl, tll, ptr), t}
} }
/*
// The MakeClosure instruction yields a closure value whose code is
// Fn and whose free variables' values are supplied by Bindings.
//
// Type() returns a (possibly named) *types.Signature.
//
// Example printed form:
//
// t0 = make closure anon@1.2 [x y z]
// t1 = make closure bound$(main.I).add [i]
func (b Builder) MakeClosure(fn Expr, bindings []Expr) Expr {
if debugInstr {
log.Printf("MakeClosure %v, %v\n", fn, bindings)
}
panic("todo")
}
*/
// The FieldAddr instruction yields the address of Field of *struct X. // The FieldAddr instruction yields the address of Field of *struct X.
// //
// The field is identified by its index within the field list of the // The field is identified by its index within the field list of the