JLhs.java |
1 // Copyright 2012- Bill Campbell, Swami Iyer and Bahar Akbal-Delibas 2 3 package jminusminus; 4 5 /** 6 * The type of any expression that can appear on the lhs of an assignment statement: JVariable, 7 * JFieldSelection, and JArrayExpression. 8 */ 9 interface JLhs { 10 /** 11 * Analyzes the lhs of an assignment. This is very much like the analyze() methods, but 12 * perhaps a little more selective here and there. 13 * 14 * @param context context in which names are resolved. 15 * @return the analyzed (and possibly rewritten) AST subtree. 16 */ 17 public JExpression analyzeLhs(Context context); 18 19 /** 20 * Generates code to load onto the stack any part of the lhs that must be there, as in a[i] = x. 21 * 22 * @param output the code emitter. 23 */ 24 public void codegenLoadLhsLvalue(CLEmitter output); 25 26 /** 27 * Generates code to load an Rvalue of the lhs, as in a += x. 28 * 29 * @param output the code emitter. 30 */ 31 public void codegenLoadLhsRvalue(CLEmitter output); 32 33 /** 34 * Generates the code to duplicate the Rvalue that is on the stack because it is to be used 35 * in a surrounding expression, as in a[i] = x--. 36 * 37 * @param output the code emitter. 38 */ 39 public void codegenDuplicateRvalue(CLEmitter output); 40 41 /** 42 * Generates the code to do the actual assignment. 43 * 44 * @param output the code emitter. 45 */ 46 public void codegenStore(CLEmitter output); 47 } 48