package core import ( "git.urbach.dev/cli/q/src/asm" "git.urbach.dev/cli/q/src/ast" ) // CompileAssert compiles an assertion. func (f *Function) CompileAssert(assert *ast.Assert) error { f.count.assert++ success := f.CreateLabel("assert true", f.count.assert) fail := f.CreateLabel("assert false", f.count.assert) err := f.CompileCondition(assert.Condition, success, fail) if err != nil { return err } f.AddLabel(success) f.Defer(func() { f.AddLabel(fail) f.Jump(asm.JUMP, "_crash") }) return err }