⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 name.java

📁 java编译器gjc源码 java编译环境
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

    /**
      * Replace all `from' bytes in this name with `to' bytes.
      */
    public Name replace(byte from, byte to) {
        byte[] names = table.names;
        int i = 0;
        while (i < len) {
            if (names[index + i] == from) {
                byte[] bs = new byte[len];
                System.arraycopy(names, index, bs, 0, i);
                bs[i] = to;
                i++;
                while (i < len) {
                    byte b = names[index + i];
                    bs[i] = b == from ? to : b;
                    i++;
                }
                return fromUtf(table, bs, 0, len);
            }
            i++;
        }
        return this;
    }

    /**
      * Return the concatenation of this name and name `n'.
      */
    public Name append(Name n) {
        byte[] bs = new byte[len + n.len];
        getBytes(bs, 0);
        n.getBytes(bs, len);
        return fromUtf(table, bs, 0, bs.length);
    }

    /**
      * Return the concatenation of this name, the given ASCII
      *  character, and name `n'.
      */
    public Name append(char c, Name n) {
        byte[] bs = new byte[len + n.len + 1];
        getBytes(bs, 0);
        bs[len] = (byte) c;
        n.getBytes(bs, len + 1);
        return fromUtf(table, bs, 0, bs.length);
    }

    /**
      * Return the concatenation of all names in the array `ns'.
      */
    public static Name concat(Table table, Name[] ns) {
        int len = 0;
        for (int i = 0; i < ns.length; i++)
            len = len + ns[i].len;
        byte[] bs = new byte[len];
        len = 0;
        for (int i = 0; i < ns.length; i++) {
            ns[i].getBytes(bs, len);
            len = len + ns[i].len;
        }
        return fromUtf(table, bs, 0, len);
    }

    public static class Table {
        private static List freelist = List.make();

        private static synchronized Table make() {
            while (freelist.nonEmpty()) {
                Table t = (Name.Table)((SoftReference) freelist.head).get();
                freelist = freelist.tail;
                if (t != null)
                    return t;
            }
            return new Table();
        }

        private static synchronized void dispose(Table t) {
            freelist = freelist.prepend(new SoftReference(t));
        }

        public void dispose() {
            dispose(this);
        }
        private static final Context.Key namesKey = new Context.Key();

        public static Table instance(Context context) {
            Table instance = (Name.Table) context.get(namesKey);
            if (instance == null) {
                instance = make();
                context.put(namesKey, instance);
            }
            return instance;
        }

        /**
          * The hash table for names.
          */
        private Name[] hashes;

        /**
         * The array holding all encountered names.
         */
        public byte[] names;

        /**
         * The mask to be used for hashing
         */
        private int hashMask;

        /**
         * The number of filled bytes in `names'.
         */
        private int nc = 0;

        /**
         * Allocator
         *  @param hashSize the (constant) size to be used for the hash table
         *                  needs to be a power of two.
         *  @param nameSize the initial size of the name table.
         */
        public Table(int hashSize, int nameSize) {
            super();
            hashMask = hashSize - 1;
            hashes = new Name[hashSize];
            names = new byte[nameSize];
            slash = fromString("/");
            hyphen = fromString("-");
            slashequals = fromString("/=");
            deprecated = fromString("deprecated");
            init = fromString("<init>");
            clinit = fromString("<clinit>");
            error = fromString("<error>");
            any = fromString("<any>");
            empty = fromString("");
            one = fromString("1");
            period = fromString(".");
            dollar = fromString("$");
            comma = fromString(",");
            semicolon = fromString(";");
            asterisk = fromString("*");
            _this = fromString("this");
            _super = fromString("super");
            __input = fromString("__input");
            _null = fromString("null");
            _false = fromString("false");
            _true = fromString("true");
            _class = fromString("class");
            emptyPackage = fromString("unnamed package");
            java_lang = fromString("java.lang");
            java_lang_Object = fromString("java.lang.Object");
            java_lang_Cloneable = fromString("java.lang.Cloneable");
            java_io_Serializable = fromString("java.io.Serializable");
            ConstantValue = fromString("ConstantValue");
            LineNumberTable = fromString("LineNumberTable");
            LocalVariableTable = fromString("LocalVariableTable");
            CharacterRangeTable = fromString("CharacterRangeTable");
            SourceID = fromString("SourceID");
            CompilationID = fromString("CompilationID");
            Code = fromString("Code");
            Exceptions = fromString("Exceptions");
            SourceFile = fromString("SourceFile");
            InnerClasses = fromString("InnerClasses");
            Synthetic = fromString("Synthetic");
            Deprecated = fromString("Deprecated");
            dollarAssertionsDisabled = fromString("$assertionsDisabled");
            desiredAssertionStatus = fromString("desiredAssertionStatus");
            append = fromString("append");
            forName = fromString("forName");
            toString = fromString("toString");
            length = fromString("length");
            valueOf = fromString("valueOf");
            classDollar = fromString("class$");
            thisDollar = fromString("this$");
            valDollar = fromString("val$");
            accessDollar = fromString("access$");
            getMessage = fromString("getMessage");
            getClass = fromString("getClass");
            TYPE = fromString("TYPE");
            Array = fromString("Array");
            Method = fromString("Method");
            clone = fromString("clone");
            getComponentType = fromString("getComponentType");
            getClassLoader = fromString("getClassLoader");
            initCause = fromString("initCause");
        }

        public Table() {
            this(32768, 131072);
        }

        /**
          * Create a name from the bytes in cs[start..start+len-1].
          *  Assume that bytes are in utf8 format.
          */
        public Name fromUtf(byte[] cs, int start, int len) {
            return Name.fromUtf(this, cs, start, len);
        }

        /**
          * Create a name from the bytes in array cs.
          *  Assume that bytes are in utf8 format.
          */
        public Name fromUtf(byte[] cs) {
            return Name.fromUtf(this, cs, 0, cs.length);
        }

        /**
          * Create a name from the characters in cs[start..start+len-1].
          */
        public Name fromChars(char[] cs, int start, int len) {
            return Name.fromChars(this, cs, start, len);
        }

        /**
          * Create a name from the characters in string s.
          */
        public Name fromString(String s) {
            return Name.fromString(this, s);
        }
        public final Name slash;
        public final Name hyphen;
        public final Name slashequals;
        public final Name deprecated;
        public final Name init;
        public final Name clinit;
        public final Name error;
        public final Name any;
        public final Name empty;
        public final Name one;
        public final Name period;
        public final Name dollar;
        public final Name comma;
        public final Name semicolon;
        public final Name asterisk;
        public final Name _this;
        public final Name _super;
        public final Name __input;
        public final Name _null;
        public final Name _false;
        public final Name _true;
        public final Name _class;
        public final Name emptyPackage;
        public final Name java_lang;
        public final Name java_lang_Object;
        public final Name java_lang_Cloneable;
        public final Name java_io_Serializable;
        public final Name ConstantValue;
        public final Name LineNumberTable;
        public final Name LocalVariableTable;
        public final Name CharacterRangeTable;
        public final Name SourceID;
        public final Name CompilationID;
        public final Name Code;
        public final Name Exceptions;
        public final Name SourceFile;
        public final Name InnerClasses;
        public final Name Synthetic;
        public final Name Deprecated;
        public final Name dollarAssertionsDisabled;
        public final Name desiredAssertionStatus;
        public final Name append;
        public final Name forName;
        public final Name toString;
        public final Name length;
        public final Name valueOf;
        public final Name classDollar;
        public final Name thisDollar;
        public final Name valDollar;
        public final Name accessDollar;
        public final Name getMessage;
        public final Name getClass;
        public final Name TYPE;
        public final Name Array;
        public final Name Method;
        public final Name clone;
        public final Name getComponentType;
        public final Name getClassLoader;
        public final Name initCause;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -