ensure anonymous ops work
This commit is contained in:
parent
f9aec75bf1
commit
867f83377f
@ -35,9 +35,14 @@ func (bctx BuildCtx) BuildStmt(ctx Ctx, s Statement) Expr {
|
||||
case Macro:
|
||||
return ctx.Macro(o)(bctx, ctx, s.Arg)
|
||||
case Identifier:
|
||||
fn := ctx.Identifier(o).(llvmVal)
|
||||
s.Op = ctx.Identifier(o).(llvmVal)
|
||||
return bctx.BuildStmt(ctx, s)
|
||||
case Statement:
|
||||
s.Op = bctx.BuildStmt(ctx, o)
|
||||
return bctx.BuildStmt(ctx, s)
|
||||
case llvmVal:
|
||||
arg := bctx.buildExpr(ctx, s.Arg).(llvmVal)
|
||||
out := bctx.B.CreateCall(llvm.Value(fn), []llvm.Value{llvm.Value(arg)}, "")
|
||||
out := bctx.B.CreateCall(llvm.Value(o), []llvm.Value{llvm.Value(arg)}, "")
|
||||
return llvmVal(out)
|
||||
default:
|
||||
panic(fmt.Sprintf("non op type %v (%T)", s.Op, s.Op))
|
||||
|
24
main.go
24
main.go
@ -32,22 +32,20 @@ func main() {
|
||||
|
||||
log.Printf("making program")
|
||||
add := expr.Macro("add")
|
||||
bind := expr.Macro("bind")
|
||||
//bind := expr.Macro("bind")
|
||||
op := expr.Macro("op")
|
||||
in := expr.Macro("in")
|
||||
incr := expr.Identifier("incr")
|
||||
stmts := []expr.Statement{
|
||||
expr.NewStatement(bind, incr,
|
||||
expr.NewStatement(op,
|
||||
expr.NewList(
|
||||
expr.NewStatement(add, expr.NewTuple(
|
||||
expr.Int(1),
|
||||
expr.NewStatement(in, expr.NewTuple()),
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
incr := expr.NewStatement(op,
|
||||
expr.NewList(
|
||||
expr.NewStatement(add, expr.NewTuple(
|
||||
expr.Int(1),
|
||||
expr.NewStatement(in, expr.NewTuple()),
|
||||
)),
|
||||
),
|
||||
)
|
||||
|
||||
stmts := []expr.Statement{
|
||||
expr.NewStatement(
|
||||
incr,
|
||||
expr.Int(5),
|
||||
|
Loading…
Reference in New Issue
Block a user