More consistent use of add_inst (#5012)
Use the InstId returned by add_inst rather than creating it eagerly, when possible.
This commit is contained in:
@@ -262,8 +262,7 @@ impl PatternSequence {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn add_arg(&mut self, index: usize, ty: TypeId) -> Value {
|
fn add_arg(&mut self, index: usize, ty: TypeId) -> Value {
|
||||||
let inst = InstId(self.insts.len());
|
let inst = self.add_inst(PatternInst::Arg { index, ty });
|
||||||
self.add_inst(PatternInst::Arg { index, ty });
|
|
||||||
Value::Pattern { inst, output: 0 }
|
Value::Pattern { inst, output: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,14 +495,12 @@ impl ExprSequence {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn add_const_int(&mut self, ty: TypeId, val: i128) -> Value {
|
fn add_const_int(&mut self, ty: TypeId, val: i128) -> Value {
|
||||||
let inst = InstId(self.insts.len());
|
let inst = self.add_inst(ExprInst::ConstInt { ty, val });
|
||||||
self.add_inst(ExprInst::ConstInt { ty, val });
|
|
||||||
Value::Expr { inst, output: 0 }
|
Value::Expr { inst, output: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_const_prim(&mut self, ty: TypeId, val: Sym) -> Value {
|
fn add_const_prim(&mut self, ty: TypeId, val: Sym) -> Value {
|
||||||
let inst = InstId(self.insts.len());
|
let inst = self.add_inst(ExprInst::ConstPrim { ty, val });
|
||||||
self.add_inst(ExprInst::ConstPrim { ty, val });
|
|
||||||
Value::Expr { inst, output: 0 }
|
Value::Expr { inst, output: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,9 +510,8 @@ impl ExprSequence {
|
|||||||
ty: TypeId,
|
ty: TypeId,
|
||||||
variant: VariantId,
|
variant: VariantId,
|
||||||
) -> Value {
|
) -> Value {
|
||||||
let inst = InstId(self.insts.len());
|
|
||||||
let inputs = inputs.iter().cloned().collect();
|
let inputs = inputs.iter().cloned().collect();
|
||||||
self.add_inst(ExprInst::CreateVariant {
|
let inst = self.add_inst(ExprInst::CreateVariant {
|
||||||
inputs,
|
inputs,
|
||||||
ty,
|
ty,
|
||||||
variant,
|
variant,
|
||||||
@@ -531,9 +527,8 @@ impl ExprSequence {
|
|||||||
infallible: bool,
|
infallible: bool,
|
||||||
multi: bool,
|
multi: bool,
|
||||||
) -> Value {
|
) -> Value {
|
||||||
let inst = InstId(self.insts.len());
|
|
||||||
let inputs = inputs.iter().cloned().collect();
|
let inputs = inputs.iter().cloned().collect();
|
||||||
self.add_inst(ExprInst::Construct {
|
let inst = self.add_inst(ExprInst::Construct {
|
||||||
inputs,
|
inputs,
|
||||||
ty,
|
ty,
|
||||||
term,
|
term,
|
||||||
|
|||||||
Reference in New Issue
Block a user