[MAJOR: removed Java API.
barista@x9c.fr**20110307050012
Ignore-this: 92ef0bc7f9276d95b9b6b310d17065d3
] {
rmdir ./api/classes
hunk ./api/src/fr/x9c/barista/api/API.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-import fr.x9c.cadmium.kernel.AbstractNativeRunner;
-import fr.x9c.cadmium.kernel.Block;
-import fr.x9c.cadmium.kernel.CadmiumException;
-import fr.x9c.cadmium.kernel.Value;
-import fr.x9c.cadmium.kernel.Fail;
-import fr.x9c.cadmium.kernel.FalseExit;
-import fr.x9c.cadmium.kernel.Fatal;
-import fr.x9c.cadmium.support.values.ToValue;
-
-/**
- * Entry point of the Barista Java API.
- *
- * @author Xavier Clerc
- * @version 1.1
- * @since 1.0
- */
-public final class API {
-
- /** The actual Barista program (that registered callbacks to be used). */
- private static fr.x9c.barista.cafesterolMain main;
-
- /**
- * No instance of this class.
- */
- private API() {
- } // end empty constructor
-
- /**
- * Initializes the Barista API.
- */
- public static synchronized void init() {
- if (main == null) {
- main = fr.x9c.barista.cafesterolMain.mainWithReturn(new String[] { "-api" });
- } // end if
- } // end method 'init()'
-
- /**
- * Runs a callback, wrapping any exception as a Barista one.
- * @param name callback name - should not be null
- * @param args callback parameters - should not be null
- * @return the result of the callback execution
- * @throws BaristaException if any error occurs during callback
- */
- static Value callback(final String name, final Value... args)
- throws BaristaException {
- assert name != null : "null name";
- assert args != null : "null args";
- init();
- final AbstractNativeRunner runner = main.copy();
- try {
- return runner.callback(name, args);
- } catch (final Fail.Exception fe) {
- final Value v = fe.asValue(runner);
- throw new BaristaException(v.asBlock().get(1).asBlock().asString());
- } catch (final Fatal.Exception fe) {
- throw new BaristaException(fe.getMessage());
- } catch (final FalseExit fe) {
- return null;
- } catch (final CadmiumException ce) {
- throw new BaristaException(ce.toString());
- } // end try/catch
- } // end method 'callback(String, Value...)'
-
- /**
- * Creates an UTF8 instance from a string.
- * @param s string to create from - should not be null
- * @return the corresponding UTF8 instance
- */
- static Value createUTF8(final String s) {
- assert s != null : "null s";
- try {
- final Block b = Block.createString(s.getBytes("UTF-8"));
- return Value.createFromBlock(b);
- } catch (java.io.UnsupportedEncodingException uee) {
- throw new BaristaException("UTF8 unsupported by Java platform");
- } // and try/catch
- } // end method 'createUTF8(String)'
-
- /**
- * Converts an UTF8 value into a string.
- * @param v value to convert - should not be null
- * @return the corresponding string
- */
- static String stringOfUTF8(final Value v) {
- assert v != null : "null v";
- try {
- return new String(v.asBlock().getBytes(), "UTF-8");
- } catch (java.io.UnsupportedEncodingException uee) {
- throw new BaristaException("UTF8 unsupported by Java platform");
- } // and try/catch
- } // end method 'stringOfUTF8(Value)'
-
- /**
- * Creates a class name from a string.
- * @param s string to create name from - should not be null
- * @return the corresponding class name
- * @throws BaristaException if passed string is not a valid class name
- */
- static Value createClassName(final String s) throws BaristaException {
- assert s != null : "null s";
- return callback("fr.x9c.barista.api.Name.make_class",
- createUTF8(s));
- } // end method 'createClassName(String)'
-
- /**
- * Creates a field name from a string.
- * @param s string to create name from - should not be null
- * @return the corresponding field name
- * @throws BaristaException if passed string is not a valid field name
- */
- static Value createFieldName(final String s) throws BaristaException {
- assert s != null : "null s";
- return callback("fr.x9c.barista.api.Name.make_field",
- createUTF8(s));
- } // end method 'createFieldName(String)'
-
- /**
- * Creates a method name from a string.
- * @param s string to create name from - should not be null
- * @return the corresponding method name
- * @throws BaristaException if passed string is not a valid method name
- */
- static Value createMethodName(final String s) throws BaristaException {
- assert s != null : "null s";
- return callback("fr.x9c.barista.api.Name.make_method",
- createUTF8(s));
- } // end method 'createMethodName(String)'
-
- /**
- * Converts a class name value into a string.
- * @param v classname value to convert - should not be null
- * @return the corresponding string
- * @throws BaristaEception if an error occurs during conversion
- */
- static String stringOfClassName(final Value v) throws BaristaException {
- assert v != null : "null v";
- return stringOfUTF8(callback("fr.x9c.barista.api.Name.utf8_of_class", v));
- } // end method 'stringOfClassName(Value)'
-
- /**
- * Converts a field name value into a string.
- * @param v field name value to convert - should not be null
- * @return the corresponding string
- * @throws BaristaEception if an error occurs during conversion
- */
- static String stringOfFieldName(final Value v) throws BaristaException {
- assert v != null : "null v";
- return stringOfUTF8(callback("fr.x9c.barista.api.Name.utf8_of_field", v));
- } // end method 'stringOfFieldName(Value)'
-
- /**
- * Converts a method name value into a string.
- * @param v method name value to convert - should not be null
- * @return the corresponding string
- * @throws BaristaEception if an error occurs during conversion
- */
- static String stringOfMethodName(final Value v) throws BaristaException {
- assert v != null : "null v";
- return stringOfUTF8(callback("fr.x9c.barista.api.Name.utf8_of_method", v));
- } // end method 'stringOfMethodName(Value)'
-
- /**
- * Creates a field signature from a string.
- * @param s string to create signature from - should not be null
- * @return the corresponding signature
- * @throws BaristaException if passed string is not a valid field signature
- */
- static Value createFieldSignature(final String s) throws BaristaException {
- assert s != null : "null s";
- return callback("fr.x9c.barista.api.Signature.make_field",
- createUTF8(s));
- } // end method 'createFieldSignature(String)'
-
- /**
- * Converts a field signature value into a string.
- * @param v field signature value to convert - should not be null
- * @return the corresponding string
- * @throws BaristaEception if an error occurs during conversion
- */
- static String stringOfFieldSignature(final Value v) throws BaristaException {
- assert v != null : "null v";
- return stringOfUTF8(callback("fr.x9c.barista.api.Signature.utf8_of_field_signature", v));
- } // end method 'stringOfFieldSignature(Value)'
-
- /**
- * Creates a method signature from a string.
- * @param s string to create signature from - should not be null
- * @return the corresponding signature
- * @throws BaristaException if passed string is not a valid method signature
- */
- static Value createMethodSignature(final String s) throws BaristaException {
- assert s != null : "null s";
- return callback("fr.x9c.barista.api.Signature.make_method",
- createUTF8(s));
- } // end method 'createMethodSignature(String)'
-
- /**
- * Converts a method signature value into a string.
- * @param v method signature value to convert - should not be null
- * @return the corresponding string
- * @throws BaristaEception if an error occurs during conversion
- */
- static String stringOfMethodSignature(final Value v) throws BaristaException {
- assert v != null : "null v";
- return stringOfUTF8(callback("fr.x9c.barista.api.Signature.utf8_of_method_signature", v));
- } // end method 'stringOfMethodSignature(Value)'
-
- /**
- * Creates a class signature from a string.
- * @param s string to create signature from - should not be null
- * @return the corresponding signature
- * @throws BaristaException if passed string is not a valid class signature
- */
- static Value createClassSignature(final String s) throws BaristaException {
- assert s != null : "null s";
- return callback("fr.x9c.barista.api.Signature.make_class",
- createUTF8(s));
- } // end method 'createClassSignature(String)'
-
- /**
- * Converts a class signature value into a string.
- * @param v class signature value to convert - should not be null
- * @return the corresponding string
- * @throws BaristaEception if an error occurs during conversion
- */
- static String stringOfClassSignature(final Value v) throws BaristaException {
- assert v != null : "null v";
- return stringOfUTF8(callback("fr.x9c.barista.api.Signature.utf8_of_class_signature", v));
- } // end method 'stringOfClassSignature(Value)'
-
- /**
- * Decodes a list of value from a value.
- * @param v value to decode - should not be null
- * @return the corresponding list
- */
- static List decodeList(final Value v) {
- assert v != null : "null v";
- final List res = new LinkedList();
- Value list = v;
- while (list != Value.EMPTY_LIST) {
- final Block b = list.asBlock();
- res.add(b.get(0));
- list = b.get(1);
- } // end while
- return res;
- } // end method 'decodeList(Value)'
-
- /**
- * Encodes a list into a value.
- * @param l list to encode - should not be null
- * @return the passed list as a value
- */
- static Value encodeList(final List l) {
- assert l != null : "null l";
- Value res = Value.EMPTY_LIST;
- final ListIterator it = l.listIterator(l.size());
- while (it.hasPrevious()) {
- final Block cons = Block.createBlock(Block.TAG_CONS,
- it.previous().toValue(),
- res);
- res = Value.createFromBlock(cons);
- } // end while
- return res;
- } // end method 'encodeList(List)'
-
- /**
- * Encodes a list into a value.
- * @param l list to encode - should not be null
- * @return the passed list as a value
- */
- static Value encodeValueList(final List l) {
- assert l != null : "null l";
- Value res = Value.EMPTY_LIST;
- final ListIterator it = l.listIterator(l.size());
- while (it.hasPrevious()) {
- final Block cons = Block.createBlock(Block.TAG_CONS,
- it.previous(),
- res);
- res = Value.createFromBlock(cons);
- } // end while
- return res;
- } // end method 'encodeValueList(List)'
-
- /**
- * Encodes a list into a value.
- * @param ll list to encode - should not be null
- * @return the passed list as a value
- */
- static Value encodeListList(final List< List > ll) {
- assert ll != null : "null ll";
- final List l = new LinkedList();
- for (List i : ll) {
- l.add(encodeList(i));
- } // end for
- return encodeValueList(l);
- } // end method 'encodeListList(List< List >)'
-
- /**
- * Tests whether two objects are either equal or both null.
- * @param obj1 first object to test
- * @param obj2 second object to test
- * @return true if passed objects are either equal or both null,
- * false otherwise
- */
- static boolean nullOrEquals(final Object obj1, final Object obj2) {
- if (obj1 != null) {
- return obj2 != null ? obj1.equals(obj2) : false;
- } else {
- return obj2 == null;
- } // end if/else
- } // end method 'nullOrEquals(Object, Object)'
-
-} // end class 'API'
rmfile ./api/src/fr/x9c/barista/api/API.java
hunk ./api/src/fr/x9c/barista/api/AccessFlag.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import fr.x9c.cadmium.kernel.Value;
-import fr.x9c.cadmium.primitives.stdlib.Hash;
-import fr.x9c.cadmium.support.values.ToValue;
-
-/**
- * This class represents a Java access flag for a Java element.
- *
- * @author Xavier Clerc
- * @version 2.0
- * @since 1.0
- */
-public enum AccessFlag implements ToValue, Comparator {
-
- Public,
- Private,
- Protected,
- Static,
- Final,
- Super,
- Synchronized,
- Bridge,
- Volatile,
- Transient,
- Varargs,
- Native,
- Interface,
- Abstract,
- Strict,
- Synthetic,
- Annotation,
- Enum,
- Module;
-
- /** Map from tag values to flags. */
- private static final Map MAP =
- new HashMap();
-
- /** Map initilization. */
- static {
- for (AccessFlag a : AccessFlag.values()) {
- MAP.put(a.toValue().asLong(), a);
- } // end for
- } // end static block
-
- /**
- * Tests whether the flag is a valid class flag.
- * @return true if the flag is a valid class flag,
- * false otherwise
- */
- public boolean isClassFlag() {
- switch (this) {
- case Public:
- case Final:
- case Super:
- case Interface:
- case Abstract:
- case Synthetic:
- case Annotation:
- case Enum:
- case Module:
- return true;
- default:
- return false;
- } // end switch
- } // end method 'isClassFlag()'
-
- /**
- * Tests whether the flag is a valid inner-class flag.
- * @return true if the flag is a valid inner-class flag,
- * false otherwise
- */
- public boolean isInnerClassFlag() {
- switch (this) {
- case Public:
- case Private:
- case Protected:
- case Static:
- case Final:
- case Super:
- case Interface:
- case Abstract:
- case Synthetic:
- case Annotation:
- case Enum:
- case Module:
- return true;
- default:
- return false;
- } // end switch
- } // end method 'isInnerClassFlag()'
-
- /**
- * Tests whether the flag is a valid field flag.
- * @return true if the flag is a valid field flag,
- * false otherwise
- */
- public boolean isFieldFlag() {
- switch (this) {
- case Public:
- case Private:
- case Protected:
- case Static:
- case Final:
- case Volatile:
- case Transient:
- case Synthetic:
- case Enum:
- case Module:
- return true;
- default:
- return false;
- } // end switch
- } // end method 'isFieldFlag()'
-
- /**
- * Tests whether the flag is a valid method flag.
- * @return true if the flag is a valid method flag,
- * false otherwise
- */
- public boolean isMethodFlag() {
- switch (this) {
- case Public:
- case Private:
- case Protected:
- case Static:
- case Final:
- case Synchronized:
- case Bridge:
- case Varargs:
- case Native:
- case Abstract:
- case Strict:
- case Synthetic:
- case Module:
- return true;
- default:
- return false;
- } // end switch
- } // end method 'isMethodFlag()'
-
- /**
- * Tests whether the flag is a valid constructor flag.
- * @return true if the flag is a valid constructor flag,
- * false otherwise
- */
- public boolean isConstructorFlag() {
- switch (this) {
- case Public:
- case Private:
- case Protected:
- case Strict:
- case Varargs:
- case Synthetic:
- case Module:
- return true;
- default:
- return false;
- } // end switch
- } // end method 'isConstructorFlag()'
-
- /**
- * Returns the rank of a flag, used for comparison.
- * @return the rank of a flag, used for comparison
- */
- int getRank() {
- switch (this) {
- case Public:
- case Private:
- case Protected:
- case Module:
- return 1;
- case Abstract:
- case Static:
- return 2;
- case Final:
- return 3;
- case Synchronized:
- case Volatile:
- case Transient:
- case Native:
- case Strict:
- return 4;
- case Super:
- case Bridge:
- case Varargs:
- case Interface:
- case Synthetic:
- case Annotation:
- case Enum:
- return 5;
- default:
- assert false : "invalid flag";
- return 0;
- } // end switch
- } // end method 'getRank()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- return Hash.hashVariant(name());
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- public int compare(final AccessFlag af1, final AccessFlag af2) {
- assert af1 != null : "null af1";
- assert af2 != null : "null af2";
- final int cmp = af1.getRank() - af2.getRank();
- if (cmp != 0) {
- return cmp;
- } else {
- return af1.name().compareTo(af2.name());
- } // end if/else
- } // end method 'toValue()'
-
- /**
- * Constructs an instance from a value.
- * @param v value to construct instance from - should not be null
- * @return the corresponding instance
- */
- static AccessFlag fromValue(final Value v) {
- assert v != null : "null v";
- return MAP.get(v.asLong());
- } // end method 'fromValue(Value)'
-
- /**
- * Tests whether a list contains only class flags.
- * @param l list to test - should not be null
- * @return true if the list contains only class flags,
- * false otherwise
- */
- public static boolean areClassFlags(final List l) {
- for (AccessFlag a : l) {
- if (!a.isClassFlag()) {
- return false;
- } // end if
- } // end for
- return true;
- } // end method 'areClassFlags(List)'
-
- /**
- * Tests whether a list contains only inner-class flags.
- * @param l list to test - should not be null
- * @return true if the list contains only inner-class flags,
- * false otherwise
- */
- public static boolean areInnerClassFlags(final List l) {
- for (AccessFlag a : l) {
- if (!a.isInnerClassFlag()) {
- return false;
- } // end if
- } // end for
- return true;
- } // end method 'areInnerClassFlags(List)'
-
- /**
- * Tests whether a list contains only field flags.
- * @param l list to test - should not be null
- * @return true if the list contains only field flags,
- * false otherwise
- */
- public static boolean areFieldFlags(final List l) {
- for (AccessFlag a : l) {
- if (!a.isFieldFlag()) {
- return false;
- } // end if
- } // end for
- return true;
- } // end method 'areFieldFlags(List)'
-
- /**
- * Tests whether a list contains only method flags.
- * @param l list to test - should not be null
- * @return true if the list contains only method flags,
- * false otherwise
- */
- public static boolean areMethodFlags(final List l) {
- for (AccessFlag a : l) {
- if (!a.isMethodFlag()) {
- return false;
- } // end if
- } // end for
- return true;
- } // end method 'areMethodFlags(List)'
-
- /**
- * Tests whether a list contains only constructor flags.
- * @param l list to test - should not be null
- * @return true if the list contains only constructor flags,
- * false otherwise
- */
- public static boolean areConstructorFlags(final List l) {
- for (AccessFlag a : l) {
- if (!a.isConstructorFlag()) {
- return false;
- } // end if
- } // end for
- return true;
- } // end method 'areConstructorFlags(List)'
-
- /**
- * Converts a flag list into a string.
- * @param l list to convert - should not be null
- * @return the concatenation of all list elements
- */
- public static String listToString(final List l) {
- assert l != null : "null l";
- final StringBuilder sb = new StringBuilder();
- final List l2 = new LinkedList(l);
- Collections.sort(l2);
- boolean first = true;
- for (AccessFlag a : l2) {
- if (first) {
- first = false;
- } else {
- sb.append(" ");
- } // end if/else
- sb.append(a.toString());
- } // end for
- return sb.toString();
- } // end method 'listToString(List)'
-
-} // end class 'AccessFlag'
rmfile ./api/src/fr/x9c/barista/api/AccessFlag.java
hunk ./api/src/fr/x9c/barista/api/Annotation.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-import fr.x9c.cadmium.kernel.Block;
-import fr.x9c.cadmium.kernel.Value;
-import fr.x9c.cadmium.support.Helper;
-import fr.x9c.cadmium.support.values.ToValue;
-
-/**
- * This class represents a Java annotation.
- *
- * @author Xavier Clerc
- * @version 1.0
- * @since 1.0
- */
-public final class Annotation implements ToValue {
-
- /**
- * Parent class of all element value embedded inside annotations.
- */
- public static abstract class ElementValue implements ToValue {
-
- /**
- * Ensures that no element value could be defined outside this file.
- */
- private ElementValue() {
- } // end empty constructor
-
- } // end inner-class 'ElementValue'
-
- /**
- * Represents a boolean value embedded inside an annotation.
- */
- public static final class BooleanValue extends ElementValue {
-
- /** The underlying value. */
- private final boolean value;
-
- /**
- * Constructs a boolean value.
- * @param v value
- */
- public BooleanValue(final boolean v) {
- this.value = v;
- } // end constructor(boolean)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public boolean getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0, this.value ? Value.TRUE : Value.FALSE);
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "BooleanValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.value ? 1 : 0;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof BooleanValue) {
- final BooleanValue that = (BooleanValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'BooleanValue'
-
- /**
- * Represents a byte value embedded inside an annotation.
- */
- public static final class ByteValue extends ElementValue {
-
- /** The underlying value. */
- private final byte value;
-
- /**
- * Constructs a byte value.
- * @param v value
- */
- public ByteValue(final byte v) {
- this.value = v;
- } // end constructor(byte)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public byte getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(1, Value.createFromLong(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "ByteValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ByteValue) {
- final ByteValue that = (ByteValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ByteValue'
-
- /**
- * Represents a char value embedded inside an annotation.
- */
- public static final class CharValue extends ElementValue {
-
- /** The underlying value. */
- private final char value;
-
- /**
- * Constructs a char value.
- * @param v value
- */
- public CharValue(final char v) {
- this.value = v;
- } // end constructor(char)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public char getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(2, Value.createFromLong(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "CharValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof CharValue) {
- final CharValue that = (CharValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'CharValue'
-
- /**
- * Represents a double value embedded inside an annotation.
- */
- public static final class DoubleValue extends ElementValue {
-
- /** The underlying value. */
- private final double value;
-
- /**
- * Constructs a double value.
- * @param v value
- */
- public DoubleValue(final double v) {
- this.value = v;
- } // end constructor(double)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public double getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(3, Helper.createFloat(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "DoubleValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return (int) this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof DoubleValue) {
- final DoubleValue that = (DoubleValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'DoubleValue'
-
- /**
- * Represents a float value embedded inside an annotation.
- */
- public static final class FloatValue extends ElementValue {
-
- /** The underlying value. */
- private final float value;
-
- /**
- * Constructs a float value.
- * @param v value
- */
- public FloatValue(final float v) {
- this.value = v;
- } // end constructor(float)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public float getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(4, Helper.createFloat(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "FloatValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return (int) this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof FloatValue) {
- final FloatValue that = (FloatValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'FloatValue'
-
- /**
- * Represents an int value embedded inside an annotation.
- */
- public static final class IntValue extends ElementValue {
-
- /** The underlying value. */
- private final int value;
-
- /**
- * Constructs a int value.
- * @param v value
- */
- public IntValue(final int v) {
- this.value = v;
- } // end constructor(int)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public int getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(5, Helper.createInt32(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "IntValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof IntValue) {
- final IntValue that = (IntValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'IntValue'
-
- /**
- * Represents a long value embedded inside an annotation.
- */
- public static final class LongValue extends ElementValue {
-
- /** The underlying value. */
- private final long value;
-
- /**
- * Constructs a long value.
- * @param v value
- */
- public LongValue(final long v) {
- this.value = v;
- } // end constructor(long)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public long getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(6, Helper.createInt64(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "LongValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return (int) this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof LongValue) {
- final LongValue that = (LongValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'LongValue'
-
- /**
- * Represents a short value embedded inside an annotation.
- */
- public static final class ShortValue extends ElementValue {
-
- /** The underlying value. */
- private final short value;
-
- /**
- * Constructs a short value.
- * @param v value
- */
- public ShortValue(final short v) {
- this.value = v;
- } // end constructor(short)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public short getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(7, Value.createFromLong(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "ShortValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ShortValue) {
- final ShortValue that = (ShortValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ShortValue'
-
- /**
- * Represents a string value embedded inside an annotation.
- */
- public static final class StringValue extends ElementValue {
-
- /** The underlying value. */
- private final String value;
-
- /**
- * Constructs a string value.
- * @param v value - should not be null
- */
- public StringValue(final String v) {
- assert v != null : "null v";
- this.value = v;
- } // end constructor(String)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public String getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(8, API.createUTF8(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "StringValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.value.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof StringValue) {
- final StringValue that = (StringValue) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'StringValue'
-
- /**
- * Represents an enum value embedded inside an annotation.
- */
- public static final class EnumValue extends ElementValue {
-
- /** The underlying class name. */
- private final String className;
-
- /** The underlying enum name. */
- private final String enumName;
-
- /**
- * Constructs an enum value.
- * @param cn class name - should not be null
- * @param en enum name - should not be null
- */
- public EnumValue(final String cn, final String en) {
- assert cn != null : "null cn";
- assert en != null : "null en";
- this.className = cn;
- this.enumName = en;
- } // end constructor(String, String)
-
- /**
- * Returns the class name.
- * @return the class name
- */
- public String getClassName() {
- return this.className;
- } // end method 'getClassName()'
-
- /**
- * Returns the enum name.
- * @return the enum name
- */
- public String getEnumName() {
- return this.enumName;
- } // end method 'getEnumName()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(9,
- API.createClassName(this.className),
- API.createFieldName(this.enumName));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "EnumValue(" + this.className + ", " + this.enumName + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.className.hashCode() + this.enumName.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof EnumValue) {
- final EnumValue that = (EnumValue) obj;
- return this.className.equals(that.className)
- && this.enumName.equals(that.enumName);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'EnumValue'
-
- /**
- * Represents a class value embedded inside an annotation.
- */
- public static final class ClassValue extends ElementValue {
-
- /** The underlying class name. */
- private final String className;
-
- /**
- * Constructs a class value.
- * @param cn class name - should not be null
- */
- public ClassValue(final String cn) {
- assert cn != null : "null cn";
- this.className = cn;
- } // end constructor(String)
-
- /**
- * Returns the class name.
- * @return the class name
- */
- public String getClassName() {
- return this.className;
- } // end method 'getClassName()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(10, API.createClassName(this.className));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "ClassValue(" + this.className + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.className.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ClassValue) {
- final ClassValue that = (ClassValue) obj;
- return this.className.equals(that.className);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ClassValue'
-
- /**
- * Represents an annotation value embedded inside an annotation.
- */
- public static final class AnnotationValue extends ElementValue {
-
- /** The underlying value. */
- private final Annotation value;
-
- /**
- * Constructs an annotation value.
- * @param v value - should not be null
- */
- public AnnotationValue(final Annotation v) {
- assert v != null : "null v";
- this.value = v;
- } // end constructor(Annotation)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public Annotation getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(11, this.value.toValue());
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "AnnotationValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.value.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof AnnotationValue) {
- final AnnotationValue that = (AnnotationValue) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'AnnotationValue'
-
- /**
- * Represents an Array value embedded inside an annotation.
- */
- public static final class ArrayValue extends ElementValue {
-
- /** The underlying value. */
- private final ElementValue[] value;
-
- /**
- * Constructs an array value.
- * @param v value - should not be null
- */
- public ArrayValue(final ElementValue[] v) {
- assert v != null : "null v";
- final int len = v.length;
- this.value = new ElementValue[len];
- System.arraycopy(v, 0, this.value, 0, len);
- } // end constructor(ElementValue[])
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public ElementValue[] getValue() {
- final int len = this.value.length;
- final ElementValue[] res = new ElementValue[len];
- System.arraycopy(this.value, 0, res, 0, len);
- return res;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- Value res = Value.EMPTY_LIST;
- for (int i = this.value.length - 1; i >= 0; i--) {
- final Block cons = Block.createBlock(Block.TAG_CONS,
- this.value[i].toValue(),
- res);
- res = Value.createFromBlock(cons);
- } // end for
- final Block b = Block.createBlock(12, res);
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "ArrayValue(" + Arrays.toString(this.value) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Arrays.hashCode(this.value);
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ArrayValue) {
- final ArrayValue that = (ArrayValue) obj;
- return Arrays.equals(this.value, that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ArrayValue'
-
- /** Annotation name. */
- private final String name;
-
- /** Annotation element names. */
- private final List names;
-
- /** Annotation element values. */
- private final List extends ElementValue> values;
-
- /**
- * Constructs an annotation.
- * @param nm annotation name - should not be null
- * @param n element names - should not be null,
- * should also have the same size as v
- * @param v element values - should not be null,
- * should also have the same size as n
- */
- public Annotation(final String nm,
- final List n,
- final List extends ElementValue> v) {
- assert nm != null : "null nm";
- assert n != null : "null n";
- assert v != null : "null v";
- assert n.size() == v.size() : "n and v have different sizes";
- this.name = nm;
- this.names = new LinkedList(n);
- this.values = new LinkedList(v);
- } // end constructor(String, List, List extends ElementValue>)
-
- /**
- * Returns the name of the annotation.
- * @return the name of the annotation
- */
- public String getName() {
- return this.name;
- } // end method 'getName()'
-
- /**
- * Returns the names of the annotations elements.
- * @return the names of the annotations elements
- */
- public List getNames() {
- return new LinkedList(this.names);
- } // end method 'getNames()'
-
- /**
- * Returns the values of the annotations elements.
- * @return the values of the annotations elements
- */
- public List extends ElementValue> getValues() {
- return new LinkedList(this.values);
- } // end method 'getValues()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- Value list = Value.EMPTY_LIST;
- final ListIterator itNames = this.names.listIterator(this.names.size());
- final ListIterator extends ElementValue> itValues = this.values.listIterator(this.values.size());
- while (itNames.hasPrevious() && itValues.hasPrevious()) {
- final Block b = Block.createBlock(0,
- API.createUTF8(itNames.previous()),
- itValues.previous().toValue());
- final Block cons = Block.createBlock(Block.TAG_CONS,
- Value.createFromBlock(b),
- list);
- list = Value.createFromBlock(cons);
- } // end while
- final Block res = Block.createBlock(0,
- API.createClassName(this.name),
- list);
- return Value.createFromBlock(res);
- } // end method 'toValue()'
-
- /**
- * Constructs an instance from a value.
- * @param v value to construct instance from - should not be null
- * @return the corresponding instance
- */
- static ElementValue elementFromValue(final Value v) {
- assert v != null : "null v";
- final Block val = v.asBlock();
- final ElementValue elem;
- switch (val.getTag()) {
- case 0:
- return new BooleanValue(val.get(0) == Value.TRUE);
- case 1:
- return new ByteValue((byte) val.get(0).asLong());
- case 2:
- return new CharValue((char) val.get(0).asLong());
- case 3:
- return new DoubleValue(val.get(0).asBlock().asDouble());
- case 4:
- return new FloatValue((float) val.get(0).asBlock().asDouble());
- case 5:
- return new IntValue(val.get(0).asBlock().asInt32());
- case 6:
- return new LongValue(val.get(0).asBlock().asInt64());
- case 7:
- return new ShortValue((short) val.get(0).asLong());
- case 8:
- return new StringValue(API.stringOfUTF8(val.get(0)));
- case 9:
- return new EnumValue(API.stringOfClassName(val.get(0)),
- API.stringOfFieldName(val.get(1)));
- case 10:
- return new ClassValue(API.stringOfClassName(val.get(0)));
- case 11:
- return new AnnotationValue(fromValue(val.get(0)));
- case 12:
- final List elements = API.decodeList(val.get(0));
- final int sz = elements.size();
- final ElementValue[] elementValues = new ElementValue[sz];
- elements.toArray(elementValues);
- return new ArrayValue(elementValues);
- default:
- assert false : "invalid tag";
- return null;
- } // end switch
- } // end method 'elementFromValue(Value)'
-
- /**
- * Constructs an instance from a value.
- * @param v value to construct instance from - should not be null
- * @return the corresponding instance
- */
- static Annotation fromValue(final Value v) {
- assert v != null : "null v";
- final Block b = v.asBlock();
- final String name = API.stringOfClassName(b.get(0));
- final List list = API.decodeList(b.get(1));
- final List names = new LinkedList();
- final List values = new LinkedList();
- for (Value e : list) {
- final Block bl = e.asBlock();
- names.add(API.stringOfUTF8(bl.get(0)));
- values.add(elementFromValue(bl.get(1)));
- } // end for
- return new Annotation(name, names, values);
- } // end method 'fromValue(Value)'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("@");
- sb.append(this.name);
- sb.append("(");
- final Iterator itNames = this.names.iterator();
- final Iterator extends ElementValue> itValues = this.values.iterator();
- boolean first = true;
- while (itNames.hasNext() && itValues.hasNext()) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- } // end if/else
- sb.append(itNames.next());
- sb.append("=");
- sb.append(itValues.next().toString());
- } // end while
- sb.append(")");
- return sb.toString();
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.name.hashCode()
- + this.names.hashCode()
- + this.values.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Annotation) {
- final Annotation that = (Annotation) obj;
- return this.name.equals(that.name)
- && this.names.equals(that.names)
- && this.values.equals(that.values);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
-} // end class 'Annotation'
rmfile ./api/src/fr/x9c/barista/api/Annotation.java
hunk ./api/src/fr/x9c/barista/api/AntAssembleTask.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-
-/**
- * This class implements an Ant task
- * assembling a class.
- * The task supports the following attributes:
- *
- * - file: file to assemble
- * file - no default value, should be set
- * - path: output path for assembled file
- * directory - no default value, should be set
- * - target: version used for class encoding
- * string - default value is 1.6
- *
- *
- * @author Xavier Clerc
- * @version 1.3
- * @since 1.0
- */
-public final class AntAssembleTask extends Task {
-
- /** File to assemble. */
- private File file;
-
- /** Output path for assembled file. */
- private File path;
-
- /** Version used for class encoding. */
- private String target;
-
- /**
- * Creates a new task with default parameters.
- */
- public AntAssembleTask() {
- this.file = null;
- this.path = null;
- this.target = "1.6";
- } // end empty constructor
-
- /**
- * Sets the file to assemble.
- * @param f file to assemble
- */
- public void setFile(final File f) {
- this.file = f;
- } // end method 'setFile(File)'
-
- /**
- * Sets the output path for assembled file.
- * @param f output path for assembled file
- */
- public void setPath(final File f) {
- this.path = f;
- } // end method 'setPath(File)'
-
- /**
- * Sets the version used for class encoding.
- * @param s version used for class encoding
- */
- public void setTarget(final String s) {
- this.target = s;
- } // end method 'setTarger(String)'
-
- /**
- * Actually executes the task.
- */
- public void execute() throws BuildException {
- if (this.file == null) {
- throw new BuildException("'file' attribute is not set.",
- getLocation());
- } // end if
- if (this.path == null) {
- throw new BuildException("'path' attribute is not set.",
- getLocation());
- } // end if
- final Version version = Version.fromString(this.target);
- if (version == null) {
- throw new BuildException("'target' attribute is invalid.",
- getLocation());
- } // end if
-
- try {
- Assembler.assemble(version,
- new FileInputStream(this.file),
- this.path.getAbsolutePath());
- } catch (final IOException ioe) {
- throw new BuildException(ioe.getMessage(), ioe, getLocation());
- } catch (final BaristaException be) {
- throw new BuildException(be.getMessage(), be, getLocation());
- } // end try/catch
- } // end method 'execute()'
-
-} // end class 'AntAssembleTask'
rmfile ./api/src/fr/x9c/barista/api/AntAssembleTask.java
hunk ./api/src/fr/x9c/barista/api/AntDisassembleTask.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Path;
-
-/**
- * This class implements an Ant task
- * diassembling a class.
- * The task supports the following attributes:
- *
- * - classname: fully-qualified name of the class to disassemble
- * string - no default value, should be set
- * - output: where to disassemble the class
- file defaults to null (which means standard output)
- *
- * The task should also be supplied a nested <classpath> element
- * to know where to look for class files.
- *
- * @author Xavier Clerc
- * @version 1.0
- * @since 1.0
- */
-public final class AntDisassembleTask extends Task {
-
- /** Fully-qualified name of the class to be disassembled. */
- private String classname;
-
- /** Where to disassemble the class (null means standard output). */
- private File output;
-
- /** Nested classpath elements. */
- private List classpaths;
-
- /**
- * Creates a new task with default parameters.
- */
- public AntDisassembleTask() {
- this.classname = null;
- this.output = null;
- this.classpaths = new LinkedList();
- } // end empty constructor
-
- /**
- * Sets the fully-qualified name of the class to disassemble.
- * @param cn fully-qualified name of the class to disassemble
- */
- public void setClassname(final String cn) {
- this.classname = cn;
- } // end method 'setClassname(String)'
-
- /**
- * Sets the output for the task.
- * @param f output for the task
- */
- public void setOutput(final File f) {
- this.output = f;
- } // end method 'setOutput(File)'
-
- /**
- * Adds a nested classpath element to the task.
- * @param p classpath element to add
- */
- public void addClasspath(final Path p) {
- if (p != null) {
- this.classpaths.add(p);
- } // end if
- } // end method 'addClasspath(Path)'
-
- /**
- * Actually executes the task.
- */
- public void execute() throws BuildException {
- if (this.classname == null) {
- throw new BuildException("'classname' attribute is not set.",
- getLocation());
- } // end if
-
- final List classpath = new LinkedList();
- for (Path p : this.classpaths) {
- for (String s : p.list()) {
- classpath.add(new File(s).getAbsolutePath());
- } // end for
- } // end for
-
- try {
- final OutputStream out =
- this.output == null ? System.out : new FileOutputStream(this.output);
- Disassembler.disassemble(this.classname, new ClassPath(classpath), out);
- } catch (final IOException ioe) {
- throw new BuildException(ioe.getMessage(), ioe, getLocation());
- } catch (final BaristaException be) {
- throw new BuildException(be.getMessage(), be, getLocation());
- } // end try/catch
- } // end method 'execute()'
-
-} // end class 'AntDisassembleTask'
rmfile ./api/src/fr/x9c/barista/api/AntDisassembleTask.java
hunk ./api/src/fr/x9c/barista/api/AntPrintTask.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Path;
-
-/**
- * This class implements an Ant task
- * printing a class.
- * The task supports the following attributes:
- *
- * - classname: fully-qualified name of the class to print
- * string - no default value, should be set
- * - output: where to print the class
- file defaults to null (which means standard output)
- *
- * The task should also be supplied a nested <classpath> element
- * to know where to look for class files.
- *
- * @author Xavier Clerc
- * @version 1.0
- * @since 1.0
- */
-public final class AntPrintTask extends Task {
-
- /** Fully-qualified name of the class to be printed. */
- private String classname;
-
- /** Where to print the class (null means standard output). */
- private File output;
-
- /** Nested classpath elements. */
- private List classpaths;
-
- /**
- * Creates a new task with default parameters.
- */
- public AntPrintTask() {
- this.classname = null;
- this.output = null;
- this.classpaths = new LinkedList();
- } // end empty constructor
-
- /**
- * Sets the fully-qualified name of the class to print.
- * @param cn fully-qualified name of the class to print
- */
- public void setClassname(final String cn) {
- this.classname = cn;
- } // end method 'setClassname(String)'
-
- /**
- * Sets the output for the task.
- * @param f output for the task
- */
- public void setOutput(final File f) {
- this.output = f;
- } // end method 'setOutput(File)'
-
- /**
- * Adds a nested classpath element to the task.
- * @param p classpath element to add
- */
- public void addClasspath(final Path p) {
- if (p != null) {
- this.classpaths.add(p);
- } // end if
- } // end method 'addClasspath(Path)'
-
- /**
- * Actually executes the task.
- */
- public void execute() throws BuildException {
- if (this.classname == null) {
- throw new BuildException("'classname' attribute is not set.",
- getLocation());
- } // end if
-
- final List classpath = new LinkedList();
- for (Path p : this.classpaths) {
- for (String s : p.list()) {
- classpath.add(new File(s).getAbsolutePath());
- } // end for
- } // end for
-
- try {
- final OutputStream out =
- this.output == null ? System.out : new FileOutputStream(this.output);
- Printer.print(this.classname, new ClassPath(classpath), out);
- } catch (final IOException ioe) {
- throw new BuildException(ioe.getMessage(), ioe, getLocation());
- } catch (final BaristaException be) {
- throw new BuildException(be.getMessage(), be, getLocation());
- } // end try/catch
- } // end method 'execute()'
-
-} // end class 'AntPrintTask'
rmfile ./api/src/fr/x9c/barista/api/AntPrintTask.java
hunk ./api/src/fr/x9c/barista/api/Assembler.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import fr.x9c.cadmium.kernel.Block;
-import fr.x9c.cadmium.kernel.Channel;
-import fr.x9c.cadmium.kernel.Custom;
-import fr.x9c.cadmium.kernel.Value;
-
-/**
- * This class provides methods for class assembling from textual source.
- *
- * @author Xavier Clerc
- * @version 2.0
- * @since 1.0
- */
-public final class Assembler {
-
- /**
- * No instance of this class.
- */
- private Assembler() {
- } // end empty constructor
-
- /**
- * Calls the callback to assemble a class.
- * @param v version usef for encoding - should not be null
- * @param computeStacks whether stack elements should be computed
- * @param optimize whether optimizations should be enabled
- * @param classPath class path (used for stack computations) - should not be null
- * @param in where to read source - should not be null
- * @param dest where to output bytecode - should not be null
- * @return the name of the assembled class
- * @throws BaristaException if an errors occurs while assembling
- */
- private static String callAssemble(final Version v,
- final boolean computeStacks,
- final boolean optimize,
- final String classPath,
- final InputStream in,
- final Value dest)
- throws BaristaException {
- assert v != null : "null v";
- assert classPath != null : "null classPath";
- assert in != null : "null in";
- assert dest != null : "null dest";
- final Block b = Block.createCustom(Custom.CHANNEL_SIZE,
- Custom.CHANNEL_OPS);
- b.setCustom(new Channel(in));
- final Value i = Value.createFromBlock(b);
- final Value res =
- API.callback("fr.x9c.barista.api.Assembler.assemble",
- v.toValue(),
- computeStacks ? Value.TRUE : Value.FALSE,
- optimize ? Value.TRUE : Value.FALSE,
- Value.createFromBlock(Block.createString(classPath)),
- i,
- dest);
- return API.stringOfUTF8(res);
- } // end method 'callAssemble(Version, boolean, boolean, String, InputStream, Value)'
-
- /**
- * Assembles from a textual source.
- * @param v version usef for encoding - should not be null
- * @param computeStacks whether stack elements should be computed
- * @param optimize whether optimizations should be enabled
- * @param classPath class path (used for stack computations) - should not be null
- * @param in where to read source - should not be null
- * @param out where to output bytecode - should not be null
- * @return the name of the assembled class
- * @throws BaristaException if an errors occurs while assembling
- */
- public static String assemble(final Version v,
- final boolean computeStacks,
- final boolean optimize,
- final String classPath,
- final InputStream in,
- final OutputStream out)
- throws BaristaException {
- final Block b = Block.createCustom(Custom.CHANNEL_SIZE,
- Custom.CHANNEL_OPS);
- b.setCustom(new Channel(out));
- final Block c = Block.createBlock(1, Value.createFromBlock(b));
- final Block d = Block.createBlock(0, Value.createFromBlock(c));
- return callAssemble(v, computeStacks, optimize, classPath, in, Value.createFromBlock(d));
- } // end method 'assemble(Version, boolean, boolean, String, InputStream, OutputStream)'
-
- /**
- * Assembles from a textual source.
- * @param v version usef for encoding - should not be null
- * @param in where to read source - should not be null
- * @param out where to output bytecode - should not be null
- * @return the name of the assembled class
- * @throws BaristaException if an errors occurs while assembling
- */
- public static String assemble(final Version v,
- final InputStream in,
- final OutputStream out)
- throws BaristaException {
- final Block b = Block.createCustom(Custom.CHANNEL_SIZE,
- Custom.CHANNEL_OPS);
- b.setCustom(new Channel(out));
- final Block c = Block.createBlock(1, Value.createFromBlock(b));
- final Block d = Block.createBlock(0, Value.createFromBlock(c));
- return callAssemble(v, false, false, ".", in, Value.createFromBlock(d));
- } // end method 'assemble(Version, InputStream, OutputStream)'
-
- /**
- * Assembles from a textual source.
- * @param in where to read source - should not be null
- * @param out where to output bytecode - should not be null
- * @return the name of the assembled class
- * @throws BaristaException if an errors occurs while assembling
- */
- public static String assemble(final InputStream in,
- final OutputStream out)
- throws BaristaException {
- return assemble(Version.Java_1_6, in, out);
- } // end method 'assemble(InputStream, OutputStream)'
-
- /**
- * Assembles from a textual source.
- * @param v version usef for encoding - should not be null
- * @param computeStacks whether stack elements should be computed
- * @param optimize whether optimizations should be enabled
- * @param classPath class path (used for stack computations) - should not be null
- * @param in where to read source - should not be null
- * @param path where to output bytecode (needed subdirectories will be created)
- * - should not be null
- * @return the name of the assembled class
- * @throws BaristaException if an errors occurs while assembling
- */
- public static String assemble(final Version v,
- final boolean computeStacks,
- final boolean optimize,
- final String classPath,
- final InputStream in,
- final String path)
- throws BaristaException {
- final Block b = Block.createString(path);
- final Block d = Block.createBlock(1, Value.createFromBlock(b));
- return callAssemble(v, computeStacks, optimize, classPath, in, Value.createFromBlock(d));
- } // end method 'assemble(Version, boolean, boolean, String, InputStream, String)'
-
- /**
- * Assembles from a textual source.
- * @param v version usef for encoding - should not be null
- * @param in where to read source - should not be null
- * @param path where to output bytecode (needed subdirectories will be created)
- * - should not be null
- * @return the name of the assembled class
- * @throws BaristaException if an errors occurs while assembling
- */
- public static String assemble(final Version v,
- final InputStream in,
- final String path)
- throws BaristaException {
- final Block b = Block.createString(path);
- final Block d = Block.createBlock(1, Value.createFromBlock(b));
- return callAssemble(v, false, false, ".", in, Value.createFromBlock(d));
- } // end method 'assemble(Version, InputStream, String)'
-
- /**
- * Assembles from a textual source.
- * @param in where to read source - should not be null
- * @param path where to output bytecode (needed subdirectories will be created)
- * - should not be null
- * @return the name of the assembled class
- * @throws BaristaException if an errors occurs while assembling
- */
- public static String assemble(final InputStream in,
- final String path)
- throws BaristaException {
- return assemble(Version.Java_1_6, in, path);
- } // end method 'assemble(InputStream, String)'
-
-} // end class 'Assembler'
rmfile ./api/src/fr/x9c/barista/api/Assembler.java
hunk ./api/src/fr/x9c/barista/api/Attribute.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import fr.x9c.cadmium.kernel.Block;
-import fr.x9c.cadmium.kernel.Value;
-import fr.x9c.cadmium.primitives.stdlib.Hash;
-import fr.x9c.cadmium.support.Helper;
-import fr.x9c.cadmium.support.values.ToValue;
-
-/**
- * This class represents an attribute of a Java element.
- *
- * @author Xavier Clerc
- * @version 2.0
- * @since 1.0
- */
-public abstract class Attribute implements ToValue {
-
- /** Hash value for 'AnnotationDefault' attribute. */
- public static final Value HASH_ANNOTATION_DEFAULT =
- Hash.hashVariant("AnnotationDefault");
-
- /** Hash value for 'Code' attribute. */
- public static final Value HASH_CODE =
- Hash.hashVariant("Code");
-
- /** Hash value for 'ConstantValue' attribute. */
- public static final Value HASH_CONSTANT_VALUE =
- Hash.hashVariant("ConstantValue");
-
- /** Hash value for 'Deprecated' attribute. */
- public static final Value HASH_DEPRECATED =
- Hash.hashVariant("Deprecated");
-
- /** Hash value for 'EnclosingMethod' attribute. */
- public static final Value HASH_ENCLOSING_METHOD =
- Hash.hashVariant("EnclosingMethod");
-
- /** Hash value for 'Exceptions' attribute. */
- public static final Value HASH_EXCEPTIONS =
- Hash.hashVariant("Exceptions");
-
- /** Hash value for 'InnerClasses' attribute. */
- public static final Value HASH_INNER_CLASSES =
- Hash.hashVariant("InnerClasses");
-
- /** Hash value for 'LineNumberTable' attribute. */
- public static final Value HASH_LINE_NUMBER_TABLE =
- Hash.hashVariant("LineNumberTable");
-
- /** Hash value for 'LocalVariableTable' attribute. */
- public static final Value HASH_LOCAL_VARIABLE_TABLE =
- Hash.hashVariant("LocalVariableTable");
-
- /** Hash value for 'LocalVariableTypeTable' attribute. */
- public static final Value HASH_LOCAL_VARIABLE_TYPE_TABLE =
- Hash.hashVariant("LocalVariableTypeTable");
-
- /** Hash value for 'Module' attribute. */
- public static final Value HASH_MODULE =
- Hash.hashVariant("Module");
-
- /** Hash value for 'RuntimeInvisibleAnnotations' attribute. */
- public static final Value HASH_RUNTIME_INVISIBLE_ANNOTATIONS =
- Hash.hashVariant("RuntimeInvisibleAnnotations");
-
- /** Hash value for 'RuntimeInvisibleTypeAnnotations' attribute. */
- public static final Value HASH_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS =
- Hash.hashVariant("RuntimeInvisibleTypeAnnotations");
-
- /** Hash value for 'RuntimeInvisibleParameterAnnotations' attribute. */
- public static final Value HASH_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS =
- Hash.hashVariant("RuntimeInvisibleParameterAnnotations");
-
- /** Hash value for 'RuntimeVisibleAnnotations' attribute. */
- public static final Value HASH_RUNTIME_VISIBLE_ANNOTATIONS =
- Hash.hashVariant("RuntimeVisibleAnnotations");
-
- /** Hash value for 'RuntimeVisibleParameterAnnotations' attribute. */
- public static final Value HASH_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS =
- Hash.hashVariant("RuntimeVisibleParameterAnnotations");
-
- /** Hash value for 'RuntimeVisibleTypeAnnotations' attribute. */
- public static final Value HASH_RUNTIME_VISIBLE_TYPE_ANNOTATIONS =
- Hash.hashVariant("RuntimeVisibleTypeAnnotations");
-
- /** Hash value for 'Signature' attribute. */
- public static final Value HASH_SIGNATURE =
- Hash.hashVariant("Signature");
-
- /** Hash value for 'SourceDebugExtension' attribute. */
- public static final Value HASH_SOURCE_DEBUG_EXTENSION =
- Hash.hashVariant("SourceDebugExtension");
-
- /** Hash value for 'SourceFile' attribute. */
- public static final Value HASH_SOURCE_FILE =
- Hash.hashVariant("SourceFile");
-
- /** Hash value for 'Synthetic' attribute. */
- public static final Value HASH_SYNTHETIC =
- Hash.hashVariant("Synthetic");
-
- /** Hash value for 'Synthetic' attribute. */
- public static final Value HASH_STACK_MAP_TABLE =
- Hash.hashVariant("StackMapTable");
-
- /** Hash value for 'Unknown' attribute. */
- public static final Value HASH_UNKNOWN =
- Hash.hashVariant("Unknown");
-
- /**
- * Parent class of all constant values embedded in attributes.
- */
- public static abstract class ConstantVal implements ToValue {
-
- /**
- * Ensures that no constant value could be defined outside this file.
- */
- private ConstantVal() {
- } // end empty constructor
-
- /**
- * Constructs an instance from a value.
- * @param v value to construct instance from - should not be null
- * @return the corresponding instance
- */
- static ConstantVal fromValue(final Value v) {
- assert v != null : "null v";
- final Block b = v.asBlock();
- switch (b.getTag()) {
- case 0: return new LongValue(b.get(0).asBlock().asInt64());
- case 1: return new FloatValue((float) b.get(0).asBlock().asDouble());
- case 2: return new DoubleValue(b.get(0).asBlock().asDouble());
- case 3: return new BooleanValue(b.get(0) == Value.TRUE);
- case 4: return new ByteValue((byte) b.get(0).asLong());
- case 5: return new CharValue((char) b.get(0).asLong());
- case 6: return new ShortValue((short) b.get(0).asLong());
- case 7: return new IntegerValue(b.get(0).asBlock().asInt32());
- case 8: return new StringValue(API.stringOfUTF8(b.get(0)));
- default:
- assert false : "invalid tag";
- return null;
- } // end switch
- } // end method 'fromValue(Value)'
-
- } // end inner-class 'ConstantVal'
-
- /**
- * Represents a long value embedded inside an attribute.
- */
- public static final class LongValue extends ConstantVal {
-
- /** The underlying value. */
- private final long value;
-
- /**
- * Constructs a long value.
- * @param v value
- */
- public LongValue(final long v) {
- this.value = v;
- } // end constructor(long)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public long getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0, Helper.createInt64(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final String toString() {
- return "LongValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final int hashCode() {
- return (int) this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof LongValue) {
- final LongValue that = (LongValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'LongValue'
-
- /**
- * Represents a float value embedded inside an attribute.
- */
- public static final class FloatValue extends ConstantVal {
-
- /** The underlying value. */
- private final float value;
-
- /**
- * Constructs a float value.
- * @param v value
- */
- public FloatValue(final float v) {
- this.value = v;
- } // end constructor(float)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public float getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(1, Helper.createFloat(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final String toString() {
- return "FloatValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final int hashCode() {
- return (int) this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof FloatValue) {
- final FloatValue that = (FloatValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'FloatValue'
-
- /**
- * Represents a double value embedded inside an attribute.
- */
- public static final class DoubleValue extends ConstantVal {
-
- /** The underlying value. */
- private final double value;
-
- /**
- * Constructs a double value.
- * @param v value
- */
- public DoubleValue(final double v) {
- this.value = v;
- } // end constructor(double)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public double getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(2, Helper.createFloat(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final String toString() {
- return "DoubleValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final int hashCode() {
- return (int) this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof DoubleValue) {
- final DoubleValue that = (DoubleValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'DoubleValue'
-
- /**
- * Represents a boolean value embedded inside an attribute.
- */
- public static final class BooleanValue extends ConstantVal {
-
- /** The underlying value. */
- private final boolean value;
-
- /**
- * Constructs a boolean value.
- * @param v value
- */
- public BooleanValue(final boolean v) {
- this.value = v;
- } // end constructor(boolean)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public boolean getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(3, this.value ? Value.TRUE : Value.FALSE);
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final String toString() {
- return "BooleanValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final int hashCode() {
- return this.value ? 1 : 0;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof BooleanValue) {
- final BooleanValue that = (BooleanValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'BooleanValue'
-
- /**
- * Represents a byte value embedded inside an attribute.
- */
- public static final class ByteValue extends ConstantVal {
-
- /** The underlying value. */
- private final byte value;
-
- /**
- * Constructs a byte value.
- * @param v value
- */
- public ByteValue(final byte v) {
- this.value = v;
- } // end constructor(byte)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public byte getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(4, Value.createFromLong(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final String toString() {
- return "ByteValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final int hashCode() {
- return this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof ByteValue) {
- final ByteValue that = (ByteValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ByteValue'
-
- /**
- * Represents a char value embedded inside an attribute.
- */
- public static final class CharValue extends ConstantVal {
-
- /** The underlying value. */
- private final char value;
-
- /**
- * Constructs a char value.
- * @param v value
- */
- public CharValue(final char v) {
- this.value = v;
- } // end constructor(char)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public char getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(5, Value.createFromLong(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final String toString() {
- return "CharValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final int hashCode() {
- return this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof CharValue) {
- final CharValue that = (CharValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'CharValue'
-
- /**
- * Represents a short value embedded inside an attribute.
- */
- public static final class ShortValue extends ConstantVal {
-
- /** The underlying value. */
- private final short value;
-
- /**
- * Constructs a short value.
- * @param v value
- */
- public ShortValue(final short v) {
- this.value = v;
- } // end constructor(short)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public short getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(6, Value.createFromLong(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final String toString() {
- return "ShortValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final int hashCode() {
- return this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof ShortValue) {
- final ShortValue that = (ShortValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ShortValue'
-
- /**
- * Represents a integer value embedded inside an attribute.
- */
- public static final class IntegerValue extends ConstantVal {
-
- /** The underlying value. */
- private final int value;
-
- /**
- * Constructs a integer value.
- * @param v value
- */
- public IntegerValue(final int v) {
- this.value = v;
- } // end constructor(integer)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public int getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(7, Helper.createInt32(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final String toString() {
- return "IntegerValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final int hashCode() {
- return this.value;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof IntegerValue) {
- final IntegerValue that = (IntegerValue) obj;
- return this.value == that.value;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'IntegerValue'
-
- /**
- * Represents a string value embedded inside an attribute.
- */
- public static final class StringValue extends ConstantVal {
-
- /** The underlying value. */
- private final String value;
-
- /**
- * Constructs a string value.
- * @param v value - should not be null
- */
- public StringValue(final String v) {
- assert v != null : "null v";
- this.value = v;
- } // end constructor(String)
-
- /**
- * Returns the underlying value.
- * @return the underlying value
- */
- public String getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(8, API.createUTF8(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final String toString() {
- return "StringValue(" + this.value + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final int hashCode() {
- return this.value.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof StringValue) {
- final StringValue that = (StringValue) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'StringValue'
-
- /**
- * This class implements elements to be used in an exception table.
- */
- public static final class ExceptionTableElement implements ToValue {
-
- /** The starting offset of protected code. */
- private final int start;
-
- /** The ending offset of protected code. */
- private final int end;
-
- /** The handler offset. */
- private final int handler;
-
- /** The exception to be caught (null means all). */
- private final String exception;
-
- /**
- * Constructs an exception table element from offsets and name.
- * @param s starting offset of protected code - should be in 0..65535
- * @param e ending offset of protected code - should be in 0..65535
- * @param h handler offset - should be in 0..65535
- * @param exn exception to be caught (null means all)
- */
- public ExceptionTableElement(final int s,
- final int e,
- final int h,
- final String exn) {
- assert (s >= 0) && (s <= 65535) : "invalid s";
- assert (e >= 0) && (e <= 65535) : "invalid e";
- assert (h >= 0) && (h <= 65535) : "invalid h";
- this.start = s;
- this.end = e;
- this.handler = h;
- this.exception = exn;
- } // end constructor(int, int, int, String)
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Value exn;
- if (this.exception == null) {
- exn = Value.ZERO;
- } else {
- exn = Value.createFromBlock(Block.createBlock(0, API.createClassName(this.exception)));
- } // end if/else
- final Block b = Block.createBlock(0,
- Value.createFromLong(this.start),
- Value.createFromLong(this.end),
- Value.createFromLong(this.handler),
- exn);
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * Constructs an instance from a value.
- * @param v value to construct instance from - should not be null
- * @return the corresponding instance
- */
- static ExceptionTableElement fromValue(final Value v) {
- assert v != null : "null v";
- final Block b = v.asBlock();
- return new ExceptionTableElement(b.get(0).asLong(),
- b.get(1).asLong(),
- b.get(2).asLong(),
- b.get(3) == Value.ZERO
- ? null
- : API.stringOfClassName(b.get(3).asBlock().get(0)));
- } // end method 'fromValue(Value)'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final String toString() {
- return "ExceptionTableElement("
- + this.start + ", "
- + this.end + ", "
- + this.handler + ", "
- + this.exception + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final int hashCode() {
- return this.start
- + this.end
- + this.handler
- + (this.exception != null ? this.exception.hashCode() : 0);
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof ExceptionTableElement) {
- final ExceptionTableElement that = (ExceptionTableElement) obj;
- return (this.start == that.start)
- && (this.end == that.end)
- && (this.handler == that.handler)
- && API.nullOrEquals(this.exception, that.exception);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ExceptionTableElement'
-
- /**
- * This class implements a code value.
- */
- public static final class CodeValue implements ToValue {
-
- /** Maximum stack size. */
- private final int maxStack;
-
- /** Maximum locals size. */
- private final int maxLocals;
-
- /** Instructions. */
- private final List extends Instruction> instructions;
-
- /** Exception table. */
- private final List exceptionTable;
-
- /** Attributes. */
- private final List extends Attribute> attributes;
-
- /**
- * Constructs a code value.
- * @param ms maximum stack size - should be in 0..65535
- * @param ml maximum locals size - should be in 0..65535
- * @param c instructions - should not be null
- * @param e exception table - should not be null
- * @param a attribute - should not be null,
- * should also be code attributes
- */
- public CodeValue(final int ms,
- final int ml,
- final List extends Instruction> c,
- final List e,
- final List extends Attribute> a) {
- assert (ms >= 0) && (ms <= 65535) : "invalid ms";
- assert (ml >= 0) && (ml <= 65535) : "invalid ml";
- assert c != null : "null c";
- assert e != null : "null e";
- assert a != null : "null a";
- assert areCodeAttributes(a) : "invalid attribute";
- this.maxStack = ms;
- this.maxLocals = ml;
- this.instructions = new LinkedList(c);
- this.exceptionTable = new LinkedList(e);
- this.attributes = new LinkedList(a);
- } // end constructor(int, int, List extends Instruction>, ...)
-
- /**
- * Returns the maximum stack size.
- * @return the maximum stack size
- */
- public int getMaxStack() {
- return this.maxStack;
- } // end method 'getMaxStack()'
-
- /**
- * Returns the maximum locals size.
- * @return the maximum locals size
- */
- public int getMaxLocals() {
- return this.maxLocals;
- } // end method 'getMaxLocals()'
-
- /**
- * Returns the instruction list.
- * @return the instruction list
- */
- public List extends Instruction> getInstructions() {
- return new LinkedList(this.instructions);
- } // end method 'getInstructions()'
-
- /**
- * Returns the exception table.
- * @return the exception table
- */
- public List getExceptionTable() {
- return new LinkedList(this.exceptionTable);
- } // end method 'getExceptionTable()'
-
- /**
- * Returns the attributes.
- * @return the attributes
- */
- public List extends Attribute> getAttributes() {
- return new LinkedList(this.attributes);
- } // end method 'getAttributes()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("CodeValue(maxstack=");
- sb.append(this.maxStack);
- sb.append(",maxlocals=");
- sb.append(this.maxLocals);
- sb.append(",instructions=");
- sb.append(this.instructions.toString());
- sb.append(",exceptiontable=");
- sb.append(this.exceptionTable.toString());
- sb.append(",attributes=");
- sb.append(this.attributes.toString());
- sb.append(")");
- return sb.toString();
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof CodeValue) {
- final CodeValue that = (CodeValue) obj;
- return this.maxStack == that.maxStack
- && this.maxLocals == that.maxLocals
- && this.instructions.equals(that.instructions)
- && this.exceptionTable.equals(that.exceptionTable)
- && this.attributes.equals(that.attributes);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.maxStack
- + this.maxLocals
- + this.instructions.hashCode()
- + this.exceptionTable.hashCode()
- + this.attributes.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(5, 0);
- b.set(0, Value.createFromLong(this.maxStack));
- b.set(1, Value.createFromLong(this.maxLocals));
- b.set(2, API.encodeList(this.instructions));
- b.set(3, API.encodeList(this.exceptionTable));
- b.set(4, API.encodeList(this.attributes));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * Constructs an instance from a value.
- * @param v value to construct instance from - should not be null
- * @return the corresponding instance
- */
- static CodeValue fromValue(final Value v) {
- assert v != null : "null v";
- final Block b = v.asBlock();
- final List instrs = new LinkedList();
- for (Value i : API.decodeList(b.get(2))) {
- instrs.add(Instruction.fromValue(i));
- } // end for
- final List exns = new LinkedList();
- for (Value e : API.decodeList(b.get(3))) {
- exns.add(ExceptionTableElement.fromValue(e));
- } // end for
- final List attrs = new LinkedList();
- for (Value a : API.decodeList(b.get(4))) {
- attrs.add(Attribute.fromValue(a));
- } // end for
- return new CodeValue(b.get(0).asLong(),
- b.get(1).asLong(),
- instrs,
- exns,
- attrs);
- } // end method 'fromValue(Value)'
-
- } // end inner-class 'CodeValue'
-
- /**
- * This class represents verification type infos used in stack frames.
- */
- public static abstract class VerificationTypeInfo implements ToValue {
-
- /** The tag for 'type' elements. */
- private static final int TAG_TYPE = Hash.hashVariant("Class_or_interface").asLong();
-
- /** The tag for 'array' elements. */
- private static final int TAG_ARRAY = Hash.hashVariant("Array_type").asLong();
-
- /**
- * This class represents verification type infos with no parameter.
- */
- private static final class Simple extends VerificationTypeInfo {
-
- /** Type name. */
- private final String name;
-
- /** Type code. */
- private final int code;
-
- /**
- * Constructs a verification type from name and code.
- * @param n type name - should not be null
- * @param c type code
- */
- private Simple(final String n, final int c) {
- assert n != null : "null n";
- this.name = n;
- this.code = c;
- } // end constructor(String, int)
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- return Value.createFromLong(this.code);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return this.name;
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.code;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Simple) {
- final Simple that = (Simple) obj;
- return this.code == that.code;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Simple'
-
- /** Verification type info for "top". */
- public static final VerificationTypeInfo TopVariableInfo = new Simple("TopVariableInfo", 0);
-
- /** Verification type info for "integer". */
- public static final VerificationTypeInfo IntegerVariableInfo = new Simple("IntegerVariableInfo", 1);
-
- /** Verification type info for "float". */
- public static final VerificationTypeInfo FloatVariableInfo = new Simple("FloatVariableInfo", 2);
-
- /** Verification type info for "long". */
- public static final VerificationTypeInfo LongVariableInfo = new Simple("LongVariableInfo", 3);
-
- /** Verification type info for "double". */
- public static final VerificationTypeInfo DoubleVariableInfo = new Simple("DoubleVariableInfo", 4);
-
- /** Verification type info for "null". */
- public static final VerificationTypeInfo NullVariableInfo = new Simple("NullVariableInfo", 5);
-
- /** Verification type info for "uninitialized this". */
- public static final VerificationTypeInfo UninitializedThisVariableInfo = new Simple("UninitializedThisVariableInfo", 6);
-
- /** Verification type info for "object". */
- public static final class ObjectVariableInfo extends VerificationTypeInfo {
-
- /** Parameter. */
- private final Object param;
-
- /**
- * Constructs an instance of the "object" variable info.
- * @param t type name - should not be null
- */
- public ObjectVariableInfo(final Instruction.TypeName t) {
- assert t != null : "null t";
- this.param = t;
- } // end constructor(Instruction.TypeName)
-
- /**
- * Constructs an instance of the "object" variable info.
- * @param d descriptor - should not be null
- */
- public ObjectVariableInfo(final Descriptor.Array d) {
- assert d != null : "null d";
- this.param = d;
- } // end constructor(Descriptor.Array)
-
- /**
- * Returns the underlying type name.
- * @return the underlying type name if any, null otherwise
- */
- public Instruction.TypeName getTypeName() {
- return this.param instanceof Instruction.TypeName
- ? (Instruction.TypeName) this.param
- : null;
- } // end method 'getTypeName()'
-
- /**
- * Returns the underlying descriptor.
- * @return the underlying descriptor if any, null otherwise
- */
- public Descriptor.Array getDescriptor() {
- return this.param instanceof Descriptor.Array
- ? (Descriptor.Array) this.param
- : null;
- } // end method 'getDescriptor()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- if (this.param instanceof Instruction.TypeName) {
- final Block b = Block.createBlock(1, 0);
- b.set(0, Instruction.wrap("Class_or_interface", ((Instruction.TypeName) this.param).toValue()));
- return Value.createFromBlock(b);
- } else {
- final Block b = Block.createBlock(1, 0);
- b.set(0, Instruction.wrap("Array", ((Instruction.TypeName) this.param).toValue()));
- return Value.createFromBlock(b);
- } // end if/else
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "ObjectVariableInfo(" + this.param.toString() + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.param.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ObjectVariableInfo) {
- final ObjectVariableInfo that = (ObjectVariableInfo) obj;
- return this.param.equals(that.param);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ObjectVariableInfo'
-
- /** Verification type info for "uninitialized". */
- public static final class UninitializedVariableInfo extends VerificationTypeInfo {
-
- /** Code offset of object creation. */
- private final int offset;
-
- /**
- * Constructs an instance of the "uninitialized" variable info.
- * @param o code offset of object creation - should be in 0..65535
- */
- public UninitializedVariableInfo(final int o) {
- assert (o >= 0) && (o <= 65535) : "invalid o";
- this.offset = o;
- } // end constructor(int)
-
- /**
- * Returns the code offset of object creation.
- * @return the code offset of object creation
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(1, Value.createFromLong(this.offset));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "UninitializedVariableInfo(" + this.offset + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof UninitializedVariableInfo) {
- final UninitializedVariableInfo that = (UninitializedVariableInfo) obj;
- return this.offset == that.offset;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'UninitializedVariableInfo'
-
- private VerificationTypeInfo() {
- } // end empty constructor
-
- /**
- * Constructs an instance from a value.
- * @param v value to construct instance from - should not be null
- * @return the corresponding instance
- */
- @SuppressWarnings("fallthrough")
- static VerificationTypeInfo fromValue(final Value v) {
- assert v != null : "null v";
- if (v.isLong()) {
- switch (v.asLong()) {
- case 0: return TopVariableInfo;
- case 1: return IntegerVariableInfo;
- case 2: return FloatVariableInfo;
- case 3: return LongVariableInfo;
- case 4: return DoubleVariableInfo;
- case 5: return NullVariableInfo;
- case 6: return UninitializedThisVariableInfo;
- default:
- assert false : "invalid tag";
- return null;
- } // end switch
- } else {
- final Block b = v.asBlock();
- switch (b.getTag()) {
- case 0: if (b.get(0).asBlock().get(0).asLong() == TAG_TYPE) return new ObjectVariableInfo(Instruction.TypeName.fromValue(b.get(0).asBlock().get(1))); else if (b.get(0).asBlock().get(0).asLong() == TAG_ARRAY) return new ObjectVariableInfo((Descriptor.Array) Descriptor.fromValue(b.get(0).asBlock().get(1)));
- case 1: return new UninitializedVariableInfo((short) b.get(0).asBlock().get(1).asLong());
- default:
- assert false : "invalid tag";
- return null;
- } // end switch
- } // end if/else
- } // end method 'fromValue(Value)'
-
- } // end inner-class 'VerificationTypeInfo'
-
- /**
- * This class represents stack map frames.
- */
- public static abstract class StackMapFrame implements ToValue {
-
- /** Code offset. */
- protected final int offset;
-
- /**
- * Constructs an instance from a code offset.
- * @param o code offset - should be in 0..65535
- */
- private StackMapFrame(final int o) {
- assert (o >= 0) && (o <= 65535) : "invalid o";
- this.offset = o;
- } // end constructor(int)
-
- /**
- * Returns the code offset.
- * @return the code offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /** Stack map frame for 'same'. */
- public static final class Same extends StackMapFrame {
-
- /**
- * Constructs an instance from a code offset.
- * @param o code offset - should be in 0..65535
- */
- public Same(final int o) {
- super(o);
- } // end constructor(int)
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0, Value.createFromLong(this.offset));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "Same(" + this.offset + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Same) {
- final Same that = (Same) obj;
- return this.offset == that.offset;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Same'
-
- /** Stack map frame for 'same locals, 1 stack item'. */
- public static final class SameLocals1StackItem extends StackMapFrame {
-
- /** Type of stack item. */
- private final VerificationTypeInfo type;
-
- /**
- * Constructs an instance from a code offset.
- * @param o code offset - should be in 0..65535
- * @param t type of stack item - should not be null
- */
- public SameLocals1StackItem(final int o, final VerificationTypeInfo t) {
- super(o);
- assert t != null : "null t";
- this.type = t;
- } // end constructor(int, VerificationTypeInfo)
-
- /**
- * Returns the type of the stack item.
- * @return the type of the stack item
- */
- public VerificationTypeInfo getType() {
- return this.type;
- } // end method 'getType()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(1, Value.createFromLong(this.offset), this.type.toValue());
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "SameLocals1StackItem(" + this.offset + ", " + this.type + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.type.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof SameLocals1StackItem) {
- final SameLocals1StackItem that = (SameLocals1StackItem) obj;
- return (this.offset == that.offset)
- && this.type.equals(that.type);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'SameLocals1StackItem'
-
- /** Stack map frame for 'chop1'. */
- public static final class Chop1 extends StackMapFrame {
-
- /**
- * Constructs an instance from a code offset.
- * @param o code offset - should be in 0..65535
- */
- public Chop1(final int o) {
- super(o);
- } // end constructor(int)
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(2, Value.createFromLong(this.offset));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "Chop1(" + this.offset + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Chop1) {
- final Chop1 that = (Chop1) obj;
- return this.offset == that.offset;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Chop1'
-
- /** Stack map frame for 'chop2'. */
- public static final class Chop2 extends StackMapFrame {
-
- /**
- * Constructs an instance from a code offset.
- * @param o code offset - should be in 0..65535
- */
- public Chop2(final int o) {
- super(o);
- } // end constructor(int)
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(3, Value.createFromLong(this.offset));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "Chop2(" + this.offset + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Chop2) {
- final Chop2 that = (Chop2) obj;
- return this.offset == that.offset;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Chop2'
-
- /** Stack map frame for 'chop3'. */
- public static final class Chop3 extends StackMapFrame {
-
- /**
- * Constructs an instance from a code offset.
- * @param o code offset - should be in 0..65535
- */
- public Chop3(final int o) {
- super(o);
- } // end constructor(int)
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(4, Value.createFromLong(this.offset));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "Chop3(" + this.offset + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Chop3) {
- final Chop3 that = (Chop3) obj;
- return this.offset == that.offset;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Chop3'
-
- /** Stack map frame for 'append1'. */
- public static final class Append1 extends StackMapFrame {
-
- /** Type of stack item. */
- private final VerificationTypeInfo type;
-
- /**
- * Constructs an instance from a code offset.
- * @param o code offset - should be in 0..65535
- * @param t type of stack item - should not be null
- */
- public Append1(final int o, final VerificationTypeInfo t) {
- super(o);
- assert t != null : "null t";
- this.type = t;
- } // end constructor(int, VerificationTypeInfo)
-
- /**
- * Returns the type of the stack item.
- * @return the type of the stack item
- */
- public VerificationTypeInfo getType() {
- return this.type;
- } // end method 'getType()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(5, Value.createFromLong(this.offset), this.type.toValue());
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "Append1(" + this.offset + ", " + this.type + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.type.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Append1) {
- final Append1 that = (Append1) obj;
- return (this.offset == that.offset)
- && this.type.equals(that.type);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Append1'
-
- /** Stack map frame for 'append2'. */
- public static final class Append2 extends StackMapFrame {
-
- /** Type of first added stack item. */
- private final VerificationTypeInfo type1;
-
- /** Type of second added stack item. */
- private final VerificationTypeInfo type2;
-
- /**
- * Constructs an instance from a code offset.
- * @param o code offset - should be in 0..65535
- * @param t1 type of stack item - should not be null
- * @param t2 type of stack item - should not be null
- */
- public Append2(final int o,
- final VerificationTypeInfo t1,
- final VerificationTypeInfo t2) {
- super(o);
- assert t1 != null : "null t1";
- assert t2 != null : "null t2";
- this.type1 = t1;
- this.type2 = t2;
- } // end constructor(int, VerificationTypeInfo, VerificationTypeInfo)
-
- /**
- * Returns the type of the first added stack item.
- * @return the type of the first added stack item
- */
- public VerificationTypeInfo getType1() {
- return this.type1;
- } // end method 'getType1()'
-
- /**
- * Returns the type of the second added stack item.
- * @return the type of the second added stack item
- */
- public VerificationTypeInfo getType2() {
- return this.type2;
- } // end method 'getType2()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(6, Value.createFromLong(this.offset), this.type1.toValue(), this.type2.toValue());
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "Append2(" + this.offset + ", " + this.type1 + ", " + this.type2 + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.type1.hashCode() + this.type2.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Append2) {
- final Append2 that = (Append2) obj;
- return (this.offset == that.offset)
- && this.type1.equals(that.type1)
- && this.type2.equals(that.type2);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Append2'
-
- /** Stack map frame for 'append3'. */
- public static final class Append3 extends StackMapFrame {
-
- /** Type of first added stack item. */
- private final VerificationTypeInfo type1;
-
- /** Type of second added stack item. */
- private final VerificationTypeInfo type2;
-
- /** Type of third added stack item. */
- private final VerificationTypeInfo type3;
-
- /**
- * Constructs an instance from a code offset.
- * @param o code offset - should be in 0..65535
- * @param t1 type of stack item - should not be null
- * @param t2 type of stack item - should not be null
- * @param t3 type of stack item - should not be null
- */
- public Append3(final int o,
- final VerificationTypeInfo t1,
- final VerificationTypeInfo t2,
- final VerificationTypeInfo t3) {
- super(o);
- assert t1 != null : "null t1";
- assert t2 != null : "null t2";
- assert t3 != null : "null t3";
- this.type1 = t1;
- this.type2 = t2;
- this.type3 = t3;
- } // end constructor(int, VerificationTypeInfo, VerificationTypeInfo, VerificationTypeInfo)
-
- /**
- * Returns the type of the first added stack item.
- * @return the type of the first added stack item
- */
- public VerificationTypeInfo getType1() {
- return this.type1;
- } // end method 'getType1()'
-
- /**
- * Returns the type of the second added stack item.
- * @return the type of the second added stack item
- */
- public VerificationTypeInfo getType2() {
- return this.type2;
- } // end method 'getType2()'
-
- /**
- * Returns the type of the third added stack item.
- * @return the type of the third added stack item
- */
- public VerificationTypeInfo getType3() {
- return this.type3;
- } // end method 'getType3()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(7, Value.createFromLong(this.offset), this.type1.toValue(), this.type2.toValue(), this.type3.toValue());
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "Append3(" + this.offset + ", " + this.type1 + ", " + this.type2 + ", " + this.type3 + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.type1.hashCode() + this.type2.hashCode() + this.type3.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Append3) {
- final Append3 that = (Append3) obj;
- return (this.offset == that.offset)
- && this.type1.equals(that.type1)
- && this.type2.equals(that.type2)
- && this.type3.equals(that.type3);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Append3'
-
- /** Stack map frame for 'full'. */
- public static final class Full extends StackMapFrame {
-
- /** Type of first added stack item. */
- private final List extends VerificationTypeInfo> locals;
-
- /** Type of second added stack item. */
- private final List extends VerificationTypeInfo> operands;
-
- /**
- * Constructs an instance from a code offset.
- * @param o code offset - should be in 0..65535
- * @param locs types of locals - should not be null
- * @param ops types of stack operands - should not be null
- */
- public Full(final int o,
- final List extends VerificationTypeInfo> locs,
- final List extends VerificationTypeInfo> ops) {
- super(o);
- assert locs != null : "null locs";
- assert ops != null : "null ops";
- this.locals = new LinkedList(locs);
- this.operands = new LinkedList(ops);
- } // end constructor(int, List extends VerificationTypeInfo>, List extends VerificationTypeInfo>)
-
- /**
- * Returns the types of the locals.
- * @return the types of the locals
- */
- public List extends VerificationTypeInfo> getLocals() {
- return new LinkedList(this.locals);
- } // end method 'getLocals()'
-
- /**
- * Returns the types of the operands.
- * @return the types of the operands
- */
- public List extends VerificationTypeInfo> getOperands() {
- return new LinkedList(this.operands);
- } // end method 'getOperands()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(8, Value.createFromLong(this.offset), API.encodeList(this.locals), API.encodeList(this.operands));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "Full(" + this.offset + ", " + this.locals + ", " + this.operands + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.locals.hashCode() + this.operands.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Full) {
- final Full that = (Full) obj;
- return (this.offset == that.offset)
- && this.locals.equals(that.locals)
- && this.operands.equals(that.operands);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Full'
-
- /**
- * Constructs an instance from a value.
- * @param v value to construct instance from - should not be null
- * @return the corresponding instance
- */
- static StackMapFrame fromValue(final Value v) {
- assert v != null : "null v";
- final Block b = v.asBlock();
- switch (b.getTag()) {
- case 0: return new Same(b.get(0).asLong());
- case 1: return new SameLocals1StackItem(b.get(0).asLong(), VerificationTypeInfo.fromValue(b.get(1)));
- case 2: return new Chop1(b.get(0).asLong());
- case 3: return new Chop2(b.get(0).asLong());
- case 4: return new Chop3(b.get(0).asLong());
- case 5: return new Append1(b.get(0).asLong(), VerificationTypeInfo.fromValue(b.get(1)));
- case 6: return new Append2(b.get(0).asLong(), VerificationTypeInfo.fromValue(b.get(1)), VerificationTypeInfo.fromValue(b.get(2)));
- case 7: return new Append3(b.get(0).asLong(), VerificationTypeInfo.fromValue(b.get(1)), VerificationTypeInfo.fromValue(b.get(2)), VerificationTypeInfo.fromValue(b.get(3)));
- case 8:
- final List locals = new LinkedList();
- for (Value l : API.decodeList(b.get(1))) {
- locals.add(VerificationTypeInfo.fromValue(l));
- } // end for
- final List operands = new LinkedList();
- for (Value o : API.decodeList(b.get(2))) {
- operands.add(VerificationTypeInfo.fromValue(o));
- } // end for
- return new Full(b.get(0).asLong(), locals, operands);
- default:
- assert false : "invalid tag";
- return null;
- } // end switch
- } // end method 'fromValue(Value)'
-
- } // end inner-class 'StackMapFrame'
-
- /** Whether the attribute can be a field attribute. */
- private final boolean isField;
-
- /** Whether the attribute can be a method attribute. */
- private final boolean isMethod;
-
- /** Whether the attribute can be a class attribute. */
- private final boolean isClass;
-
- /** Whether the attribute can be a code attribute. */
- private final boolean isCode;
-
- /**
- * Constructs an attribute.
- * @param f whether the attribute can be a field attribute
- * @param m whether the attribute can be a method attribute
- * @param c whether the attribute can be a class attribute
- * @param d whether the attribute can be a code attribute
- */
- private Attribute(final boolean f,
- final boolean m,
- final boolean c,
- final boolean d) {
- this.isField = f;
- this.isMethod = m;
- this.isClass = c;
- this.isCode = d;
- } // end constructor(boolean, boolean, boolean, boolean)
-
- /**
- * Tests whether the attribute can be a field attribute.
- * @return true if the attribute can be a field attribute,
- * false otherwise
- */
- public final boolean isFieldAttribute() {
- return this.isField;
- } // end method 'isFieldAttribute()'
-
- /**
- * Tests whether the attribute can be a method attribute.
- * @return true if the attribute can be a method attribute,
- * false otherwise
- */
- public final boolean isMethodAttribute() {
- return this.isMethod;
- } // end method 'isMethodAttribute()'
-
- /**
- * Tests whether the attribute can be a class attribute.
- * @return true if the attribute can be a class attribute,
- * false otherwise
- */
- public final boolean isClassAttribute() {
- return this.isClass;
- } // end method 'isClassAttribute()'
-
- /**
- * Tests whether the attribute can be a code attribute.
- * @return true if the attribute can be a code attribute,
- * false otherwise
- */
- public final boolean isCodeAttribute() {
- return this.isCode;
- } // end method 'isCodeAttribute()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final String toString() {
- final Class c = this.getClass();
- if (c.equals(Deprecated.class)) {
- return "Deprecated";
- } else if (c.equals(Synthetic.class)) {
- return "Synthetic";
- } else {
- return c.getSimpleName() + "(-)";
- } // end if/elsif/else
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final int hashCode() {
- return this.getClass().hashCode();
- } // end method 'toString()'
-
- /**
- * Tests whether a list contains only field attributes.
- * @param l list to test - should not be null
- * @return true if the list contains only field attributes,
- * false otherwise
- */
- public static boolean areFieldAttributes(final List extends Attribute> l) {
- assert l != null : "null l";
- for (Attribute a : l) {
- if (!a.isFieldAttribute()) {
- return false;
- } // end if
- } // end for
- return true;
- } // end method 'areFieldAttributes(List extends Attribute>)'
-
- /**
- * Tests whether a list contains only method attributes.
- * @param l list to test - should not be null
- * @return true if the list contains only method attributes,
- * false otherwise
- */
- public static boolean areMethodAttributes(final List extends Attribute> l) {
- assert l != null : "null l";
- for (Attribute a : l) {
- if (!a.isMethodAttribute()) {
- return false;
- } // end if
- } // end for
- return true;
- } // end method 'areMethodAttributes(List extends Attribute>)'
-
- /**
- * Tests whether a list contains only class attributes.
- * @param l list to test - should not be null
- * @return true if the list contains only class attributes,
- * false otherwise
- */
- public static boolean areClassAttributes(final List extends Attribute> l) {
- assert l != null : "null l";
- for (Attribute a : l) {
- if (!a.isClassAttribute()) {
- return false;
- } // end if
- } // end for
- return true;
- } // end method 'areClassAttributes(List extends Attribute>)'
-
- /**
- * Tests whether a list contains only code attributes.
- * @param l list to test - should not be null
- * @return true if the list contains only code attributes,
- * false otherwise
- */
- public static boolean areCodeAttributes(final List extends Attribute> l) {
- assert l != null : "null l";
- for (Attribute a : l) {
- if (!a.isCodeAttribute()) {
- return false;
- } // end if
- } // end for
- return true;
- } // end method 'areCodeAttributes(List extends Attribute>)'
-
- /**
- * This class implements an 'AnnotationDefault' attribute.
- */
- public static final class AnnotationDefault extends Attribute {
-
- /** Attribute value. */
- private final Annotation.ElementValue value;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public AnnotationDefault(final Annotation.ElementValue v) {
- super(false, true, false, false);
- assert v != null : "null v";
- this.value = v;
- } // end constructor(Annotation.ElementValue)
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public Annotation.ElementValue getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0,
- HASH_ANNOTATION_DEFAULT,
- this.value.toValue());
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof AnnotationDefault) {
- final AnnotationDefault that = (AnnotationDefault) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'AnnotationDefault'
-
- /**
- * This class implements a 'Code' attribute.
- */
- public static final class Code extends Attribute {
-
- /** Attribute value. */
- private final CodeValue value;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public Code(final CodeValue v) {
- super(false, true, false, false);
- assert v != null : "null v";
- this.value = v;
- } // end constructor(CodeValue)
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public CodeValue getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0,
- HASH_CODE,
- this.value.toValue());
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof Code) {
- final Code that = (Code) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Code'
-
- /**
- * This class implements a 'ConstantValue' attribute.
- */
- public static final class ConstantValue extends Attribute {
-
- /** Attribute value. */
- private final ConstantVal value;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public ConstantValue(final ConstantVal v) {
- super(true, false, false, false);
- assert v != null : "null v";
- this.value = v;
- } // end constructor(ConstantVal)
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public ConstantVal getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0,
- HASH_CONSTANT_VALUE,
- this.value.toValue());
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof ConstantValue) {
- final ConstantValue that = (ConstantValue) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ConstantValue'
-
- /**
- * This class implements a 'Deprecated' attribute.
- */
- public static final class Deprecated extends Attribute {
-
- /**
- * Constructs an attribute.
- */
- public Deprecated() {
- super(true, true, true, false);
- } // end empty constructor
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- return HASH_DEPRECATED;
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof Deprecated) {
- return true;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Deprecated'
-
- /**
- * This class implements an 'EnclosingMethod' attribute.
- */
- public static final class EnclosingMethod extends Attribute {
-
- /** Class name. */
- private final String className;
-
- /** Method name. */
- private final String methodName;
-
- /** Method return type descriptor. */
- private final Descriptor returnType;
-
- /** Method parameter type descriptors. */
- private final List extends Descriptor> parameterTypes;
-
- /**
- * Constructs an attribute.
- * @param cn class name - should not be null
- * @param mn method name - should not be null
- * @param mr method return type descriptor - should not be null
- * @param mp method parameter type descriptors - should not be null,
- * should also be non-void descriptors
- * @throws BaristaException if one of the descriptors is not a valid descriptor
- * @throws BaristaException if one of the attributes is not a valid attribute
- */
- public EnclosingMethod(final String cn,
- final String mn,
- final Descriptor mr,
- final List extends Descriptor> mp)
- throws BaristaException {
- super(false, false, true, false);
- assert cn != null : "null cn";
- assert mn != null : "null mn";
- assert mr != null : "null mr";
- assert mp != null : "null mp";
- if (!mr.isFieldDescriptor()) {
- throw new BaristaException("invalid descriptor for return type");
- } // end if
- if (!Descriptor.areFieldDescriptors(mp)) {
- throw new BaristaException("invalid descriptor for parameter type");
- } // end fi
- this.className = cn;
- this.methodName = mn;
- this.returnType = mr;
- this.parameterTypes = new LinkedList(mp);
- } // end constructor(String, String, Descriptor, List extends Descriptor>)
-
- /**
- * Constructs an attribute.
- * @param cn class name - should not be null
- */
- public EnclosingMethod(final String cn) {
- super(false, false, true, false);
- assert cn != null : "null cn";
- this.className = cn;
- this.methodName = null;
- this.returnType = null;
- this.parameterTypes = null;
- } // end constructor(String)
-
- /**
- * Returns the class name.
- * @return the class name
- */
- public String getClassName() {
- return this.className;
- } // end method 'getClassName()'
-
- /**
- * Returns the method name.
- * @return the method name
- */
- public String getMethodName() {
- return this.methodName;
- } // end method 'getMethodName()'
-
- /**
- * Returns the method return type.
- * @return the method return type
- */
- public Descriptor getReturnType() {
- return this.returnType;
- } // end method 'getReturnType()'
-
- /**
- * Returns the method parameter types.
- * @return the method parameter types
- */
- public List extends Descriptor> getParameterTypes() {
- return new LinkedList(this.parameterTypes);
- } // end method 'getParameterTypes()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Value o;
- if (this.methodName == null) {
- o = Value.ZERO;
- } else {
- final Block desc = Block.createBlock(0,
- API.encodeList(this.parameterTypes),
- this.returnType.toValue());
- final Block m = Block.createBlock(0,
- API.createMethodName(this.methodName),
- Value.createFromBlock(desc));
- o = Value.createFromBlock(m);
- } // end if/else
- final Block c = Block.createBlock(0,
- API.createClassName(this.className),
- o);
- final Block b = Block.createBlock(0,
- HASH_ENCLOSING_METHOD,
- Value.createFromBlock(c));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof EnclosingMethod) {
- final EnclosingMethod that = (EnclosingMethod) obj;
- return this.className.equals(that.className)
- && API.nullOrEquals(this.methodName, that.methodName)
- && API.nullOrEquals(this.returnType, that.returnType)
- && API.nullOrEquals(this.parameterTypes, that.parameterTypes);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'EnclosingMethod'
-
- /**
- * This class implements an 'Exceptions' attribute.
- */
- public static final class Exceptions extends Attribute {
-
- /** Attribute value. */
- private final List value;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public Exceptions(final List v) {
- super(false, true, false, false);
- assert v != null : "null v";
- this.value = new LinkedList(v);
- } // end constructor(List)
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public List getValue() {
- return new LinkedList(this.value);
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final List l = new LinkedList();
- for (String s : this.value) {
- l.add(API.createClassName(s));
- } // end value
- final Block b = Block.createBlock(0,
- HASH_EXCEPTIONS,
- API.encodeValueList(l));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof Exceptions) {
- final Exceptions that = (Exceptions) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Exceptions'
-
- /**
- * This class implements an 'InnerClasses' attribute.
- */
- public static final class InnerClasses extends Attribute {
-
- /** Inner-class names. */
- private final List inners;
-
- /** Outer-class names. */
- private final List outers;
-
- /** Class names. */
- private final List names;
-
- /** Class flags. */
- private final List< List > flags;
-
- /**
- * Constructs an attribute.
- * all passed lists should have the same size.
- * @param i inner-class names - should not be null
- * @param o outer-class names - should not be null
- * @param n names - should not be null
- * @param f class flags - should not be null,
- * should also be inner-class flags
- * @throws BaristaException if one of the flags is not a valid flag
- */
- public InnerClasses(final List i,
- final List o,
- final List n,
- final List< List > f)
- throws BaristaException {
- super(false, false, true, false);
- assert i != null : "null i";
- assert o != null : "null o";
- assert n != null : "null n";
- assert f != null : "null f";
- for (List l : f) {
- if (!AccessFlag.areInnerClassFlags(l)) {
- throw new BaristaException("invalid flag");
- } // endif
- } // end for
- assert i.size() == o.size()
- && o.size() == n.size()
- && n.size() == f.size() : "parameters have different sizes";
- this.inners = new LinkedList(i);
- this.outers = new LinkedList(o);
- this.names = new LinkedList(n);
- this.flags = new LinkedList< List >();
- for (List l : f) {
- this.flags.add(new LinkedList(l));
- } // end for
- } // end constructor(List, List, ...)
-
- /**
- * Returns the inner class names.
- * @return the inner class names
- */
- public List getInners() {
- return new LinkedList(this.inners);
- } // end method 'getInners()'
-
- /**
- * Returns the outer class names.
- * @return the outer class names
- */
- public List getOuters() {
- return new LinkedList(this.outers);
- } // end method 'getOuters()'
-
- /**
- * Returns the class names.
- * @return the class names
- */
- public List getNames() {
- return new LinkedList(this.names);
- } // end method 'getNames()'
-
- /**
- * Returns the class flags.
- * @return the class flags
- */
- public List< List > getFlags() {
- final List< List > res = new LinkedList< List >();
- for (List l : this.flags) {
- res.add(new LinkedList(l));
- } // end for
- return res;
- } // end method 'getFlags()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final List l = new LinkedList();
- final Iterator itInn = this.inners.iterator();
- final Iterator itOut = this.outers.iterator();
- final Iterator itNames = this.names.iterator();
- final Iterator< List > itFlags = this.flags.iterator();
- while (itInn.hasNext() && itOut.hasNext()
- && itNames.hasNext() && itFlags.hasNext()) {
- final String i = itInn.next();
- final String o = itOut.next();
- final String n = itNames.next();
- final List f = itFlags.next();
- final Value bi;
- if (i == null) {
- bi = Value.ZERO;
- } else {
- bi = Value.createFromBlock(Block.createBlock(0, API.createClassName(i)));
- } // end if/else
- final Value bo;
- if (o == null) {
- bo = Value.ZERO;
- } else {
- bo = Value.createFromBlock(Block.createBlock(0, API.createClassName(o)));
- } // end if/else
- final Value bn;
- if (n == null) {
- bn = Value.ZERO;
- } else {
- bn = Value.createFromBlock(Block.createBlock(0, API.createUTF8(n)));
- } // end if/else
- l.add(Value.createFromBlock(Block.createBlock(0, bi, bo, bn, API.encodeList(f))));
- } // end while
- final Block b = Block.createBlock(0,
- HASH_INNER_CLASSES,
- API.encodeValueList(l));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof InnerClasses) {
- final InnerClasses that = (InnerClasses) obj;
- return this.inners.equals(that.inners)
- && this.outers.equals(that.outers)
- && this.names.equals(that.names)
- && this.flags.equals(that.flags);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'InnerClasses'
-
- /**
- * This class implements a 'LineNumberTable' attribute.
- */
- public static final class LineNumberTable extends Attribute {
-
- /** Offets. */
- private final List offsets;
-
- /** Lines. */
- private final List lines;
-
- /**
- * Constructs an attribute.
- * @param ofs offets - should not be null,
- * each value should be in 0..65535
- * @param ln lines - should not be null,
- * each value should be in 0..65535
- */
- public LineNumberTable(final List ofs,
- final List ln) {
- super(false, false, false, true);
- assert ofs != null : "null ofs";
- assert ln != null : "null ln";
- assert ofs.size() == ln.size() : "ofs and ln have different sizes";
- for (int o : ofs) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- } // end for
- for (int l : ln) {
- assert (l >= 0) && (l <= 65535) : "invalid line value";
- } // end for
- this.offsets = new LinkedList(ofs);
- this.lines = new LinkedList(ln);
- } // end constructor(List, List)
-
- /**
- * Returns the offsets.
- * @return the offsets
- */
- public List getOffsets() {
- return new LinkedList(this.offsets);
- } // end method 'getOffsets()'
-
- /**
- * Returns the lines.
- * @return the lines
- */
- public List getLines() {
- return new LinkedList(this.lines);
- } // end method 'getLines()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final List l = new LinkedList();
- final Iterator itOffsets = this.offsets.iterator();
- final Iterator itLines = this.lines.iterator();
- while (itOffsets.hasNext() && itLines.hasNext()) {
- final Block e = Block.createBlock(0,
- Value.createFromLong(itOffsets.next()),
- Value.createFromLong(itLines.next()));
- l.add(Value.createFromBlock(e));
- } // end while
- final Block b = Block.createBlock(0,
- HASH_LINE_NUMBER_TABLE,
- API.encodeValueList(l));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof LineNumberTable) {
- final LineNumberTable that = (LineNumberTable) obj;
- return this.offsets.equals(that.offsets)
- && this.lines.equals(that.lines);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'LineNumberTable'
-
- /**
- * This class implements a 'LocalVariableTable' attribute.
- */
- public static final class LocalVariableTable extends Attribute {
-
- /** Starting offets. */
- private final List starts;
-
- /** Ending offets. */
- private final List ends;
-
- /** Variable names. */
- private final List names;
-
- /** Variable descriptors. */
- private final List extends Descriptor> descriptors;
-
- /** Variable indexes. */
- private final List indexes;
-
- /**
- * Constructs an attribute.
- * all passed lists should have the same size.
- * @param s starting offsets - should not be null,
- * each value should be in 0..65535
- * @param e ending offsets - should not be null,
- * each value should be in 0..65535
- * @param n variable names - should not be null
- * @param d descriptors - should not be null,
- * should also be a non-void descriptor
- * @param i indexes - should not be null,
- * each value should be in 0..65535
- * @throws BaristaException if one of the descriptors is not a valid descriptor
- */
- public LocalVariableTable(final List s,
- final List e,
- final List n,
- final List extends Descriptor> d,
- final List i)
- throws BaristaException {
- super(false, false, false, true);
- assert s != null : "null s";
- assert e != null : "null e";
- assert n != null : "null n";
- assert d != null : "null d";
- assert i != null : "null i";
- if (!Descriptor.areFieldDescriptors(d)) {
- throw new BaristaException("invalid descriptor");
- } // end if
- assert s.size() == e.size()
- && e.size() == n.size()
- && n.size() == d.size()
- && d.size() == i.size() : "parameters have different sizes";
- for (int x : s) {
- assert (x >= 0) && (x <= 65535) : "invalid offset value";
- } // end for
- for (int x : e) {
- assert (x >= 0) && (x <= 65535) : "invalid offset value";
- } // end for
- for (int x : i) {
- assert (x >= 0) && (x <= 65535) : "invalid index value";
- } // end for
- this.starts = new LinkedList(s);
- this.ends = new LinkedList(e);
- this.names = new LinkedList(n);
- this.descriptors = new LinkedList(d);
- this.indexes = new LinkedList(i);
- } // end constructor(List, List, ...)
-
- /**
- * Returns the list of starting offsets.
- * @return the list of starting offsets
- */
- public List getStartingOffsets() {
- return new LinkedList(this.starts);
- } // end method 'getStartingOffsets()'
-
- /**
- * Returns the list of ending offsets.
- * @return the list of ending offsets
- */
- public List getEndingOffsets() {
- return new LinkedList(this.ends);
- } // end method 'getEndingOffsets()'
-
- /**
- * Returns the list of names.
- * @return the list of names
- */
- public List getNames() {
- return new LinkedList(this.names);
- } // end method 'getNames()'
-
- /**
- * Returns the list of descriptors.
- * @return the list of descriptors
- */
- public List extends Descriptor> getDescriptors() {
- return new LinkedList(this.descriptors);
- } // end method 'getDescriptors()'
-
- /**
- * Returns the list of indexes.
- * @return the list of indexes
- */
- public List getIndexes() {
- return new LinkedList(this.indexes);
- } // end method 'getIndexes()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final List l = new LinkedList();
- final Iterator itStarts = this.starts.iterator();
- final Iterator itEnds = this.ends.iterator();
- final Iterator itNames = this.names.iterator();
- final Iterator extends Descriptor> itDescs = this.descriptors.iterator();
- final Iterator itInd = this.indexes.iterator();
- while (itStarts.hasNext() && itEnds.hasNext() && itNames.hasNext()
- && itDescs.hasNext() && itInd.hasNext()) {
- final Block e = Block.createBlock(5, 0);
- e.set(0, Value.createFromLong(itStarts.next()));
- e.set(1, Value.createFromLong(itEnds.next()));
- e.set(2, API.createUTF8(itNames.next()));
- e.set(3, itDescs.next().toValue());
- e.set(4, Value.createFromLong(itInd.next()));
- l.add(Value.createFromBlock(e));
- } // end while
- final Block b = Block.createBlock(0,
- HASH_LOCAL_VARIABLE_TABLE,
- API.encodeValueList(l));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof LocalVariableTable) {
- final LocalVariableTable that = (LocalVariableTable) obj;
- return this.starts.equals(that.starts)
- && this.ends.equals(that.ends)
- && this.names.equals(that.names)
- && this.descriptors.equals(that.descriptors)
- && this.indexes.equals(that.indexes);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'LocalVariableTable'
-
- /**
- * This class implements a 'LocalVariableTypeTable' attribute.
- */
- public static final class LocalVariableTypeTable extends Attribute {
-
- /** Starting offets. */
- private final List starts;
-
- /** Ending offets. */
- private final List ends;
-
- /** Variable names. */
- private final List names;
-
- /** Variable type signatures. */
- private final List signatures;
-
- /** Variable indexes. */
- private final List indexes;
-
- /**
- * Constructs an attribute.
- * all passed lists should have the same size.
- * @param s starting offsets - should not be null,
- * each value should be in 0..65535
- * @param e ending offsets - should not be null,
- * each value should be in 0..65535
- * @param n variable names - should not be null
- * @param t type signatures - should not be null
- * @param i indexes - should not be null,
- * each value should be in 0..65535
- */
- public LocalVariableTypeTable(final List s,
- final List e,
- final List n,
- final List t,
- final List i) {
- super(false, false, false, true);
- assert s != null : "null s";
- assert e != null : "null e";
- assert n != null : "null n";
- assert t != null : "null t";
- assert i != null : "null i";
- assert s.size() == e.size()
- && e.size() == n.size()
- && n.size() == t.size()
- && t.size() == i.size() : "parameters have different sizes";
- for (int x : s) {
- assert (x >= 0) && (x <= 65535) : "invalid offset value";
- } // end for
- for (int x : e) {
- assert (x >= 0) && (x <= 65535) : "invalid offset value";
- } // end for
- for (int x : i) {
- assert (x >= 0) && (x <= 65535) : "invalid index value";
- } // end for
- this.starts = new LinkedList(s);
- this.ends = new LinkedList(e);
- this.names = new LinkedList(n);
- this.signatures = new LinkedList(t);
- this.indexes = new LinkedList(i);
- } // end constructor(List, List, ...)
-
- /**
- * Returns the list of starting offsets.
- * @return the list of starting offsets
- */
- public List getStartingOffsets() {
- return new LinkedList(this.starts);
- } // end method 'getStartingOffsets()'
-
- /**
- * Returns the list of ending offsets.
- * @return the list of ending offsets
- */
- public List getEndingOffsets() {
- return new LinkedList(this.ends);
- } // end method 'getEndingOffsets()'
-
- /**
- * Returns the list of names.
- * @return the list of names
- */
- public List getNames() {
- return new LinkedList(this.names);
- } // end method 'getNames()'
-
- /**
- * Returns the list of type signatures.
- * @return the list of type signatures
- */
- public List getSignatures() {
- return new LinkedList(this.signatures);
- } // end method 'getSignatures()'
-
- /**
- * Returns the list of indexes.
- * @return the list of indexes
- */
- public List getIndexes() {
- return new LinkedList(this.indexes);
- } // end method 'getIndexes()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final List l = new LinkedList();
- final Iterator itStarts = this.starts.iterator();
- final Iterator itEnds = this.ends.iterator();
- final Iterator itNames = this.names.iterator();
- final Iterator itSigns = this.signatures.iterator();
- final Iterator itInd = this.indexes.iterator();
- while (itStarts.hasNext() && itEnds.hasNext() && itNames.hasNext()
- && itSigns.hasNext() && itInd.hasNext()) {
- final Block e = Block.createBlock(5, 0);
- e.set(0, Value.createFromLong(itStarts.next()));
- e.set(1, Value.createFromLong(itEnds.next()));
- e.set(2, API.createUTF8(itNames.next()));
- e.set(3, API.createFieldSignature(itSigns.next()));
- e.set(4, Value.createFromLong(itInd.next()));
- l.add(Value.createFromBlock(e));
- } // end while
- final Block b = Block.createBlock(0,
- HASH_LOCAL_VARIABLE_TYPE_TABLE,
- API.encodeValueList(l));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof LocalVariableTypeTable) {
- final LocalVariableTypeTable that = (LocalVariableTypeTable) obj;
- return this.starts.equals(that.starts)
- && this.ends.equals(that.ends)
- && this.names.equals(that.names)
- && this.signatures.equals(that.signatures)
- && this.indexes.equals(that.indexes);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'LocalVariableTypeTable'
-
- /**
- * This class implements a 'Module' attribute.
- */
- public static final class Module extends Attribute {
-
- /** Attribute name. */
- private final String name;
-
- /** Attribute version. */
- private final String version;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public Module(final String n, final String v) {
- super(false, false, true, false);
- assert n != null : "null n";
- assert v != null : "null v";
- this.name = n;
- this.version = v;
- } // end constructor(String, String)
-
- /**
- * Returns the attribute name.
- * @return the attribute name
- */
- public String getName() {
- return this.name;
- } // end method 'getName()'
-
- /**
- * Returns the attribute version.
- * @return the attribute version
- */
- public String getVersion() {
- return this.version;
- } // end method 'getVersion()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block c = Block.createBlock(0,
- API.createUTF8(this.name),
- API.createUTF8(this.version));
- final Block b = Block.createBlock(0,
- HASH_MODULE,
- Value.createFromBlock(c));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof Module) {
- final Module that = (Module) obj;
- return this.name.equals(that.name)
- && this.version.equals(that.version);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Module'
-
- /**
- * This class implements a 'RuntimeInvisibleAnnotations' attribute.
- */
- public static final class RuntimeInvisibleAnnotations extends Attribute {
-
- /** Attribute value. */
- private final List value;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public RuntimeInvisibleAnnotations(final List v) {
- super(true, true, true, false);
- assert v != null : "null v";
- this.value = new LinkedList(v);
- } // end constructor(List)
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public List getValue() {
- return new LinkedList(this.value);
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0,
- HASH_RUNTIME_INVISIBLE_ANNOTATIONS,
- API.encodeList(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof RuntimeInvisibleAnnotations) {
- final RuntimeInvisibleAnnotations that = (RuntimeInvisibleAnnotations) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'RuntimeInvisibleAnnotations'
-
- /**
- * This class implements a 'RuntimeInvisibleAnnotations' attribute.
- */
- public static final class RuntimeInvisibleTypeAnnotations extends Attribute {
-
- /** Attribute value. */
- private final List value;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public RuntimeInvisibleTypeAnnotations(final List v) {
- super(true, true, true, false);
- assert v != null : "null v";
- this.value = new LinkedList(v);
- } // end constructor(List)
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public List getValue() {
- return new LinkedList(this.value);
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0,
- HASH_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS,
- API.encodeList(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof RuntimeInvisibleTypeAnnotations) {
- final RuntimeInvisibleTypeAnnotations that = (RuntimeInvisibleTypeAnnotations) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'RuntimeInvisibleTypeAnnotations'
-
- /**
- * This class implements a 'RuntimeInvisibleParameterAnnotations' attribute.
- */
- public static final class RuntimeInvisibleParameterAnnotations extends Attribute {
-
- /** Attribute value. */
- private final List< List > value;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public RuntimeInvisibleParameterAnnotations(final List< List > v) {
- super(false, true, false, false);
- assert v != null : "null v";
- this.value = new LinkedList< List >();
- for (List a : v) {
- this.value.add(new LinkedList(a));
- } // end for
- } // end constructor(List< List >)
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public List< List > getValue() {
- final List< List > res = new LinkedList< List >();
- for (List l : this.value) {
- res.add(new LinkedList(l));
- } // end for
- return res;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0,
- HASH_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS,
- API.encodeListList(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof RuntimeInvisibleParameterAnnotations) {
- final RuntimeInvisibleParameterAnnotations that = (RuntimeInvisibleParameterAnnotations) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'RuntimeInvisibleParameterAnnotations'
-
- /**
- * This class implements a 'RuntimeVisibleAnnotations' attribute.
- */
- public static final class RuntimeVisibleAnnotations extends Attribute {
-
- /** Attribute value. */
- private final List value;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public RuntimeVisibleAnnotations(final List v) {
- super(true, true, true, false);
- assert v != null : "null v";
- this.value = new LinkedList(v);
- } // end constructor(List)
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public List getValue() {
- return new LinkedList(this.value);
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0,
- HASH_RUNTIME_VISIBLE_ANNOTATIONS,
- API.encodeList(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof RuntimeVisibleAnnotations) {
- final RuntimeVisibleAnnotations that = (RuntimeVisibleAnnotations) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'RuntimeVisibleAnnotations'
-
- /**
- * This class implements a 'RuntimeVisibleAnnotations' attribute.
- */
- public static final class RuntimeVisibleTypeAnnotations extends Attribute {
-
- /** Attribute value. */
- private final List value;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public RuntimeVisibleTypeAnnotations(final List v) {
- super(true, true, true, false);
- assert v != null : "null v";
- this.value = new LinkedList(v);
- } // end constructor(List)
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public List getValue() {
- return new LinkedList(this.value);
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0,
- HASH_RUNTIME_VISIBLE_TYPE_ANNOTATIONS,
- API.encodeList(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof RuntimeVisibleTypeAnnotations) {
- final RuntimeVisibleTypeAnnotations that = (RuntimeVisibleTypeAnnotations) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'RuntimeVisibleTypeAnnotations'
-
- /**
- * This class implements a 'RuntimeVisibleParameterAnnotations' attribute.
- */
- public static final class RuntimeVisibleParameterAnnotations extends Attribute {
-
- /** Attribute value. */
- private final List< List > value;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public RuntimeVisibleParameterAnnotations(final List< List > v) {
- super(false, true, false, false);
- assert v != null : "null v";
- this.value = new LinkedList< List >();
- for (List a : v) {
- this.value.add(new LinkedList(a));
- } // end for
- } // end constructor(List< List >)
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public List< List > getValue() {
- final List< List > res = new LinkedList< List >();
- for (List l : this.value) {
- res.add(new LinkedList(l));
- } // end for
- return res;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0,
- HASH_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS,
- API.encodeListList(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof RuntimeVisibleParameterAnnotations) {
- final RuntimeVisibleParameterAnnotations that = (RuntimeVisibleParameterAnnotations) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'RuntimeVisibleParameterAnnotations'
-
- /**
- * This class implements a 'Signature' attribute.
- */
- public static final class Signature extends Attribute {
-
- /** Hash value for 'Class' attribute. */
- private static final Value HASH_CLASS =
- Hash.hashVariant("Class");
-
- /** Hash value for 'Method' attribute. */
- private static final Value HASH_METHOD =
- Hash.hashVariant("Method");
-
- /** Hash value for 'Field' attribute. */
- private static final Value HASH_FIELD =
- Hash.hashVariant("Field");
-
- /** Kinds of signatures. */
- public static enum Kind { CLASS, METHOD, FIELD };
-
- /** Attribute kind. */
- private final Kind kind;
-
- /** Attribute value. */
- private final String value;
-
- /**
- * Constructs an attribute.
- * @param k kind of signature - should not be null
- * @param v attribute value - should not be null
- */
- public Signature(final Kind k, final String v) {
- super(k.equals(Kind.FIELD), k.equals(Kind.METHOD), k.equals(Kind.CLASS), false);
- assert k != null : "null k";
- assert v != null : "null v";
- this.kind = k;
- this.value = v;
- } // end constructor(String)
-
- /**
- * Returns the attribute kind.
- * @return the attribute kind
- */
- public Kind getKind() {
- return this.kind;
- } // end method 'getKind()'
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public String getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block v;
- switch (this.kind) {
- case CLASS:
- v = Block.createBlock(0,
- HASH_CLASS,
- API.createClassSignature(this.value));
- break;
- case METHOD:
- v = Block.createBlock(0,
- HASH_METHOD,
- API.createMethodSignature(this.value));
- break;
- case FIELD:
- v = Block.createBlock(0,
- HASH_FIELD,
- API.createFieldSignature(this.value));
- break;
- default:
- // should not be reached
- v = Block.createBlock(0, Value.ZERO, Value.ZERO);
- break;
- } // end switch
- final Block b = Block.createBlock(0,
- HASH_SIGNATURE,
- Value.createFromBlock(v));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof Signature) {
- final Signature that = (Signature) obj;
- return this.kind.equals(that.kind)
- && this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Signature'
-
- /**
- * This class implements a 'SourceDebugExtension' attribute.
- */
- public static final class SourceDebugExtension extends Attribute {
-
- /** Attribute value. */
- private final String value;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public SourceDebugExtension(final String v) {
- super(false, false, true, false);
- assert v != null : "null v";
- this.value = v;
- } // end constructor(String)
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public String getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0,
- HASH_SOURCE_DEBUG_EXTENSION,
- API.createUTF8(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof SourceDebugExtension) {
- final SourceDebugExtension that = (SourceDebugExtension) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'SourceDebugExtension'
-
- /**
- * This class implements a 'SourceFile' attribute.
- */
- public static final class SourceFile extends Attribute {
-
- /** Attribute value. */
- private final String value;
-
- /**
- * Constructs an attribute.
- * @param v attribute value - should not be null
- */
- public SourceFile(final String v) {
- super(false, false, true, false);
- assert v != null : "null v";
- this.value = v;
- } // end constructor(String)
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public String getValue() {
- return this.value;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0,
- HASH_SOURCE_FILE,
- API.createUTF8(this.value));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof SourceFile) {
- final SourceFile that = (SourceFile) obj;
- return this.value.equals(that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'SourceFile'
-
- /**
- * This class implements a 'Synthetic' attribute.
- */
- public static final class Synthetic extends Attribute {
-
- /**
- * Constructs an attribute.
- */
- public Synthetic() {
- super(true, true, true, false);
- } // end empty constructor
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- return HASH_SYNTHETIC;
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof Synthetic) {
- return true;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Synthetic'
-
- /**
- * This class implements a 'StackMapTable' attribute.
- */
- public static final class StackMapTable extends Attribute {
-
- /** Embedded frames. */
- private final List extends StackMapFrame> frames;
-
- /**
- * Constructs an attribute.
- * @param f stack frames - should not be null
- */
- public StackMapTable(final List extends StackMapFrame> f) {
- super(false, false, false, true);
- assert f != null : "null f";
- this.frames = new LinkedList(f);
- } // end constructor(List extends StackMapFrame>)
-
- /**
- * Returns the list of embedded frames.
- * @return the list of embedded frames
- */
- public List extends StackMapFrame> getFrames() {
- return new LinkedList(this.frames);
- } // end method 'getFrames()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block c = Block.createBlock(0, API.encodeList(this.frames));
- final Block b = Block.createBlock(0,
- HASH_STACK_MAP_TABLE,
- Value.createFromBlock(c));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof StackMapTable) {
- final StackMapTable that = (StackMapTable) obj;
- return this.frames.equals(that.frames);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'StackMapTable'
-
- /**
- * This class implements an 'Unknown' attribute.
- */
- public static final class Unknown extends Attribute {
-
- /** Attribute name. */
- private final String name;
-
- /** Attribute value. */
- private final byte[] value;
-
- /**
- * Constructs an attribute.
- * @param n attribute name - should not be null
- * @param v attribute value - should not be null
- */
- public Unknown(final String n, final byte[] v) {
- super(true, true, true, true);
- assert n != null : "null n";
- assert v != null : "null v";
- this.name = n;
- final int len = v.length;
- this.value = new byte[len];
- System.arraycopy(v, 0, this.value, 0, len);
- } // end constructor(String, byte[])
-
- /**
- * Returns the attribute name.
- * @return the attribute name
- */
- public String getName() {
- return this.name;
- } // end method 'getName()'
-
- /**
- * Returns the attribute value.
- * @return the attribute value
- */
- public byte[] getValue() {
- final int len = this.value.length;
- final byte[] res = new byte[len];
- System.arraycopy(this.value, 0, res, 0, len);
- return res;
- } // end method 'getValue()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block c = Block.createBlock(0,
- API.createUTF8(this.name),
- Value.createFromBlock(Block.createString(this.value)));
- final Block b = Block.createBlock(0,
- HASH_UNKNOWN,
- Value.createFromBlock(c));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final boolean equals(final Object obj) {
- if (obj instanceof Unknown) {
- final Unknown that = (Unknown) obj;
- return this.name.equals(that.name)
- && Arrays.equals(this.value, that.value);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Unknown'
-
- /**
- * Constructs an instance from a value.
- * @param v value to construct instance from - should not be null
- * @return the corresponding instance
- */
- static Attribute fromValue(final Value v) {
- assert v != null : "null v";
- final Block b = v.asBlock();
- final int hash = b.get(0).asLong();
- if (hash == HASH_ANNOTATION_DEFAULT.asLong()) {
- return new AnnotationDefault(Annotation.elementFromValue(b.get(1)));
- } else if (hash == HASH_CODE.asLong()) {
- return new Code(CodeValue.fromValue(b.get(1)));
- } else if (hash == HASH_CONSTANT_VALUE.asLong()) {
- return new ConstantValue(ConstantVal.fromValue(b.get(1)));
- } else if (hash == HASH_DEPRECATED.asLong()) {
- return new Deprecated();
- } else if (hash == HASH_ENCLOSING_METHOD.asLong()) {
- final Block bb = b.get(1).asBlock();
- if (bb.get(1) == Value.ZERO) {
- return new EnclosingMethod(API.stringOfClassName(bb.get(0)));
- } else {
- final Block bbb = bb.get(1).asBlock();
- final Block desc = bbb.get(1).asBlock();
- final List params = new LinkedList();
- for (Value p : API.decodeList(desc.get(0))) {
- params.add(Descriptor.fromValue(v));
- } // end for
- return new EnclosingMethod(API.stringOfClassName(bb.get(0)),
- API.stringOfMethodName(bbb.get(0)),
- Descriptor.fromValue(desc.get(1)),
- params);
- } // end if/else
- } else if (hash == HASH_EXCEPTIONS.asLong()) {
- final List exns = new LinkedList();
- for (Value e : API.decodeList(b.get(1))) {
- exns.add(API.stringOfClassName(e));
- } // end for
- return new Exceptions(exns);
- } else if (hash == HASH_INNER_CLASSES.asLong()) {
- final List inners = new LinkedList();
- final List outers = new LinkedList();
- final List names = new LinkedList();
- final List< List > flags = new LinkedList< List >();
- for (Value i : API.decodeList(b.get(1))) {
- final Block ii = i.asBlock();
- if (ii.get(0) == Value.ZERO) {
- inners.add(null);
- } else {
- inners.add(API.stringOfClassName(ii.get(0).asBlock().get(0)));
- } // end if/else
- if (ii.get(1) == Value.ZERO) {
- outers.add(null);
- } else {
- outers.add(API.stringOfClassName(ii.get(1).asBlock().get(0)));
- } // end if/else
- if (ii.get(2) == Value.ZERO) {
- outers.add(null);
- } else {
- outers.add(API.stringOfUTF8(ii.get(2).asBlock().get(0)));
- } // end if/else
- final List l = new LinkedList();
- for (Value f : API.decodeList(ii.get(3))) {
- l.add(AccessFlag.fromValue(f));
- } // end for
- flags.add(l);
- } // end for
- return new InnerClasses(inners, outers, names, flags);
- } else if (hash == HASH_LINE_NUMBER_TABLE.asLong()) {
- final List offsets = new LinkedList();
- final List lines = new LinkedList();
- for (Value c : API.decodeList(b.get(1))) {
- final Block cb = c.asBlock();
- offsets.add(cb.get(0).asLong());
- lines.add(cb.get(1).asLong());
- } // end for
- return new LineNumberTable(offsets, lines);
- } else if (hash == HASH_LOCAL_VARIABLE_TABLE.asLong()) {
- final List starts = new LinkedList();
- final List ends = new LinkedList();
- final List names = new LinkedList();
- final List descriptors = new LinkedList();
- final List indexes = new LinkedList();
- for (Value t : API.decodeList(b.get(1))) {
- final Block bb = t.asBlock();
- starts.add(bb.get(0).asLong());
- ends.add(bb.get(1).asLong());
- names.add(API.stringOfUTF8(bb.get(2)));
- descriptors.add(Descriptor.fromValue(bb.get(3)));
- indexes.add(bb.get(4).asLong());
- } // end for
- return new LocalVariableTable(starts, ends, names, descriptors, indexes);
- } else if (hash == HASH_LOCAL_VARIABLE_TYPE_TABLE.asLong()) {
- final List starts = new LinkedList();
- final List ends = new LinkedList();
- final List names = new LinkedList();
- final List signatures = new LinkedList();
- final List indexes = new LinkedList();
- for (Value t : API.decodeList(b.get(1))) {
- final Block bb = t.asBlock();
- starts.add(bb.get(0).asLong());
- ends.add(bb.get(1).asLong());
- names.add(API.stringOfUTF8(bb.get(2)));
- signatures.add(API.stringOfFieldSignature(bb.get(3)));
- indexes.add(bb.get(4).asLong());
- } // end for
- return new LocalVariableTypeTable(starts, ends, names, signatures, indexes);
- } else if (hash == HASH_MODULE.asLong()) {
- return new Module(API.stringOfUTF8(b.get(1).asBlock().get(0)),
- API.stringOfUTF8(b.get(1).asBlock().get(1)));
- } else if (hash == HASH_RUNTIME_INVISIBLE_ANNOTATIONS.asLong()) {
- final List annots = new LinkedList();
- for (Value a : API.decodeList(b.get(1))) {
- annots.add(Annotation.fromValue(a));
- } // end for
- return new RuntimeInvisibleAnnotations(annots);
- } else if (hash == HASH_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS.asLong()) {
- final List annots = new LinkedList();
- for (Value a : API.decodeList(b.get(1))) {
- annots.add(ExtendedAnnotation.fromValue(a));
- } // end for
- return new RuntimeInvisibleTypeAnnotations(annots);
- } else if (hash == HASH_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS.asLong()) {
- final List< List > annotLists = new LinkedList< List >();
- for (Value al : API.decodeList(b.get(1))) {
- final List l = new LinkedList();
- for (Value a : API.decodeList(al)) {
- l.add(Annotation.fromValue(a));
- } // end for
- annotLists.add(l);
- } // end for
- return new RuntimeInvisibleParameterAnnotations(annotLists);
- } else if (hash == HASH_RUNTIME_VISIBLE_ANNOTATIONS.asLong()) {
- final List annots = new LinkedList();
- for (Value a : API.decodeList(b.get(1))) {
- annots.add(Annotation.fromValue(a));
- } // end for
- return new RuntimeVisibleAnnotations(annots);
- } else if (hash == HASH_RUNTIME_VISIBLE_TYPE_ANNOTATIONS.asLong()) {
- final List annots = new LinkedList();
- for (Value a : API.decodeList(b.get(1))) {
- annots.add(ExtendedAnnotation.fromValue(a));
- } // end for
- return new RuntimeVisibleTypeAnnotations(annots);
- } else if (hash == HASH_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS.asLong()) {
- final List< List > annotLists = new LinkedList< List >();
- for (Value al : API.decodeList(b.get(1))) {
- final List l = new LinkedList();
- for (Value a : API.decodeList(al)) {
- l.add(Annotation.fromValue(a));
- } // end for
- annotLists.add(l);
- } // end for
- return new RuntimeVisibleParameterAnnotations(annotLists);
- } else if (hash == HASH_SIGNATURE.asLong()) {
- final Block s = b.get(1).asBlock();
- final int h = s.get(0).asLong();
- if (h == Signature.HASH_CLASS.asLong()) {
- return new Signature(Signature.Kind.CLASS,
- API.stringOfClassSignature(s.get(1)));
- } else if (h == Signature.HASH_METHOD.asLong()) {
- return new Signature(Signature.Kind.METHOD,
- API.stringOfMethodSignature(s.get(1)));
- } else if (h == Signature.HASH_FIELD.asLong()) {
- return new Signature(Signature.Kind.FIELD,
- API.stringOfFieldSignature(s.get(1)));
- } else {
- assert false : "invalid tag";
- return null;
- } // end if/elsif/else
- } else if (hash == HASH_SOURCE_DEBUG_EXTENSION.asLong()) {
- return new SourceDebugExtension(API.stringOfUTF8(b.get(1)));
- } else if (hash == HASH_SOURCE_FILE.asLong()) {
- return new SourceFile(API.stringOfUTF8(b.get(1)));
- } else if (hash == HASH_SYNTHETIC.asLong()) {
- return new Synthetic();
- } else if (hash == HASH_STACK_MAP_TABLE.asLong()) {
- final List frames = new LinkedList();
- for (Value f : API.decodeList(b.get(1))) {
- frames.add(StackMapFrame.fromValue(f));
- } // end for
- return new StackMapTable(frames);
- } else if (hash == HASH_UNKNOWN.asLong()) {
- return new Unknown(API.stringOfUTF8(b.get(1).asBlock().get(0)),
- b.get(1).asBlock().get(1).asBlock().getBytes());
- } else {
- assert false : "invalid tag";
- return null;
- } // end if/elsif/else
- } // end method 'fromValue(Value)'
-
-} // end class 'Attribute'
rmfile ./api/src/fr/x9c/barista/api/Attribute.java
hunk ./api/src/fr/x9c/barista/api/BaristaException.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-/**
- * This class defines the exception to be thrown when a Barista call fails.
- *
- * @author Xavier Clerc
- * @version 1.0
- * @since 1.0
- */
-public final class BaristaException extends RuntimeException {
-
- /** Serialization UID. */
- static final long serialVersionUID = 8049594418997160639L;
-
- /**
- * Constructs an exception from message.
- * @param msg exception message
- */
- public BaristaException(final String msg) {
- super(msg);
- } // end constructor (String)
-
- /**
- * Constructs an exception from message and cause.
- * @param msg exception message
- * @param cause exception cause
- */
- public BaristaException(final String msg, final Throwable cause) {
- super(msg, cause);
- } // end constructor (String, Throwable)
-
-} // end class 'BaristaException'
rmfile ./api/src/fr/x9c/barista/api/BaristaException.java
hunk ./api/src/fr/x9c/barista/api/ByteCode.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.io.InputStream;
-
-import fr.x9c.cadmium.kernel.Block;
-import fr.x9c.cadmium.kernel.Channel;
-import fr.x9c.cadmium.kernel.Custom;
-import fr.x9c.cadmium.kernel.Value;
-
-/**
- * This class represents a Java class definition.
- *
- * @author Xavier Clerc
- * @version 1.3
- * @since 1.0
- */
-public final class ByteCode {
-
- /**
- * No instance of this class.
- */
- private ByteCode() {
- } // end empty constructor
-
- /**
- * Generates bytecode for a class definition.
- * @param v version usef for encoding - should not be null
- * @param cd class definition to encode - should not be null
- * @return the bytecode for the passed definition
- * @throws BaristaException if an error occurs
- */
- public static byte[] encode(final Version v,
- final ClassDefinition cd)
- throws BaristaException {
- assert v != null : "null v";
- assert cd != null : "null cd";
- final Value res =
- API.callback("fr.x9c.barista.api.ClassDefinition.encode",
- v.toValue(),
- cd.toValue());
- return res.asBlock().getBytes();
- } // end method 'encode(Version, ClassDefinition)'
-
- /**
- * Generates bytecode for a class definition.
- * @param cd class definition to encode - should not be null
- * @return the bytecode for the passed definition
- * @throws BaristaException if an error occurs
- */
- public static byte[] encode(final ClassDefinition cd)
- throws BaristaException {
- assert cd != null : "null cd";
- return encode(Version.Java_1_6, cd);
- } // end method 'encode(ClassDefinition)'
-
- /**
- * Constructs a class definition from an input stream.
- * @param in source for class bytecode - should not be null
- * @return the class definition of the passed bytecode
- * @throws BaristaException if an error occurs
- */
- public static ClassDefinition decode(final InputStream in)
- throws BaristaException {
- assert in != null : "null in";
- final Block b = Block.createCustom(Custom.CHANNEL_SIZE,
- Custom.CHANNEL_OPS);
- b.setCustom(new Channel(in));
- final Value res =
- API.callback("fr.x9c.barista.api.ClassDefinition.decode",
- Value.createFromBlock(b));
- return ClassDefinition.fromValue(res);
- } // end method 'decode(InputStream)'
-
-} // end class 'ByteCode'
rmfile ./api/src/fr/x9c/barista/api/ByteCode.java
hunk ./api/src/fr/x9c/barista/api/ClassDefinition.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import fr.x9c.cadmium.kernel.Block;
-import fr.x9c.cadmium.kernel.Value;
-import fr.x9c.cadmium.support.values.ToValue;
-
-/**
- * This class represents a Java class definition.
- *
- * @author Xavier Clerc
- * @version 1.0
- * @since 1.0
- */
-public final class ClassDefinition implements ToValue {
-
- /** Class flags. */
- private final List flags;
-
- /** Class name. */
- private final String name;
-
- /**
- * Class parent
- * (should be nullonly for java.lang.Object).
- */
- private final String parent;
-
- /** Class interfaces. */
- private final List interfaces;
-
- /** Class fields. */
- private final List fields;
-
- /** Class methods. */
- private final List methods;
-
- /** Class attributes. */
- private final List extends Attribute> attributes;
-
- /**
- * Constructs a class definition.
- * @param af class flags - should not be null,
- * should also be class flags
- * @param n class name - should not be null
- * @param p class parent (should be nullonly for java.lang.Object)
- * @param i class interfaces - should not be null
- * @param f class fields - should not be null
- * @param m class methods - should not be null
- * @param a class attributes - should not be null,
- * should also be class attributes
- * @throws BaristaException if one of the flags is not a valid flag
- * @throws BaristaException if one of the attributes is not a valid attribute
- */
- public ClassDefinition(final List af,
- final String n,
- final String p,
- final List i,
- final List f,
- final List m,
- final List extends Attribute> a)
- throws BaristaException {
- assert af != null : "null af";
- assert n != null : "null n";
- assert i != null : "null i";
- assert f != null : "null f";
- assert m != null : "null m";
- assert a != null : "null a";
- if (!AccessFlag.areClassFlags(af)) {
- throw new BaristaException("invalid flag");
- } // end if
- if (!Attribute.areClassAttributes(a)) {
- throw new BaristaException("invalid attribute");
- } // end if
- this.flags = new LinkedList(af);
- this.name = n;
- this.parent = p;
- this.interfaces = new LinkedList(i);
- this.fields = new LinkedList(f);
- this.methods = new LinkedList(m);
- this.attributes = new LinkedList(a);
- } // end constructor(List, String, String, ...)
-
- /**
- * Returns the class flags.
- * @return the class flags
- */
- public List getFlags() {
- return new LinkedList(this.flags);
- } // end method 'getFlags()'
-
- /**
- * Returns the class name.
- * @return the class name
- */
- public String getName() {
- return this.name;
- } // end method 'getName()'
-
- /**
- * Returns the class parent.
- * @return the class parent
- */
- public String getParent() {
- return this.parent;
- } // end method 'getParent()'
-
- /**
- * Returns the class interfaces.
- * @return the class interfaces
- */
- public List getInterfaces() {
- return new LinkedList(this.interfaces);
- } // end method 'getInterfaces()'
-
- /**
- * Returns the class fields.
- * @return the class fields
- */
- public List getFields() {
- return new LinkedList(this.fields);
- } // end method 'getFields()'
-
- /**
- * Returns the class methods.
- * @return the class methods
- */
- public List getMethods() {
- return new LinkedList(this.methods);
- } // end method 'getMethods()'
-
- /**
- * Returns the class attributes.
- * @return the class attributes
- */
- public List extends Attribute> getAttributes() {
- return new LinkedList(this.attributes);
- } // end method 'getAttributes()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(7, 0);
- b.set(0, API.encodeList(this.flags));
- b.set(1, API.createClassName(this.name));
- if (this.parent == null) {
- b.set(2, Value.ZERO);
- } else {
- final Block p = Block.createBlock(0, API.createClassName(this.parent));
- b.set(2, Value.createFromBlock(p));
- } // end if/else
- final List l = new LinkedList();
- for (String s : this.interfaces) {
- l.add(API.createClassName(s));
- } // end for
- b.set(3, API.encodeValueList(l));
- b.set(4, API.encodeList(this.fields));
- b.set(5, API.encodeList(this.methods));
- b.set(6, API.encodeList(this.attributes));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * Constructs a class definition from a value.
- * @param v value to constructs class definition from - should not be null
- * @return the class definition corresponding to the passed value
- */
- public static ClassDefinition fromValue(final Value v) {
- assert v != null : "null v";
- final Block b = v.asBlock();
- final List flags = new LinkedList();
- for (Value a : API.decodeList(b.get(0))) {
- flags.add(AccessFlag.fromValue(a));
- } // end for
- final List itf = new LinkedList();
- for (Value i : API.decodeList(b.get(3))) {
- itf.add(API.stringOfClassName(i));
- } // end for
- final List fld = new LinkedList();
- for (Value f : API.decodeList(b.get(4))) {
- fld.add(Field.fromValue(f));
- } // end for
- final List mth = new LinkedList();
- for (Value m : API.decodeList(b.get(5))) {
- mth.add(Method.fromValue(m));
- } // end for
- final List att = new LinkedList();
- for (Value a : API.decodeList(b.get(6))) {
- att.add(Attribute.fromValue(a));
- } // end for
- return new ClassDefinition(flags,
- API.stringOfClassName(b.get(1)),
- b.get(2) == Value.ZERO
- ? null
- : API.stringOfClassName(b.get(2).asBlock().get(0)),
- itf,
- fld,
- mth,
- att);
- } // end method 'fromValue(Value)'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- final String fl = AccessFlag.listToString(this.flags);
- if (fl.length() > 0) {
- sb.append(fl);
- sb.append(" ");
- } // end if
- sb.append("class ");
- sb.append(this.name);
- if (this.parent != null) {
- sb.append(" extends ");
- sb.append(this.parent);
- } // end for
- if (this.interfaces.size() > 0) {
- sb.append(" implements ");
- boolean first = true;
- for (String s : this.interfaces) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- } // end if/else
- sb.append(s);
- } // end for
- } // end if
- sb.append(" {\n");
- for (Field f : this.fields) {
- sb.append(" ");
- sb.append(f.toString());
- sb.append(";\n");
- } // end for
- for (Method m : this.methods) {
- sb.append(" ");
- sb.append(m.toString());
- sb.append(";\n");
- } // end for
- sb.append("}");
- return sb.toString();
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.flags.hashCode()
- + this.name.hashCode()
- + (this.parent != null ? this.parent.hashCode() : 0)
- + this.interfaces.hashCode()
- + this.fields.hashCode()
- + this.methods.hashCode()
- + this.attributes.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ClassDefinition) {
- final ClassDefinition that = (ClassDefinition) obj;
- return this.flags.equals(that.flags)
- && this.name.equals(that.name)
- && API.nullOrEquals(this.parent, that.parent)
- && this.interfaces.equals(that.interfaces)
- && this.fields.equals(that.fields)
- && this.methods.equals(that.methods)
- && this.attributes.equals(that.attributes);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
-} // end class 'ClassDefinition'
rmfile ./api/src/fr/x9c/barista/api/ClassDefinition.java
hunk ./api/src/fr/x9c/barista/api/ClassPath.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-import fr.x9c.cadmium.kernel.Block;
-import fr.x9c.cadmium.kernel.Value;
-import fr.x9c.cadmium.support.values.ToValue;
-
-/**
- * This class represents a classpath used to locate class files.
- * Such a classpath does not include the classpath of the running Java
- * program. This means that an empty classpath will be unable to find any
- * class, even the java.lang.Object class.
- *
- * @author Xavier Clerc
- * @version 1.0
- * @since 1.0
- */
-public final class ClassPath implements ToValue {
-
- /** Classpath elements. */
- private final List elements;
-
- /**
- * Constructs an empty class path.
- */
- public ClassPath() {
- this.elements = new LinkedList();
- } // end empty constructor
-
- /**
- * Constructs a classpath with one element.
- * @param elem classpath element - should not be null
- */
- public ClassPath(final String elem) {
- assert elem != null : "null elem";
- this.elements = new LinkedList();
- this.elements.add(elem);
- } // end constructor(String)
-
- /**
- * Constructs a classpath from a list of elements.
- * @param elems classpath elements - should not be null
- */
- public ClassPath(final String... elems) {
- assert elems != null : "null elems";
- this.elements = new LinkedList();
- for (String s : elems) {
- this.elements.add(s);
- } // end for
- } // end constructor(String...)
-
- /**
- * Constructs a classpath from a collection of elements.
- * @param elems classpath elements - should not be null
- */
- public ClassPath(final Collection elems) {
- this.elements = new LinkedList(elems);
- } // end constructor(Collection)
-
- /**
- * Converts the classpath into a list of elements.
- * @return the classpath as a list of elements
- */
- public List toList() {
- return new LinkedList(this.elements);
- } // end method 'toList()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (String s : this.elements) {
- if (first) {
- first = false;
- } else {
- sb.append(":");
- } // end if/else
- sb.append(s);
- } // end for
- return sb.toString();
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.elements.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ClassPath) {
- final ClassPath that = (ClassPath) obj;
- return this.elements.equals(that.elements);
- } else {
- return false;
- } // end if/else
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- return Value.createFromBlock(Block.createString(toString()));
- } // end method 'toValue()'
-
-} // end class 'ClassPath'
rmfile ./api/src/fr/x9c/barista/api/ClassPath.java
hunk ./api/src/fr/x9c/barista/api/Descriptor.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import fr.x9c.cadmium.kernel.Block;
-import fr.x9c.cadmium.kernel.Value;
-import fr.x9c.cadmium.primitives.stdlib.Hash;
-import fr.x9c.cadmium.support.values.ToValue;
-
-/**
- * This class represents a descriptor for a Java element.
- *
- * @author Xavier Clerc
- * @version 1.0
- * @since 1.0
- */
-public abstract class Descriptor implements ToValue {
-
- /** Hash for 'Array' variant. */
- private static final Value HASH_ARRAY = Hash.hashVariant("Array");
-
- /** Hash for 'Class' variant. */
- private static final Value HASH_CLASS = Hash.hashVariant("Class");
-
- /** Map from tag values to flags. */
- private static final Map MAP =
- new HashMap();
-
- /**
- * Ensures that no descriptor could be defined outside this file.
- */
- private Descriptor() {
- } // end empty constructor
-
- /**
- * This class represents simple descriptor elements.
- */
- private static final class Simple extends Descriptor {
-
- /** Descriptor name. */
- private final String name;
-
- /** Print value. */
- private final String print;
-
- /**
- * Constructs a descriptor from its tag name.
- * @param n tag name - should not be null
- * @param p value to print - should not be null
- */
- private Simple(final String n, final String p) {
- assert n != null : "null n";
- assert p != null : "null p";
- this.name = n;
- this.print = p;
- } // end constructor(String, String)
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- return Hash.hashVariant(this.name);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return this.print;
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.name.hashCode();
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Simple) {
- final Simple that = (Simple) obj;
- return this.name.equals(that.name);
- } else {
- return false;
- } // end if/else
- } // end method 'toString()'
-
- } // end inner-class 'Simple'
-
- /** Descriptor for array type. */
- public static final class Array extends Descriptor {
-
- /** Elements type. */
- private final Descriptor type;
-
- /**
- * Constucts array descriptor from array element.
- * @param t element type - should be neither null nor VOID
- */
- public Array(final Descriptor t) {
- assert t != null : "null t";
- assert t != VOID : "t should not be VOID";
- this.type = t;
- } // end constructor(Descriptor)
-
- /**
- * Returns the type of array elements.
- * @return the type of array elements
- */
- public Descriptor getType() {
- return this.type;
- } // end method 'getType()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block res = Block.createBlock(0,
- HASH_ARRAY,
- this.type.toValue());
- return Value.createFromBlock(res);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return this.type.toString() + "[]";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.type.hashCode();
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Array) {
- final Array that = (Array) obj;
- return this.type.equals(that.type);
- } else {
- return false;
- } // end if/else
- } // end method 'toString()'
-
- } // end inner-class 'Array'
-
- /** Descriptor for boolean type. */
- public static final Descriptor BOOLEAN = new Simple("Boolean", "boolean");
-
- /** Descriptor for byte type. */
- public static final Descriptor BYTE = new Simple("Byte", "byte");
-
- /** Descriptor for char type. */
- public static final Descriptor CHAR = new Simple("Char", "char");
-
- /** Descriptor for class type. */
- public static final class Class extends Descriptor {
-
- /** Class name. */
- private final String name;
-
- /**
- * Constucts class name from string.
- * @param n class name - should not be null
- */
- public Class(final String n) {
- assert n != null : "null n";
- this.name = n;
- } // end constructor(String)
-
- /**
- * Returns the class name.
- * @return the class name
- */
- public String getName() {
- return this.name;
- } // end method 'getName()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block res = Block.createBlock(0,
- HASH_CLASS,
- API.createClassName(this.name));
- return Value.createFromBlock(res);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return this.name;
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.name.hashCode();
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Class) {
- final Class that = (Class) obj;
- return this.name.equals(that.name);
- } else {
- return false;
- } // end if/else
- } // end method 'toString()'
-
- } // end inner-class 'Class'
-
- /** Descriptor for double type. */
- public static final Descriptor DOUBLE = new Simple("Double", "double");
-
- /** Descriptor for float type. */
- public static final Descriptor FLOAT = new Simple("Float", "float");
-
- /** Descriptor for int type. */
- public static final Descriptor INT = new Simple("Int", "int");
-
- /** Descriptor for long type. */
- public static final Descriptor LONG = new Simple("Long", "int");
-
- /** Descriptor for short type. */
- public static final Descriptor SHORT = new Simple("Short", "short");
-
- /** Descriptor for void type. */
- public static final Descriptor VOID = new Simple("Void", "void");
-
- /**
- * Tests whether the descriptor can be a field descriptor.
- * @return true if the descriptor can be a field descriptor,
- * false otherwise
- */
- public final boolean isFieldDescriptor() {
- return this != VOID;
- } // end method 'isFieldDescriptor()'
-
- /**
- * Tests whether a list contains only field descriptors.
- * @param l list to test - should not be null
- * @return true if the list contains only field descriptors,
- * false otherwise
- */
- public static boolean areFieldDescriptors(final List extends Descriptor> l) {
- assert l != null : "null l";
- for (Descriptor d : l) {
- if (!d.isFieldDescriptor()) {
- return false;
- } // end if
- } // end for
- return true;
- } // end method 'areFieldDescriptors(List extends Descriptor>)'
-
- /**
- * Constructs an instance from a value.
- * @param v value to construct instance from - should not be null
- * @return the corresponding instance
- */
- static Descriptor fromValue(final Value v) {
- assert v != null : "null v";
- if (v.isLong()) {
- return MAP.get(v.asLong());
- } else {
- final Block b = v.asBlock();
- final int tag = b.get(0).asLong();
- if (tag == HASH_ARRAY.asLong()) {
- return new Array(fromValue(b.get(1)));
- } else if (tag == HASH_CLASS.asLong()) {
- return new Class(API.stringOfClassName(b.get(1)));
- } else {
- assert false : "invalid descriptor";
- return null;
- } // end if/elsif/else
- } // end if/else
- } // end method 'fromValue(Value)'
-
- /**
- * Converts a descriptor list into a string.
- * @param l list to convert - should not be null
- * @return the concatenation of all list elements
- */
- public static String listToString(final List extends Descriptor> l) {
- assert l != null : "null l";
- final StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (Descriptor d : l) {
- if (first) {
- first = false;
- } else {
- sb.append(" ");
- } // end if/else
- sb.append(d.toString());
- } // end for
- return sb.toString();
- } // end method 'listToString(List extends Descriptor>)'
-
- /** Map initilization. */
- static {
- MAP.put(BOOLEAN.toValue().asLong(), BOOLEAN);
- MAP.put(BYTE.toValue().asLong(), BYTE);
- MAP.put(CHAR.toValue().asLong(), CHAR);
- MAP.put(DOUBLE.toValue().asLong(), DOUBLE);
- MAP.put(FLOAT.toValue().asLong(), FLOAT);
- MAP.put(INT.toValue().asLong(), INT);
- MAP.put(LONG.toValue().asLong(), LONG);
- MAP.put(SHORT.toValue().asLong(), SHORT);
- MAP.put(VOID.toValue().asLong(), VOID);
- } // end static block
-
-} // end class 'Descriptor'
rmfile ./api/src/fr/x9c/barista/api/Descriptor.java
hunk ./api/src/fr/x9c/barista/api/Disassembler.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.io.OutputStream;
-
-import fr.x9c.cadmium.kernel.Block;
-import fr.x9c.cadmium.kernel.Channel;
-import fr.x9c.cadmium.kernel.Custom;
-import fr.x9c.cadmium.kernel.Value;
-
-/**
- * This class provides methods for class textual disassembling.
- *
- * @author Xavier Clerc
- * @version 1.0
- * @since 1.0
- */
-public final class Disassembler {
-
- /**
- * No instance of this class.
- */
- private Disassembler() {
- } // end empty constructor
-
- /**
- * Calls the callback to disassemble a class.
- * @param name class name - should not be null
- * @param cp classpath for class loading - should not be null
- * @param out where to output class description - should not be null
- * @throws BaristaException if an errors occurs while disassembling
- */
- private static void callDisassemble(final String name,
- final ClassPath cp,
- final OutputStream out)
- throws BaristaException {
- assert name != null : "null name";
- assert cp != null : "null cp";
- assert out != null : "null out";
- final Value n = API.createUTF8(name);
- final Value c = cp.toValue();
- final Block b = Block.createCustom(Custom.CHANNEL_SIZE,
- Custom.CHANNEL_OPS);
- b.setCustom(new Channel(out));
- final Value o = Value.createFromBlock(b);
- API.callback("fr.x9c.barista.api.Disassembler.disassemble", n, c, o);
- } // end method 'callDisassemble(String, ClassPath, OutputStream)'
-
- /**
- * Disassembles a class.
- * @param name class name - should not be null
- * @param cp classpath for class loading - should not be null
- * @param out where to output class description - should not be null
- * @throws BaristaException if an errors occurs while disassembling
- */
- public static void disassemble(final String name,
- final ClassPath cp,
- final OutputStream out)
- throws BaristaException {
- callDisassemble(name, cp, out);
- } // end method 'disassemble(String, ClassPath, OutputStream)'
-
- /**
- * Disassembles a class.
- * @param name class name - should not be null
- * @param cp classpath for class loading - should not be null
- * @param out where to output class description - should not be null
- * @throws BaristaException if an errors occurs while disassembling
- */
- public static void disassemble(final String name,
- final ClassPath cp,
- final Appendable out)
- throws BaristaException {
- try {
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- callDisassemble(name, cp, baos);
- out.append(baos.toString("UTF-8"));
- } catch (final UnsupportedEncodingException uee) {
- throw new BaristaException("UTF8 unsupported by Java platform");
- } catch (final IOException ioe) {
- throw new BaristaException("I/O error", ioe);
- } // and try/catch
- } // end method 'disassemble(String, ClassPath, Appendable)'
-
- /**
- * Disassembles a class.
- * @param name class name - should not be null
- * @param cp classpath for class loading - should not be null
- * @return the disassembled class
- * @throws BaristaException if an errors occurs while disassembling
- */
- public static String disassemble(final String name, final ClassPath cp)
- throws BaristaException {
- try {
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- callDisassemble(name, cp, baos);
- return baos.toString("UTF-8");
- } catch (final UnsupportedEncodingException uee) {
- throw new BaristaException("UTF8 unsupported by Java platform");
- } // and try/catch
- } // end method 'disassemble(String, ClassPath)'
-
-} // end class 'Disassembler'
rmfile ./api/src/fr/x9c/barista/api/Disassembler.java
hunk ./api/src/fr/x9c/barista/api/ExtendedAnnotation.java 1
-/*
- * This file is part of Barista.
- * Copyright (C) 2007-2010 Xavier Clerc.
- *
- * Barista is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Barista is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package fr.x9c.barista.api;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-import fr.x9c.cadmium.kernel.Block;
-import fr.x9c.cadmium.kernel.Value;
-import fr.x9c.cadmium.support.Helper;
-import fr.x9c.cadmium.support.values.ToValue;
-
-/**
- * This class represents a Java extended annotation.
- *
- * @author Xavier Clerc
- * @version 2.0
- * @since 2.0
- */
-public final class ExtendedAnnotation implements ToValue {
-
- /**
- * This class represents a local variable element, that is: pc, length, and index.
- */
- public static final class LocalVariableElement implements ToValue {
-
- /** Start pc. */
- private final int pc;
-
- /** Length. */
- private final int length;
-
- /** Local index. */
- private final int index;
-
- /**
- * Constructs an instance.
- * @param p start pc - should be in 0..65535
- * @param l length - should be in 0..65535
- * @param i local index - should be in 0..65535
- */
- public LocalVariableElement(final int p, final int l, final int i) {
- assert (p >= 0) && (p <= 65535) : "invalid start pc value";
- assert (l >= 0) && (l <= 65535) : "invalid length value";
- assert (i >= 0) && (i <= 65535) : "invalid local value";
- this.pc = p;
- this.length = l;
- this.index = i;
- } // end constructor(int, int, int)
-
- /**
- * Returns the start pc.
- * @return the start pc
- */
- public int getPc() {
- return this.pc;
- } // end method 'getPc()'
-
- /**
- * Returns the length.
- * @return the length
- */
- public int getLength() {
- return this.length;
- } // end method 'getLength()'
-
- /**
- * Returns the index.
- * @return the index
- */
- public int getIndex() {
- return this.index;
- } // end method 'getIndex()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0,
- Value.createFromLong(this.pc),
- Value.createFromLong(this.length),
- Value.createFromLong(this.index));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "LocalVariableElement(" + this.pc + ", " + this.length + ", " + this.index + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.pc + this.length + this.index;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof LocalVariableElement) {
- final LocalVariableElement that = (LocalVariableElement) obj;
- return this.pc == that.pc
- && this.length == that.length
- && this.index == that.index;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'LocalVariableElement'
-
- /**
- * Parent class of all target value embedded inside extended annotations.
- */
- public static abstract class Target implements ToValue {
-
- /**
- * Ensures that no element value could be defined outside this file.
- */
- private Target() {
- } // end empty constructor
-
- } // end inner-class 'Target'
-
- /**
- * This class represents a simple target.
- */
- private static class SimpleTarget extends Target {
-
- /** Identifier. */
- private final int id;
-
- /**
- * Constructs an instance.
- * @param id identifier
- */
- public SimpleTarget(final int id) {
- this.id = id;
- } // end constructor(int)
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- return Value.createFromLong(this.id);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.id;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof SimpleTarget) {
- final SimpleTarget that = (SimpleTarget) obj;
- return this.id == that.id;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'SimpleTarget'
-
-
- /**
- * This class represents a 'method receiver' target.
- */
- public static final class MethodReceiver extends SimpleTarget {
-
- /**
- * Constructs an instance.
- */
- public MethodReceiver() {
- super(0);
- } // end empty constructor
-
- } // end inner-class 'MethodReceiver'
-
- /**
- * This class represents a 'method return type' target.
- */
- public static final class MethodReturnType extends SimpleTarget {
-
- /**
- * Constructs an instance.
- */
- public MethodReturnType() {
- super(1);
- } // end empty constructor
-
- } // end inner-class 'MethodReturnType'
-
- /**
- * This class represents a 'field' target.
- */
- public static final class Field extends SimpleTarget {
-
- /**
- * Constructs an instance.
- */
- public Field() {
- super(2);
- } // end empty constructor
-
- } // end inner-class 'Field'
-
- /**
- * This class represents a 'typecast' target.
- */
- public static final class Typecast extends Target {
-
- /** Offset. */
- private final int offset;
-
- /**
- * Constructs an instance.
- * @param o offset - should be in 0..65535
- */
- public Typecast(final int o) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- this.offset = o;
- } // end constructor(int)
-
- /**
- * Returns the offset.
- * @return the offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(0, Value.createFromLong(this.offset));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "Typecast(" + this.offset + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof Typecast) {
- final Typecast that = (Typecast) obj;
- return this.offset == that.offset;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'Typecast'
-
- /**
- * This class represents a 'typecast' target.
- */
- public static final class TypecastLoc extends Target {
-
- /** Offset. */
- private final int offset;
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param o offset - should be in 0..65535
- * @param l location - should not be null
- */
- public TypecastLoc(final int o, final List l) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- assert l != null : "invalid location";
- this.offset = o;
- this.location = l;
- } // end constructor(int, List)
-
- /**
- * Returns the offset.
- * @return the offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(1, Value.createFromLong(this.offset), valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "TypecastLoc(" + this.offset + ", " + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof TypecastLoc) {
- final TypecastLoc that = (TypecastLoc) obj;
- return this.offset == that.offset
- && this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'TypecastLoc'
-
- /**
- * This class represents a 'instanceof' target.
- */
- public static final class InstanceOf extends Target {
-
- /** Offset. */
- private final int offset;
-
- /**
- * Constructs an instance.
- * @param o offset - should be in 0..65535
- */
- public InstanceOf(final int o) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- this.offset = o;
- } // end constructor(int)
-
- /**
- * Returns the offset.
- * @return the offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(2, Value.createFromLong(this.offset));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "InstanceOf(" + this.offset + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof InstanceOf) {
- final InstanceOf that = (InstanceOf) obj;
- return this.offset == that.offset;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'InstanceOf'
-
- /**
- * This class represents a 'instanceof' target.
- */
- public static final class InstanceOfLoc extends Target {
-
- /** Offset. */
- private final int offset;
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param o offset - should be in 0..65535
- * @param l location - should not be null
- */
- public InstanceOfLoc(final int o, final List l) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- assert l != null : "invalid location";
- this.offset = o;
- this.location = l;
- } // end constructor(int, List)
-
- /**
- * Returns the offset.
- * @return the offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(3, Value.createFromLong(this.offset), valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "InstanceOfLoc(" + this.offset + ", " + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof InstanceOfLoc) {
- final InstanceOfLoc that = (InstanceOfLoc) obj;
- return this.offset == that.offset
- && this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'InstanceOfLoc'
-
- /**
- * This class represents a 'new' target.
- */
- public static final class New extends Target {
-
- /** Offset. */
- private final int offset;
-
- /**
- * Constructs an instance.
- * @param o offset - should be in 0..65535
- */
- public New(final int o) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- this.offset = o;
- } // end constructor(int)
-
- /**
- * Returns the offset.
- * @return the offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(4, Value.createFromLong(this.offset));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "New(" + this.offset + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof New) {
- final New that = (New) obj;
- return this.offset == that.offset;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'New'
-
- /**
- * This class represents a 'new' target.
- */
- public static final class NewLoc extends Target {
-
- /** Offset. */
- private final int offset;
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param o offset - should be in 0..65535
- * @param l location - should not be null
- */
- public NewLoc(final int o, final List l) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- assert l != null : "invalid location";
- this.offset = o;
- this.location = l;
- } // end constructor(int, List)
-
- /**
- * Returns the offset.
- * @return the offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(5, Value.createFromLong(this.offset), valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "NewLoc(" + this.offset + ", " + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof NewLoc) {
- final NewLoc that = (NewLoc) obj;
- return this.offset == that.offset
- && this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'NewLoc'
-
- /**
- * This class represents a 'local variable' target.
- */
- public static final class LocalVariable extends Target {
-
- /** Intervals. */
- private final List intervals;
-
- /**
- * Constructs an instance.
- * @param i intervals - should not be null
- */
- public LocalVariable(final List i) {
- assert i != null : "invalid intervals";
- this.intervals = i;
- } // end constructor(List)
-
- /**
- * Returns the intervals.
- * @return the intervals
- */
- public List getIntervals() {
- return this.intervals;
- } // end method 'getIntervals()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(6, valueOfIntervals(this.intervals));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "LocalVariable(" + this.intervals + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.intervals.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof LocalVariable) {
- final LocalVariable that = (LocalVariable) obj;
- return this.intervals.equals(that.intervals);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'LocalVariable'
-
- /**
- * This class represents a 'local variable' target.
- */
- public static final class LocalVariableLoc extends Target {
-
- /** Intervals. */
- private final List intervals;
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param i intervals - should not be null
- * @param l location - should not be null
- */
- public LocalVariableLoc(final List i, final List l) {
- assert i != null : "invalid intervals";
- assert l != null : "invalid location";
- this.intervals = i;
- this.location = l;
- } // end constructor(List, List)
-
- /**
- * Returns the intervals.
- * @return the intervals
- */
- public List getIntervals() {
- return this.intervals;
- } // end method 'getIntervals()'
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(7, valueOfIntervals(this.intervals), valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "LocalVariableLoc(" + this.intervals + ", " + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.intervals.hashCode() + this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof LocalVariableLoc) {
- final LocalVariableLoc that = (LocalVariableLoc) obj;
- return this.intervals.equals(that.intervals)
- && this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'LocalVariableLoc'
-
- /**
- * This class represents a 'method return type' target.
- */
- public static final class MethodReturnTypeLoc extends Target {
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param l location - should not be null
- */
- public MethodReturnTypeLoc(final List l) {
- assert l != null : "invalid location";
- this.location = l;
- } // end constructor(List)
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(8, valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "MethodReturnTypeLoc(" + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof MethodReturnTypeLoc) {
- final MethodReturnTypeLoc that = (MethodReturnTypeLoc) obj;
- return this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'MethodReturnTypeLoc'
-
- /**
- * This class represents a 'method parameter' target.
- */
- public static final class MethodParameter extends Target {
-
- /** Index. */
- private final int index;
-
- /**
- * Constructs an instance.
- * @param i index - should be in 0..127
- */
- public MethodParameter(final int i) {
- assert (i >= 0) && (i <= 127) : "invalid index value";
- this.index = i;
- } // end constructor(int)
-
- /**
- * Returns the index.
- * @return the index
- */
- public int getIndex() {
- return this.index;
- } // end method 'getIndex()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(9, Value.createFromLong(this.index));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "MethodParameter(" + this.index + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.index;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof MethodParameter) {
- final MethodParameter that = (MethodParameter) obj;
- return this.index == that.index;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'MethodParameter'
-
- /**
- * This class represents a 'method parameter' target.
- */
- public static final class MethodParameterLoc extends Target {
-
- /** Index. */
- private final int index;
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param i index - should be in 0..127
- * @param l location - should not be null
- */
- public MethodParameterLoc(final int i, final List l) {
- assert (i >= 0) && (i <= 127) : "invalid index value";
- assert l != null : "invalid location";
- this.index = i;
- this.location = l;
- } // end constructor(int, List)
-
- /**
- * Returns the index.
- * @return the index
- */
- public int getIndex() {
- return this.index;
- } // end method 'getIndex()'
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(10, Value.createFromLong(this.index), valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "MethodParameterLoc(" + this.index + ", " + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.index + this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof MethodParameterLoc) {
- final MethodParameterLoc that = (MethodParameterLoc) obj;
- return this.index == that.index
- && this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'MethodParameterLoc'
-
- /**
- * This class represents a 'field' target.
- */
- public static final class FieldLoc extends Target {
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param l location - should not be null
- */
- public FieldLoc(final List l) {
- assert l != null : "invalid location";
- this.location = l;
- } // end constructor(List)
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(11, valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "FieldLoc(" + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof FieldLoc) {
- final FieldLoc that = (FieldLoc) obj;
- return this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'FieldLoc'
-
- /**
- * This class represents a 'class type parameter bound' target.
- */
- public static final class ClassTypeParameterBound extends Target {
-
- /** Parameter index. */
- private final int paramIndex;
-
- /** Bound index. */
- private final int boundIndex;
-
- /**
- * Constructs an instance.
- * @param p parameter index - should be in 0..127
- * @param b bound index - should be in 0..127
- */
- public ClassTypeParameterBound(final int p, final int b) {
- assert (p >= 0) && (p <= 127) : "invalid parameter index value";
- assert (b >= 0) && (b <= 127) : "invalid bound index value";
- this.paramIndex = p;
- this.boundIndex = b;
- } // end constructor(int, int)
-
- /**
- * Returns the parameter index.
- * @return the parameter index
- */
- public int getParameterIndex() {
- return this.paramIndex;
- } // end method getParameterIndex ()'
-
- /**
- * Returns the bound index.
- * @return the bound index
- */
- public int getBoundIndex() {
- return this.boundIndex;
- } // end method getBoundIndex ()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(12, Value.createFromLong(this.paramIndex), Value.createFromLong(this.boundIndex));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "ClassTypeParameterBound(" + this.paramIndex + ", "+ this.boundIndex + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.paramIndex + this.boundIndex;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ClassTypeParameterBound) {
- final ClassTypeParameterBound that = (ClassTypeParameterBound) obj;
- return this.paramIndex == that.paramIndex
- && this.boundIndex == that.boundIndex;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ClassTypeParameterBound'
-
- /**
- * This class represents a 'class type parameter bound' target.
- */
- public static final class ClassTypeParameterBoundLoc extends Target {
-
- /** Parameter index. */
- private final int paramIndex;
-
- /** Bound index. */
- private final int boundIndex;
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param p parameter index - should be in 0..127
- * @param b bound index - should be in 0..127
- * @param l location - should not be null
- */
- public ClassTypeParameterBoundLoc(final int p, final int b, final List l) {
- assert (p >= 0) && (p <= 127) : "invalid parameter index value";
- assert (b >= 0) && (b <= 127) : "invalid bound index value";
- assert l != null : "invalid location";
- this.paramIndex = p;
- this.boundIndex = b;
- this.location = l;
- } // end constructor(int, int, List)
-
- /**
- * Returns the parameter index.
- * @return the parameter index
- */
- public int getParameterIndex() {
- return this.paramIndex;
- } // end method getParameterIndex ()'
-
- /**
- * Returns the bound index.
- * @return the bound index
- */
- public int getBoundIndex() {
- return this.boundIndex;
- } // end method getBoundIndex ()'
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(13, Value.createFromLong(this.paramIndex), Value.createFromLong(this.boundIndex), valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "ClassTypeParameterBoundLoc(" + this.paramIndex + ", " + this.boundIndex + ", " + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.paramIndex + this.boundIndex + this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ClassTypeParameterBoundLoc) {
- final ClassTypeParameterBoundLoc that = (ClassTypeParameterBoundLoc) obj;
- return this.paramIndex == that.paramIndex
- && this.boundIndex == that.boundIndex
- && this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ClassTypeParameterBoundLoc'
-
- /**
- * This class represents a 'method type parameter bound' target.
- */
- public static final class MethodTypeParameterBound extends Target {
-
- /** Parameter index. */
- private final int paramIndex;
-
- /** Bound index. */
- private final int boundIndex;
-
- /**
- * Constructs an instance.
- * @param p parameter index - should be in 0..127
- * @param b bound index - should be in 0..127
- */
- public MethodTypeParameterBound(final int p, final int b) {
- assert (p >= 0) && (p <= 127) : "invalid parameter index value";
- assert (b >= 0) && (b <= 127) : "invalid bound index value";
- this.paramIndex = p;
- this.boundIndex = b;
- } // end constructor(int, int)
-
- /**
- * Returns the parameter index.
- * @return the parameter index
- */
- public int getParameterIndex() {
- return this.paramIndex;
- } // end method getParameterIndex ()'
-
- /**
- * Returns the bound index.
- * @return the bound index
- */
- public int getBoundIndex() {
- return this.boundIndex;
- } // end method getBoundIndex ()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(14, Value.createFromLong(this.paramIndex), Value.createFromLong(this.boundIndex));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "MethodTypeParameterBound(" + this.paramIndex + ", "+ this.boundIndex + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.paramIndex + this.boundIndex;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof MethodTypeParameterBound) {
- final MethodTypeParameterBound that = (MethodTypeParameterBound) obj;
- return this.paramIndex == that.paramIndex
- && this.boundIndex == that.boundIndex;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'MethodTypeParameterBound'
-
- /**
- * This class represents a 'method type parameter bound' target.
- */
- public static final class MethodTypeParameterBoundLoc extends Target {
-
- /** Parameter index. */
- private final int paramIndex;
-
- /** Bound index. */
- private final int boundIndex;
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param p parameter index - should be in 0..127
- * @param b bound index - should be in 0..127
- * @param l location - should not be null
- */
- public MethodTypeParameterBoundLoc(final int p, final int b, final List l) {
- assert (p >= 0) && (p <= 127) : "invalid parameter index value";
- assert (b >= 0) && (b <= 127) : "invalid bound index value";
- assert l != null : "invalid location";
- this.paramIndex = p;
- this.boundIndex = b;
- this.location = l;
- } // end constructor(int, int, List)
-
- /**
- * Returns the parameter index.
- * @return the parameter index
- */
- public int getParameterIndex() {
- return this.paramIndex;
- } // end method getParameterIndex ()'
-
- /**
- * Returns the bound index.
- * @return the bound index
- */
- public int getBoundIndex() {
- return this.boundIndex;
- } // end method getBoundIndex ()'
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(15, Value.createFromLong(this.paramIndex), Value.createFromLong(this.boundIndex), valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "MethodTypeParameterBoundLoc(" + this.paramIndex + ", " + this.boundIndex + ", " + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.paramIndex + this.boundIndex + this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof MethodTypeParameterBoundLoc) {
- final MethodTypeParameterBoundLoc that = (MethodTypeParameterBoundLoc) obj;
- return this.paramIndex == that.paramIndex
- && this.boundIndex == that.boundIndex
- && this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'MethodTypeParameterBoundLoc'
-
- /**
- * This class represents a 'super type' target.
- */
- public static final class SuperType extends Target {
-
- /** Index. */
- private final int index;
-
- /**
- * Constructs an instance.
- * @param i index - should be in 0..65535
- */
- public SuperType(final int i) {
- assert (i >= 0) && (i <= 65535) : "invalid index value";
- this.index = i;
- } // end constructor(int)
-
- /**
- * Returns the index.
- * @return the index
- */
- public int getIndex() {
- return this.index;
- } // end method 'getIndex()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(16, Value.createFromLong(this.index));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "SuperType(" + this.index + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.index;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof SuperType) {
- final SuperType that = (SuperType) obj;
- return this.index == that.index;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'SuperType'
-
- /**
- * This class represents a 'super type' target.
- */
- public static final class SuperTypeLoc extends Target {
-
- /** Index. */
- private final int index;
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param i index - should be in 0..65535
- * @param l location - should not be null
- */
- public SuperTypeLoc(final int i, final List l) {
- assert (i >= 0) && (i <= 65535) : "invalid index value";
- assert l != null : "invalid location";
- this.index = i;
- this.location = l;
- } // end constructor(int, List)
-
- /**
- * Returns the index.
- * @return the index
- */
- public int getIndex() {
- return this.index;
- } // end method 'getIndex()'
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(17, Value.createFromLong(this.index), valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "SuperTypeLoc(" + this.index + ", " + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.index + this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof SuperTypeLoc) {
- final SuperTypeLoc that = (SuperTypeLoc) obj;
- return this.index == that.index
- && this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'SuperTypeLoc'
-
- /**
- * This class represents a 'thrown exception' target.
- */
- public static final class ThrownException extends Target {
-
- /** Index. */
- private final int index;
-
- /**
- * Constructs an instance.
- * @param i index - should be in 0..65535
- */
- public ThrownException(final int i) {
- assert (i >= 0) && (i <= 65535) : "invalid index value";
- this.index = i;
- } // end constructor(int)
-
- /**
- * Returns the index.
- * @return the index
- */
- public int getIndex() {
- return this.index;
- } // end method 'getIndex()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(18, Value.createFromLong(this.index));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "ThrownException(" + this.index + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.index;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ThrownException) {
- final ThrownException that = (ThrownException) obj;
- return this.index == that.index;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ThrownException'
-
- /**
- * This class represents a 'type argument constructor call' target.
- */
- public static final class TypeArgumentConstructorCall extends Target {
-
- /** Offset. */
- private final int offset;
-
- /** Index. */
- private final int index;
-
- /**
- * Constructs an instance.
- * @param o offset - should be in 0..65535
- * @param i index - should be in 0..127
- */
- public TypeArgumentConstructorCall(final int o, final int i) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- assert (i >= 0) && (i <=127) : "invalid index value";
- this.offset = o;
- this.index = i;
- } // end constructor(int, int)
-
- /**
- * Returns the offset.
- * @return the offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * Returns the index.
- * @return the index
- */
- public int getIndex() {
- return this.index;
- } // end method 'getIndex()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(19, Value.createFromLong(this.offset), Value.createFromLong(this.index));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "TypeArgumentConstructorCall(" + this.offset + ", " + this.index + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.index;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof TypeArgumentConstructorCall) {
- final TypeArgumentConstructorCall that = (TypeArgumentConstructorCall) obj;
- return this.offset == that.offset;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'TypeArgumentConstructorCall'
-
- /**
- * This class represents a 'type argument constructor call' target.
- */
- public static final class TypeArgumentConstructorCallLoc extends Target {
-
- /** Offset. */
- private final int offset;
-
- /** Index. */
- private final int index;
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param o offset - should be in 0..65535
- * @param i index - should be in 0..127
- * @param l location - should not be null
- */
- public TypeArgumentConstructorCallLoc(final int o, final int i, final List l) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- assert (i >= 0) && (i <=127) : "invalid index value";
- assert l != null : "invalid location";
- this.offset = o;
- this.index = i;
- this.location = l;
- } // end constructor(int, int, List)
-
- /**
- * Returns the offset.
- * @return the offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * Returns the index.
- * @return the index
- */
- public int getIndex() {
- return this.index;
- } // end method 'getIndex()'
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(20, Value.createFromLong(this.offset), Value.createFromLong(this.index), valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "TypeArgumentConstructorCallLoc(" + this.offset + ", " + this.index + ", " + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.index + this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof TypeArgumentConstructorCallLoc) {
- final TypeArgumentConstructorCallLoc that = (TypeArgumentConstructorCallLoc) obj;
- return this.offset == that.offset
- && this.index == that.index
- && this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'TypeArgumentConstructorCallLoc'
-
- /**
- * This class represents a 'type argument method call' target.
- */
- public static final class TypeArgumentMethodCall extends Target {
-
- /** Offset. */
- private final int offset;
-
- /** Index. */
- private final int index;
-
- /**
- * Constructs an instance.
- * @param o offset - should be in 0..65535
- * @param i index - should be in 0..127
- */
- public TypeArgumentMethodCall(final int o, final int i) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- assert (i >= 0) && (i <=127) : "invalid index value";
- this.offset = o;
- this.index = i;
- } // end constructor(int, int)
-
- /**
- * Returns the offset.
- * @return the offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * Returns the index.
- * @return the index
- */
- public int getIndex() {
- return this.index;
- } // end method 'getIndex()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(21, Value.createFromLong(this.offset), Value.createFromLong(this.index));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "TypeArgumentMethodCall(" + this.offset + ", " + this.index + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.index;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof TypeArgumentMethodCall) {
- final TypeArgumentMethodCall that = (TypeArgumentMethodCall) obj;
- return this.offset == that.offset;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'TypeArgumentMethodCall'
-
- /**
- * This class represents a 'type argument method call' target.
- */
- public static final class TypeArgumentMethodCallLoc extends Target {
-
- /** Offset. */
- private final int offset;
-
- /** Index. */
- private final int index;
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param o offset - should be in 0..65535
- * @param i index - should be in 0..127
- * @param l location - should not be null
- */
- public TypeArgumentMethodCallLoc(final int o, final int i, final List l) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- assert (i >= 0) && (i <=127) : "invalid index value";
- assert l != null : "invalid location";
- this.offset = o;
- this.index = i;
- this.location = l;
- } // end constructor(int, int, List)
-
- /**
- * Returns the offset.
- * @return the offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * Returns the index.
- * @return the index
- */
- public int getIndex() {
- return this.index;
- } // end method 'getIndex()'
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(22, Value.createFromLong(this.offset), Value.createFromLong(this.index), valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "TypeArgumentMethodCallLoc(" + this.offset + ", " + this.index + ", " + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.index + this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof TypeArgumentMethodCallLoc) {
- final TypeArgumentMethodCallLoc that = (TypeArgumentMethodCallLoc) obj;
- return this.offset == that.offset
- && this.index == that.index
- && this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'TypeArgumentMethodCallLoc'
-
- /**
- * This class represents a 'wildcard bound' target.
- */
- public static final class WildcardBound extends Target {
-
- /** Target. */
- private final Target target;
-
- /**
- * Constructs an instance.
- * @param t target - should not be null
- */
- public WildcardBound(final Target t) {
- assert t != null : "invalid target";
- this.target = t;
- } // end constructor(Target)
-
- /**
- * Returns the target.
- * @return the target
- */
- public Target getTarget() {
- return this.target;
- } // end method 'getTarget()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(23, this.target.toValue());
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "WildcardBound(" + this.target + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.target.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof WildcardBound) {
- final WildcardBound that = (WildcardBound) obj;
- return this.target.equals(that.target);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class WildcardBound'
-
- /**
- * This class represents a 'wildcard bound' target.
- */
- public static final class WildcardBoundLoc extends Target {
-
- /** Target. */
- private final Target target;
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param t target - should not be null
- * @param l location - should not be null
- */
- public WildcardBoundLoc(final Target t, final List l) {
- assert t != null : "invalid target";
- assert l != null : "invalid location";
- this.target = t;
- this.location = l;
- } // end constructor(Target, List)
-
- /**
- * Returns the target.
- * @return the target
- */
- public Target getTarget() {
- return this.target;
- } // end method 'getTarget()'
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(24, this.target.toValue(), valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "WildcardBoundLoc(" + this.target + ", " + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.target.hashCode() + this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof WildcardBoundLoc) {
- final WildcardBoundLoc that = (WildcardBoundLoc) obj;
- return this.target.equals(that.target)
- && this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'WildcardBoundLoc'
-
- /**
- * This class represents a 'class literal' target.
- */
- public static final class ClassLiteral extends Target {
-
- /** Offset. */
- private final int offset;
-
- /**
- * Constructs an instance.
- * @param o offset - should be in 0..65535
- */
- public ClassLiteral(final int o) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- this.offset = o;
- } // end constructor(int)
-
- /**
- * Returns the offset.
- * @return the offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(25, Value.createFromLong(this.offset));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "ClassLiteral(" + this.offset + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ClassLiteral) {
- final ClassLiteral that = (ClassLiteral) obj;
- return this.offset == that.offset;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ClassLiteral'
-
- /**
- * This class represents a 'typecast't target.
- */
- public static final class ClassLiteralLoc extends Target {
-
- /** Offset. */
- private final int offset;
-
- /** Location. */
- private final List location;
-
- /**
- * Constructs an instance.
- * @param o offset - should be in 0..65535
- * @param l location - should not be null
- */
- public ClassLiteralLoc(final int o, final List l) {
- assert (o >= 0) && (o <= 65535) : "invalid offset value";
- assert l != null : "invalid location";
- this.offset = o;
- this.location = l;
- } // end constructor(int, List)
-
- /**
- * Returns the offset.
- * @return the offset
- */
- public int getOffset() {
- return this.offset;
- } // end method 'getOffset()'
-
- /**
- * Returns the location.
- * @return the location
- */
- public List getLocation() {
- return this.location;
- } // end method 'getLocation()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(26, Value.createFromLong(this.offset), valueOfLocation(this.location));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "ClassLiteralLoc(" + this.offset + ", " + stringOfLocation(this.location) + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.offset + this.location.hashCode();
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ClassLiteralLoc) {
- final ClassLiteralLoc that = (ClassLiteralLoc) obj;
- return this.offset == that.offset
- && this.location.equals(that.location);
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ClassLiteralLoc'
-
- /**
- * This class represents a 'method type parameter' target.
- */
- public static final class MethodTypeParameter extends Target {
-
- /** Index. */
- private final int index;
-
- /**
- * Constructs an instance.
- * @param i index - should be in 0..127
- */
- public MethodTypeParameter(final int i) {
- assert (i >= 0) && (i <= 127) : "invalid index value";
- this.index = i;
- } // end constructor(int)
-
- /**
- * Returns the index.
- * @return the index
- */
- public int getIndex() {
- return this.index;
- } // end method 'getIndex()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(27, Value.createFromLong(this.index));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "MethodTypeParameter(" + this.index + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.index;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof MethodTypeParameter) {
- final MethodTypeParameter that = (MethodTypeParameter) obj;
- return this.index == that.index;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'MethodTypeParameter'
-
- /**
- * This class represents a class type parameter' target.
- */
- public static final class ClassTypeParameter extends Target {
-
- /** Index. */
- private final int index;
-
- /**
- * Constructs an instance.
- * @param i index - should be in 0..127
- */
- public ClassTypeParameter(final int i) {
- assert (i >= 0) && (i <= 127) : "invalid index value";
- this.index = i;
- } // end constructor(int)
-
- /**
- * Returns the index.
- * @return the index
- */
- public int getIndex() {
- return this.index;
- } // end method 'getIndex()'
-
- /**
- * {@inheritDoc}
- */
- public Value toValue() {
- final Block b = Block.createBlock(28, Value.createFromLong(this.index));
- return Value.createFromBlock(b);
- } // end method 'toValue()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "ClassTypeParameter(" + this.index + ")";
- } // end method 'toString()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.index;
- } // end method 'hashCode()'
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj instanceof ClassTypeParameter) {
- final ClassTypeParameter that = (ClassTypeParameter) obj;
- return this.index == that.index;
- } else {
- return false;
- } // end if/else
- } // end method 'equals(Object)'
-
- } // end inner-class 'ClassTypeParameter'
-
- /** Annotation name. */
- private final String name;
-
- /** Annotation element names. */
- private final List names;
-
- /** Annotation element values. */
- private final List extends Annotation.ElementValue> values;
-
- /** Annotation target. */
- private final Target target;
-
- /**
- * Constructs an extended annotation.
- * @param nm annotation name - should not be null
- * @param n element names - should not be null,
- * should also have the same size as v
- * @param v element values - should not be null,
- * should also have the same size as n
- * @param t annotation target - should not be null,
- */
- public ExtendedAnnotation(final String nm,
- final List n,
- final List extends Annotation.ElementValue> v,
- final Target t) {
- assert nm != null : "null nm";
- assert n != null : "null n";
- assert v != null : "null v";
- assert t != null : "null t";
- assert n.size() == v.size() : "n and v have different sizes";
- this.name = nm;
- this.names = new LinkedList(n);
- this.values = new LinkedList(v);
- this.target = t;
- } // end constructor(String, List, List extends Annotation.ElementValue>, Target)
-
- /**
- * Returns the name of the annotation.
- * @return the name of the annotation
- */
- public String getName() {
- return this.name;
- } // end method 'getName()'
-
- /**
- * Returns the names of the annotations elements.
- * @return the names of the annotations elements
- */
- public List getNames() {
- return new LinkedList