jdk/src/share/classes/com/sun/tools/example/debug/expr/LValue.java
changeset 9520 99d378796e54
parent 5506 202f599c92aa
child 10292 ed7db6a12c2a
equal deleted inserted replaced
9519:a371830a963b 9520:99d378796e54
   154             throw new ParseException("Array index must be a integer type");
   154             throw new ParseException("Array index must be a integer type");
   155         }
   155         }
   156         return new LValueArrayElement(interiorGetValue(), index);
   156         return new LValueArrayElement(interiorGetValue(), index);
   157     }
   157     }
   158 
   158 
       
   159    @Override
   159     public String toString() {
   160     public String toString() {
   160         try {
   161         try {
   161             return interiorGetValue().toString();
   162             return interiorGetValue().toString();
   162         } catch (ParseException e) {
   163         } catch (ParseException e) {
   163             return "<Parse Exception>";
   164             return "<Parse Exception>";
   417         LValueLocal(StackFrame frame, LocalVariable var) {
   418         LValueLocal(StackFrame frame, LocalVariable var) {
   418             this.frame = frame;
   419             this.frame = frame;
   419             this.var = var;
   420             this.var = var;
   420         }
   421         }
   421 
   422 
       
   423       @Override
   422         Value getValue() {
   424         Value getValue() {
   423             if (jdiValue == null) {
   425             if (jdiValue == null) {
   424                 jdiValue = frame.getValue(var);
   426                 jdiValue = frame.getValue(var);
   425             }
   427             }
   426             return jdiValue;
   428             return jdiValue;
   427         }
   429         }
   428 
   430 
       
   431       @Override
   429         void setValue0(Value val) throws InvalidTypeException,
   432         void setValue0(Value val) throws InvalidTypeException,
   430                                          ClassNotLoadedException {
   433                                          ClassNotLoadedException {
   431             frame.setValue(var, val);
   434             frame.setValue(var, val);
   432             jdiValue = val;
   435             jdiValue = val;
   433         }
   436         }
   434 
   437 
       
   438       @Override
   435         void invokeWith(List<Value> arguments) throws ParseException {
   439         void invokeWith(List<Value> arguments) throws ParseException {
   436             throw new ParseException(var.name() + " is not a method");
   440             throw new ParseException(var.name() + " is not a method");
   437         }
   441         }
   438     }
   442     }
   439 
   443 
   467                 throw new ParseException("No instance field or method with the name "
   471                 throw new ParseException("No instance field or method with the name "
   468                                + memberName + " in " + refType.name());
   472                                + memberName + " in " + refType.name());
   469             }
   473             }
   470         }
   474         }
   471 
   475 
       
   476       @Override
   472         Value getValue() throws InvocationException, InvalidTypeException,
   477         Value getValue() throws InvocationException, InvalidTypeException,
   473                                 ClassNotLoadedException, IncompatibleThreadStateException,
   478                                 ClassNotLoadedException, IncompatibleThreadStateException,
   474                                 ParseException {
   479                                 ParseException {
   475             if (jdiValue != null) {
   480             if (jdiValue != null) {
   476                 return jdiValue;
   481                 return jdiValue;
   483             } else {
   488             } else {
   484                 return jdiValue = obj.invokeMethod(thread, matchingMethod, methodArguments, 0);
   489                 return jdiValue = obj.invokeMethod(thread, matchingMethod, methodArguments, 0);
   485             }
   490             }
   486         }
   491         }
   487 
   492 
       
   493         @Override
   488         void setValue0(Value val) throws ParseException,
   494         void setValue0(Value val) throws ParseException,
   489                                          InvalidTypeException,
   495                                          InvalidTypeException,
   490                                         ClassNotLoadedException {
   496                                         ClassNotLoadedException {
   491             if (matchingMethod != null) {
   497             if (matchingMethod != null) {
   492                 throw new ParseException("Cannot assign to a method invocation");
   498                 throw new ParseException("Cannot assign to a method invocation");
   493             }
   499             }
   494             obj.setValue(matchingField, val);
   500             obj.setValue(matchingField, val);
   495             jdiValue = val;
   501             jdiValue = val;
   496         }
   502         }
   497 
   503 
       
   504         @Override
   498         void invokeWith(List<Value> arguments) throws ParseException {
   505         void invokeWith(List<Value> arguments) throws ParseException {
   499             if (matchingMethod != null) {
   506             if (matchingMethod != null) {
   500                 throw new ParseException("Invalid consecutive invocations");
   507                 throw new ParseException("Invalid consecutive invocations");
   501             }
   508             }
   502             methodArguments = arguments;
   509             methodArguments = arguments;
   529                 throw new ParseException("No static field or method with the name "
   536                 throw new ParseException("No static field or method with the name "
   530                                + memberName + " in " + refType.name());
   537                                + memberName + " in " + refType.name());
   531             }
   538             }
   532         }
   539         }
   533 
   540 
       
   541         @Override
   534         Value getValue() throws InvocationException, InvalidTypeException,
   542         Value getValue() throws InvocationException, InvalidTypeException,
   535                                 ClassNotLoadedException, IncompatibleThreadStateException,
   543                                 ClassNotLoadedException, IncompatibleThreadStateException,
   536                                 ParseException {
   544                                 ParseException {
   537             if (jdiValue != null) {
   545             if (jdiValue != null) {
   538                 return jdiValue;
   546                 return jdiValue;
   546                 throw new InvalidTypeException("Cannot invoke static method on " +
   554                 throw new InvalidTypeException("Cannot invoke static method on " +
   547                                          refType.name());
   555                                          refType.name());
   548             }
   556             }
   549         }
   557         }
   550 
   558 
       
   559         @Override
   551         void setValue0(Value val)
   560         void setValue0(Value val)
   552                            throws ParseException, InvalidTypeException,
   561                            throws ParseException, InvalidTypeException,
   553                                   ClassNotLoadedException {
   562                                   ClassNotLoadedException {
   554             if (matchingMethod != null) {
   563             if (matchingMethod != null) {
   555                 throw new ParseException("Cannot assign to a method invocation");
   564                 throw new ParseException("Cannot assign to a method invocation");
   560             }
   569             }
   561             ((ClassType)refType).setValue(matchingField, val);
   570             ((ClassType)refType).setValue(matchingField, val);
   562             jdiValue = val;
   571             jdiValue = val;
   563         }
   572         }
   564 
   573 
       
   574         @Override
   565         void invokeWith(List<Value> arguments) throws ParseException {
   575         void invokeWith(List<Value> arguments) throws ParseException {
   566             if (matchingMethod != null) {
   576             if (matchingMethod != null) {
   567                 throw new ParseException("Invalid consecutive invocations");
   577                 throw new ParseException("Invalid consecutive invocations");
   568             }
   578             }
   569             methodArguments = arguments;
   579             methodArguments = arguments;
   587         final ArrayReference arrayRef;
   597         final ArrayReference arrayRef;
   588         LValueArrayLength (ArrayReference value) {
   598         LValueArrayLength (ArrayReference value) {
   589             this.arrayRef = value;
   599             this.arrayRef = value;
   590         }
   600         }
   591 
   601 
       
   602         @Override
   592         Value getValue() {
   603         Value getValue() {
   593             if (jdiValue == null) {
   604             if (jdiValue == null) {
   594                 jdiValue = arrayRef.virtualMachine().mirrorOf(arrayRef.length());
   605                 jdiValue = arrayRef.virtualMachine().mirrorOf(arrayRef.length());
   595             }
   606             }
   596             return jdiValue;
   607             return jdiValue;
   597         }
   608         }
   598 
   609 
       
   610         @Override
   599         void setValue0(Value value) throws ParseException  {
   611         void setValue0(Value value) throws ParseException  {
   600             throw new ParseException("Cannot set constant: " + value);
   612             throw new ParseException("Cannot set constant: " + value);
   601         }
   613         }
   602 
   614 
       
   615         @Override
   603         void invokeWith(List<Value> arguments) throws ParseException {
   616         void invokeWith(List<Value> arguments) throws ParseException {
   604             throw new ParseException("Array element is not a method");
   617             throw new ParseException("Array element is not a method");
   605         }
   618         }
   606     }
   619     }
   607 
   620 
   616             }
   629             }
   617             this.array = (ArrayReference)value;
   630             this.array = (ArrayReference)value;
   618             this.index = index;
   631             this.index = index;
   619         }
   632         }
   620 
   633 
       
   634         @Override
   621         Value getValue() {
   635         Value getValue() {
   622             if (jdiValue == null) {
   636             if (jdiValue == null) {
   623                 jdiValue = array.getValue(index);
   637                 jdiValue = array.getValue(index);
   624             }
   638             }
   625             return jdiValue;
   639             return jdiValue;
   626         }
   640         }
   627 
   641 
       
   642         @Override
   628         void setValue0(Value val) throws InvalidTypeException,
   643         void setValue0(Value val) throws InvalidTypeException,
   629                                          ClassNotLoadedException  {
   644                                          ClassNotLoadedException  {
   630             array.setValue(index, val);
   645             array.setValue(index, val);
   631             jdiValue = val;
   646             jdiValue = val;
   632         }
   647         }
   633 
   648 
       
   649         @Override
   634         void invokeWith(List<Value> arguments) throws ParseException {
   650         void invokeWith(List<Value> arguments) throws ParseException {
   635             throw new ParseException("Array element is not a method");
   651             throw new ParseException("Array element is not a method");
   636         }
   652         }
   637     }
   653     }
   638 
   654 
   641 
   657 
   642         LValueConstant(Value value) {
   658         LValueConstant(Value value) {
   643             this.value = value;
   659             this.value = value;
   644         }
   660         }
   645 
   661 
       
   662         @Override
   646         Value getValue() {
   663         Value getValue() {
   647             if (jdiValue == null) {
   664             if (jdiValue == null) {
   648                 jdiValue = value;
   665                 jdiValue = value;
   649             }
   666             }
   650             return jdiValue;
   667             return jdiValue;
   651         }
   668         }
   652 
   669 
       
   670         @Override
   653         void setValue0(Value val) throws ParseException {
   671         void setValue0(Value val) throws ParseException {
   654             throw new ParseException("Cannot set constant: " + value);
   672             throw new ParseException("Cannot set constant: " + value);
   655         }
   673         }
   656 
   674 
       
   675         @Override
   657         void invokeWith(List<Value> arguments) throws ParseException {
   676         void invokeWith(List<Value> arguments) throws ParseException {
   658             throw new ParseException("Constant is not a method");
   677             throw new ParseException("Constant is not a method");
   659         }
   678         }
   660     }
   679     }
   661 
   680