Lib/Source/Translate.cpp
/**
 * @param seq      Target instruction sequence to extend
 * @param lhsExpr  Expression on left-hand side
 * @param rhs      Expression on right-hand side
 */
@param seq      Target instruction sequence to extend
@param lhsExpr  Expression on left-hand side
@param rhs      Expression on right-hand side
@param seq Target instruction sequence to extend @param lhsExpr Expression on left - hand side @param rhs Expression on right - hand side
void assign(Instr::List *seq, Expr::Ptr lhsExpr, Expr::Ptr rhs) {
  Expr lhs = *lhsExpr;
  if (lhs.tag() == Expr::VAR) {
    *seq << varAssign(lhs.var(), rhs);
    return;
  }
  if (lhs.tag() == Expr::DEREF && (lhs.deref_ptr()->tag() != Expr::VAR || rhs->tag() != Expr::VAR)) {
    assert(!lhs.deref_ptr()->isLit());
    lhs.deref_ptr(simplify(seq, lhs.deref_ptr()));
    rhs = putInVar(seq, rhs);
  }
  bool handle_case = (lhs.tag() == Expr::DEREF && (lhs.deref_ptr()->tag() == Expr::VAR || rhs->tag() == Expr::VAR));
  if (handle_case) {
    *seq << getSourceTranslate().store_var(lhs.deref_ptr()->var(), rhs->var());
    return;
  }
  assert(false);  
}
void assign ( Instr :: List * seq , Expr :: Ptr lhsExpr , Expr :: Ptr rhs ) { Expr lhs = * lhsExpr ; if ( lhs . tag ( ) == Expr :: VAR ) { * seq << varAssign ( lhs . var ( ) , rhs ) ; return ; } if ( lhs . tag ( ) == Expr :: DEREF && ( lhs . deref_ptr ( ) -> tag ( ) != Expr :: VAR || rhs -> tag ( ) != Expr :: VAR ) ) { assert ( ! lhs . deref_ptr ( ) -> isLit ( ) ) ; lhs . deref_ptr ( simplify ( seq , lhs . deref_ptr ( ) ) ) ; rhs = putInVar ( seq , rhs ) ; } bool handle_case = ( lhs . tag ( ) == Expr :: DEREF && ( lhs . deref_ptr ( ) -> tag ( ) == Expr :: VAR || rhs -> tag ( ) == Expr :: VAR ) ) ; if ( handle_case ) { * seq << getSourceTranslate ( ) . store_var ( lhs . deref_ptr ( ) -> var ( ) , rhs -> var ( ) ) ; return ; } assert ( false ) ; }
@param seq      Target instruction sequence to extend
 @param lhsExpr  Expression on left-hand side
 @param rhs      Expression on right-hand side
@param seq Target instruction sequence to extend @param lhsExpr Expression on left - hand side @param rhs Expression on right - hand side
// ----------------------------------------------------------- // Case: v := rhs, where v is a variable and rhs an expression // ----------------------------------------------------------- // --------------------------------------------------------- // Case: *lhs := rhs where lhs is not a var or rhs not a var // --------------------------------------------------------- // ------------------------------------------------- // Case: *v := rhs where v is a var and rhs is a var // ------------------------------------------------- // Strictly speaking, the two VAR tests are not necessary; it is the only possible case // (According to previous code, that is) // Should not be reachable