You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GlobalVariable.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*******************************************************************************
  2. * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Common Public License v0.5
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/cpl-v05.html
  7. *
  8. * Contributors:
  9. * IBM Corporation - initial API and implementation
  10. ******************************************************************************/
  11. package org.eclipse.jdt.internal.eval;
  12. /**
  13. * A global variable is a variable defined for an evaluation context and that persists
  14. * accross evaluations.
  15. */
  16. public class GlobalVariable {
  17. char[] typeName;
  18. char[] name;
  19. char[] initializer;
  20. int declarationStart = -1, initializerStart = -1, initExpressionStart; // positions in the global variable class definition
  21. int initializerLineStart = -1; // line in the global variable class definition
  22. /**
  23. * Creates a new global variable with the given type name, name and initializer.
  24. * initializer can be null if there is none.
  25. */
  26. public GlobalVariable(char[] typeName, char[] name, char[] initializer) {
  27. this.typeName = typeName;
  28. this.name = name;
  29. this.initializer = initializer;
  30. }
  31. /**
  32. * Returns the initializer of this global variable. The initializer is a
  33. * variable initializer (ie. an expression or an array initializer) as defined
  34. * in the Java Language Specifications.
  35. */
  36. public char[] getInitializer() {
  37. return this.initializer;
  38. }
  39. /**
  40. * Returns the name of this global variable.
  41. */
  42. public char[] getName() {
  43. return this.name;
  44. }
  45. /**
  46. * Returns the dot separated fully qualified name of the type of this global variable,
  47. * or its simple representation if it is a primitive type (eg. int, boolean, etc.)
  48. */
  49. public char[] getTypeName() {
  50. return this.typeName;
  51. }
  52. /**
  53. * Returns a readable representation of the receiver.
  54. * This is for debugging purpose only.
  55. */
  56. public String toString() {
  57. StringBuffer buffer = new StringBuffer();
  58. buffer.append(this.typeName);
  59. buffer.append(" "); //$NON-NLS-1$
  60. buffer.append(this.name);
  61. if (this.initializer != null) {
  62. buffer.append("= "); //$NON-NLS-1$
  63. buffer.append(this.initializer);
  64. }
  65. buffer.append(";"); //$NON-NLS-1$
  66. return buffer.toString();
  67. }
  68. }