1 16 19 20 package com.sun.org.apache.xalan.internal.xsltc.compiler; 21 22 import com.sun.org.apache.bcel.internal.generic.InstructionList; 23 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; 24 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; 25 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; 26 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; 27 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; 28 29 33 final class UnaryOpExpr extends Expression { 34 private Expression _left; 35 36 public UnaryOpExpr(Expression left) { 37 (_left = left).setParent(this); 38 } 39 40 44 public boolean hasPositionCall() { 45 return(_left.hasPositionCall()); 46 } 47 48 51 public boolean hasLastCall() { 52 return(_left.hasLastCall()); 53 } 54 55 public void setParser(Parser parser) { 56 super.setParser(parser); 57 _left.setParser(parser); 58 } 59 60 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 61 final Type tleft = _left.typeCheck(stable); 62 final MethodType ptype = lookupPrimop(stable, "u-", 63 new MethodType(Type.Void, 64 tleft)); 65 66 if (ptype != null) { 67 final Type arg1 = (Type) ptype.argsType().elementAt(0); 68 if (!arg1.identicalTo(tleft)) { 69 _left = new CastExpr(_left, arg1); 70 } 71 return _type = ptype.resultType(); 72 } 73 74 throw new TypeCheckError(this); 75 } 76 77 public String toString() { 78 return "u-" + '(' + _left + ')'; 79 } 80 81 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 82 InstructionList il = methodGen.getInstructionList(); 83 _left.translate(classGen, methodGen); 84 il.append(_type.NEG()); 85 } 86 } 87 88 | Popular Tags |