MCPcopy Create free account
hub / github.com/aspizu/goboscript / bin_op

Method bin_op

src/codegen/expr.rs:209–254  ·  view source on GitHub ↗
(
        &mut self,
        s: S,
        d: D,
        this_id: NodeID,
        parent_id: NodeID,
        op: &BinOp,
        lhs: &Expr,
        rhs: &Expr,
    )

Source from the content-addressed store, hash-verified

207 }
208
209 pub fn bin_op(
210 &mut self,
211 s: S,
212 d: D,
213 this_id: NodeID,
214 parent_id: NodeID,
215 op: &BinOp,
216 lhs: &Expr,
217 rhs: &Expr,
218 ) -> io::Result<()> {
219 if matches!(op, BinOp::And | BinOp::Or) && !(is_expr_boolean(lhs) && is_expr_boolean(rhs)) {
220 return self.bin_op(
221 s,
222 d,
223 this_id,
224 parent_id,
225 op,
226 &coerce_condition(lhs),
227 &coerce_condition(rhs),
228 );
229 }
230 if let BinOp::Of = op {
231 if let Expr::Name(name) = lhs {
232 if let Some(QualifiedName::List(qualified_name, _)) = s.qualify_name(d, name) {
233 return self.list_index(s, d, this_id, parent_id, &qualified_name, rhs);
234 }
235 }
236 }
237 if let BinOp::In = op {
238 if let Expr::Name(name) = rhs {
239 if let Some(QualifiedName::List(qualified_name, _)) = s.qualify_name(d, name) {
240 return self.list_contains(s, d, this_id, parent_id, &qualified_name, lhs);
241 }
242 }
243 }
244 let lhs_id = self.id.new_id();
245 let rhs_id = self.id.new_id();
246 self.begin_node(Node::new(op.opcode(), this_id).parent_id(parent_id))?;
247 self.begin_inputs()?;
248 self.input(s, d, op.lhs(), lhs, lhs_id)?;
249 self.input(s, d, op.rhs(), rhs, rhs_id)?;
250 self.end_obj()?; // inputs
251 self.end_obj()?; // node
252 self.expr(s, d, lhs, lhs_id, this_id)?;
253 self.expr(s, d, rhs, rhs_id, this_id)
254 }
255
256 pub fn list_index(
257 &mut self,

Callers 1

exprMethod · 0.45

Calls 15

is_expr_booleanFunction · 0.85
coerce_conditionFunction · 0.85
newFunction · 0.85
qualify_nameMethod · 0.80
list_indexMethod · 0.80
list_containsMethod · 0.80
new_idMethod · 0.80
begin_nodeMethod · 0.80
parent_idMethod · 0.80
begin_inputsMethod · 0.80
lhsMethod · 0.80
rhsMethod · 0.80

Tested by

no test coverage detected