1 28 29 package com.caucho.es; 30 31 import com.caucho.util.IntMap; 32 33 36 class ESWrapper extends ESObject { 37 ESBase value; 38 39 public ESString toSource(IntMap map, boolean isLoopPass) throws Throwable 40 { 41 if (isLoopPass) { 42 return value.toSource(map, isLoopPass); 43 } 44 45 Global resin = Global.getGlobalProto(); 46 47 if (prototype == resin.boolProto) 48 return ESString.create("new Boolean(" + 49 value.toSource(map, isLoopPass) + ")"); 50 else if (prototype == resin.numProto) 51 return ESString.create("new Number(" + 52 value.toSource(map, isLoopPass) + ")"); 53 else if (prototype == resin.stringProto) 54 return ESString.create("new String(" + 55 value.toSource(map, isLoopPass) + ")"); 56 else 57 return ESString.create("#unknown#"); 58 } 59 60 protected ESWrapper() {} 61 protected ESObject dup() { 62 ESWrapper newWrapper = new ESWrapper(); 63 newWrapper.value = value; return newWrapper; 65 } 66 67 public ESWrapper(String className, ESBase proto, ESBase value) 68 { 69 super(className, proto); 70 71 if (value instanceof ESObject) 72 throw new RuntimeException ("cannot wrap object"); 73 74 this.value = value; 75 } 76 } 77 | Popular Tags |