Skip to content

Commit ddb1272

Browse files
authored
Rename emit to watch (#2614)
1 parent 7037524 commit ddb1272

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2011
-1966
lines changed

engine/baml-compiler/src/hir.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use baml_types::ir_type::TypeIR;
66
use internal_baml_diagnostics::Span;
77

8-
use crate::emit::EmitSpec;
8+
use crate::watch::WatchSpec;
99

1010
pub mod dump;
1111
pub mod lowering;
@@ -118,7 +118,7 @@ pub enum Statement {
118118
name: String,
119119
value: Expression,
120120
annotated_type: Option<TypeIR>,
121-
emit: Option<EmitSpec>,
121+
watch: Option<WatchSpec>,
122122
span: Span,
123123
},
124124
/// Declare a (mutable) reference.
@@ -145,7 +145,7 @@ pub enum Statement {
145145
name: String,
146146
value: Expression,
147147
annotated_type: Option<TypeIR>,
148-
emit: Option<EmitSpec>,
148+
watch: Option<WatchSpec>,
149149
span: Span,
150150
},
151151
/// Return from a function.

engine/baml-compiler/src/hir/dump.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use baml_types::ir_type::TypeIR;
44
use pretty::RcDoc;
55

66
use crate::{
7-
emit::{EmitSpec, EmitWhen},
87
hir::{
98
AssignOp, BinaryOperator, Block, Class, ClassConstructorField, Enum, EnumVariant,
109
ExprFunction, Expression, Field, Hir, LlmFunction, Parameter, Statement, TypeArg,
1110
UnaryOperator,
1211
},
12+
watch::{WatchSpec, WatchWhen},
1313
};
1414

1515
impl Hir {
@@ -132,7 +132,7 @@ impl Statement {
132132
name,
133133
value,
134134
annotated_type,
135-
emit,
135+
watch,
136136
..
137137
} => RcDoc::text("let")
138138
.append(RcDoc::space())
@@ -145,8 +145,8 @@ impl Statement {
145145
.append(RcDoc::text("="))
146146
.append(RcDoc::space())
147147
.append(value.to_doc())
148-
.append(match emit {
149-
Some(emit) => emit.to_doc(),
148+
.append(match watch {
149+
Some(watch) => watch.to_doc(),
150150
None => RcDoc::nil(),
151151
})
152152
.append(RcDoc::text(";")),
@@ -177,7 +177,7 @@ impl Statement {
177177
name,
178178
value,
179179
annotated_type,
180-
emit,
180+
watch,
181181
..
182182
} => RcDoc::text("let")
183183
.append(RcDoc::space())
@@ -190,8 +190,8 @@ impl Statement {
190190
.append(RcDoc::text("="))
191191
.append(RcDoc::space())
192192
.append(value.to_doc())
193-
.append(match emit {
194-
Some(emit) => emit.to_doc(),
193+
.append(match watch {
194+
Some(watch) => watch.to_doc(),
195195
None => RcDoc::nil(),
196196
})
197197
.append(RcDoc::text(";")),
@@ -692,20 +692,20 @@ impl AssignOp {
692692
}
693693
}
694694

695-
impl EmitSpec {
695+
impl WatchSpec {
696696
pub fn to_doc(&self) -> RcDoc<'static, ()> {
697697
let mut args: Vec<String> = Vec::new();
698698
if self.skip_def {
699699
args.push("skip_def=true".to_string())
700700
}
701701
match &self.when {
702-
EmitWhen::False => args.push("when=false".to_string()),
703-
EmitWhen::True => {}
704-
EmitWhen::FunctionName(fn_name) => args.push(format!("when={fn_name}")),
702+
WatchWhen::Manual => args.push("when=manual".to_string()),
703+
WatchWhen::True => {}
704+
WatchWhen::FunctionName(fn_name) => args.push(format!("when={fn_name}")),
705705
}
706706
args.push(format!("name={}", self.name));
707707
let args_doc = RcDoc::intersperse(args.iter().cloned().map(RcDoc::text), RcDoc::text(", "));
708-
let doc = RcDoc::space().append(RcDoc::text("@emit"));
708+
let doc = RcDoc::space().append(RcDoc::text("@watch"));
709709
if args.is_empty() {
710710
doc
711711
} else {

engine/baml-compiler/src/hir/lowering.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use baml_types::{
1111
use internal_baml_ast::ast::{self, App, AssertStmt, Attribute, ReturnStmt, WithName, WithSpan};
1212

1313
use crate::{
14-
emit::EmitSpec,
1514
hir::{
1615
self, Block, Class, ClassConstructor, ClassConstructorField, Enum, EnumVariant,
1716
ExprFunction, Expression, Field, Hir, LlmFunction, Parameter, Statement, TypeArg,
1817
},
18+
watch::WatchSpec,
1919
};
2020

2121
impl Hir {
@@ -414,29 +414,29 @@ fn lower_stmt(stmt: &ast::Stmt) -> Statement {
414414
expr,
415415
span,
416416
annotations: _,
417-
emit,
417+
watch,
418418
}) => {
419419
let lifted_expr = Expression::from_ast(expr);
420420
let annotated_type = annotation.as_ref().map(type_ir_from_ast);
421421

422-
let emit_spec = emit
422+
let watch_spec = watch
423423
.as_ref()
424-
.map(|e| EmitSpec::from_ast_with_name(e, identifier.to_string()));
424+
.map(|e| WatchSpec::from_ast_with_name(e, identifier.to_string()));
425425

426426
if *is_mutable {
427427
Statement::DeclareAndAssign {
428428
name: identifier.to_string(),
429429
value: lifted_expr,
430430
annotated_type,
431-
emit: emit_spec,
431+
watch: watch_spec,
432432
span: span.clone(),
433433
}
434434
} else {
435435
Statement::Let {
436436
name: identifier.to_string(),
437437
value: lifted_expr,
438438
annotated_type,
439-
emit: emit_spec,
439+
watch: watch_spec,
440440
span: span.clone(),
441441
}
442442
}

engine/baml-compiler/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pub mod builtin;
22
pub mod codegen;
3-
pub mod emit;
43
pub mod hir;
54
pub mod thir;
5+
pub mod watch;
66

77
pub use codegen::compile;
88

engine/baml-compiler/src/thir.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use baml_types::ir_type::TypeIR;
44

55
use crate::{
6-
emit::EmitSpec,
76
hir::{self, AssignOp, BinaryOperator, LlmFunction, UnaryOperator},
7+
watch::WatchSpec,
88
};
99

1010
pub mod interpret;
@@ -640,7 +640,7 @@ pub enum Statement<T> {
640640
Let {
641641
name: String,
642642
value: Expr<T>,
643-
emit: Option<EmitSpec>,
643+
watch: Option<WatchSpec>,
644644
span: Span,
645645
},
646646
/// Declare a (mutable) reference.
@@ -665,7 +665,7 @@ pub enum Statement<T> {
665665
DeclareAndAssign {
666666
name: String,
667667
value: Expr<T>,
668-
emit: Option<EmitSpec>,
668+
watch: Option<WatchSpec>,
669669
span: Span,
670670
},
671671
/// Return from a function.
@@ -717,7 +717,7 @@ impl<T: Clone> Statement<T> {
717717
Statement::Let {
718718
name,
719719
value,
720-
emit,
720+
watch: emit,
721721
span: _,
722722
} => {
723723
format!(
@@ -740,7 +740,7 @@ impl<T: Clone> Statement<T> {
740740
Statement::DeclareAndAssign {
741741
name,
742742
value,
743-
emit,
743+
watch: emit,
744744
span: _,
745745
} => {
746746
format!(

0 commit comments

Comments
 (0)