fn collect_variables(&self, variables: &mut Vec<Variable>, expr: Expr) {
    use ast::ExprKind::*;
    match expr.node {
      NewInstance(new_instance) => {
        for arg in new_instance.args {
          self.collect_variables(variables, arg);
        }
      }
      Call(call) => {
        if let Some(target) = call.target {
          let uid = target.last_uid();
          // Host variables can only appear as fields, and thus do not need to be retrieved from the environment.
          if self.context.var_by_uid(uid).is_spacetime() {
            variables.push(target);
          }
        }
        for arg in call.args {
          self.collect_variables(variables, arg);
        }
      }
      Var(var) => {
        let var_info = self.context.var_by_uid(var.last_uid());
        if var_info.is_spacetime() {
          variables.push(var);
        }
      }
      And(e1, e2)
    | Or(e1, e2) => {
        self.collect_variables(variables, *e1);
        self.collect_variables(variables, *e2);
      }
      Not(e) => { self.collect_variables(variables, *e); }
      Entailment(entailment) => {
        self.collect_variables(variables,entailment.left.clone());
        self.collect_variables(variables,entailment.right.clone());
      }
      Trilean(_)
    | Bottom | Top
    | Number(_) | StringLiteral(_) => ()
    }
  }
/// Collect all the variables appearing in `expr` and insert them in `variables`.
/// This is used to create a closure of this expression.
/// `variables[i] = v` represents the variable `v` at position `i` in the expression `expr`.
Collect all the variables appearing in `expr` and insert them in `variables`.
This is used to create a closure of this expression.
Collect all the variables appearing in ` expr ` and insert them in ` variables ` . This is used to create a closure of this expression .
fn collect_variables(&self, variables: &mut Vec<Variable>, expr: Expr) {
    use ast::ExprKind::*;
    match expr.node {
      NewInstance(new_instance) => {
        for arg in new_instance.args {
          self.collect_variables(variables, arg);
        }
      }
      Call(call) => {
        if let Some(target) = call.target {
          let uid = target.last_uid();
          // Host variables can only appear as fields, and thus do not need to be retrieved from the environment.
          if self.context.var_by_uid(uid).is_spacetime() {
            variables.push(target);
          }
        }
        for arg in call.args {
          self.collect_variables(variables, arg);
        }
      }
      Var(var) => {
        let var_info = self.context.var_by_uid(var.last_uid());
        if var_info.is_spacetime() {
          variables.push(var);
        }
      }
      And(e1, e2)
    | Or(e1, e2) => {
        self.collect_variables(variables, *e1);
        self.collect_variables(variables, *e2);
      }
      Not(e) => { self.collect_variables(variables, *e); }
      Entailment(entailment) => {
        self.collect_variables(variables,entailment.left.clone());
        self.collect_variables(variables,entailment.right.clone());
      }
      Trilean(_)
    | Bottom | Top
    | Number(_) | StringLiteral(_) => ()
    }
  }
fn collect_variables ( & self , variables : & mut Vec < Variable > , expr : Expr ) { use ast :: ExprKind :: * ; match expr . node { NewInstance ( new_instance ) => { for arg in new_instance . args { self . collect_variables ( variables , arg ) ; } } Call ( call ) => { if let Some ( target ) = call . target { let uid = target . last_uid ( ) ; // Host variables can only appear as fields, and thus do not need to be retrieved from the environment. if self . context . var_by_uid ( uid ) . is_spacetime ( ) { variables . push ( target ) ; } } for arg in call . args { self . collect_variables ( variables , arg ) ; } } Var ( var ) => { let var_info = self . context . var_by_uid ( var . last_uid ( ) ) ; if var_info . is_spacetime ( ) { variables . push ( var ) ; } } And ( e1 , e2 ) | Or ( e1 , e2 ) => { self . collect_variables ( variables , * e1 ) ; self . collect_variables ( variables , * e2 ) ; } Not ( e ) => { self . collect_variables ( variables , * e ) ; } Entailment ( entailment ) => { self . collect_variables ( variables , entailment . left . clone ( ) ) ; self . collect_variables ( variables , entailment . right . clone ( ) ) ; } Trilean ( _ ) | Bottom | Top | Number ( _ ) | StringLiteral ( _ ) => ( ) } }
Collect all the variables appearing in `expr` and insert them in `variables`.
Collect all the variables appearing in ` expr ` and insert them in ` variables ` .
&self
variables
&mut Vec<Variable>
expr
Expr
&self
variables
&mut Vec<Variable>
expr
Expr