1 28 29 package com.caucho.es.parser; 30 31 import com.caucho.es.ESException; 32 import com.caucho.es.ESId; 33 34 import java.io.IOException ; 35 36 39 class DeleteExpr extends Expr { 40 private Expr lhs; 41 private IdExpr var; 42 private ESId id; 43 private Expr field; 44 private boolean isTop; 45 46 DeleteExpr(Block block, IdExpr var) 47 { 48 super(block); 49 50 this.var = var; 51 var.setUsed(); 52 } 53 54 DeleteExpr(Block block, Expr lhs, ESId id) 55 { 56 super(block); 57 58 this.lhs = lhs; 59 this.id = id; 60 61 if (lhs != null) 62 lhs.setUsed(); 63 } 64 65 DeleteExpr(Block block, Expr lhs, Expr field) 66 { 67 super(block); 68 69 this.lhs = lhs; 70 this.field = field; 71 72 if (lhs != null) 73 lhs.setUsed(); 74 if (field != null) 75 field.setUsed(); 76 } 77 78 void exprStatement(Function fun) throws ESException 79 { 80 isTop = true; 81 82 fun.addExpr(this); 83 } 84 85 88 void print() 89 throws IOException 90 { 91 if (var != null && var.isLocal()) { 92 if (! isTop) 93 cl.print("ESBoolean.FALSE"); 94 } 95 else if (var != null) { 96 if (function.isGlobalScope()) 97 cl.print("_env.global.delete("); 98 else 99 cl.print("_env.deleteScopeProperty("); 100 printLiteral(var.getId()); 101 cl.print(")"); 102 if (isTop) 103 cl.println(";"); 104 } 105 else if (id != null) { 106 lhs.print(); 107 cl.print(".delete("); 108 printLiteral(id); 109 cl.print(")"); 110 if (isTop) 111 cl.println(";"); 112 } else { 113 lhs.print(); 114 cl.print(".delete("); 115 field.printStr(); 116 cl.print(")"); 117 if (isTop) 118 cl.println(";"); 119 } 120 } 121 } 122 | Popular Tags |