/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/** A class that defines all predefined constants and operators
* as well as special classes such as java.lang.Object, which need
* to be known to the compiler. All symbols are held in instance
* fields. This makes it possible to work in multiple concurrent
* projects, which might use different class files for library classes.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
public class Symtab {
/** The context key for the symbol table. */
/** Get the symbol table instance. */
return instance;
}
/** Builtin types.
*/
/** A symbol for the root package.
*/
/** A symbol for the unnamed package.
*/
/** A symbol that stands for a missing symbol.
*/
/** The error symbol.
*/
/** The unknown symbol.
*/
/** A value for the errType, with a originalType of noType */
/** A value for the unknown type. */
/** The builtin type of all arrays. */
/** VGJ: The (singleton) type of all bound types. */
/** The builtin type of all methods. */
/** Predefined types.
*/
/** The symbol representing the length field of an array.
*/
/** The null check operator. */
/** The symbol representing the final finalize method on enums */
/** The symbol representing the close method on TWR AutoCloseable type */
/** The predefined type that belongs to a tag.
*/
/** The name of the class that belongs to a basix type tag.
*/
/** A hashtable containing the encountered top-level and member classes,
* indexed by flat names. The table does not contain local classes.
* It should be updated from the outside to reflect classes defined
* by compiled source files.
*/
/** A hashtable containing the encountered packages.
* the table should be updated from outside to reflect packages defined
* by compiled source files.
*/
}
type,
new ClassSymbol(
}
}
/** The class symbol that owns all predefined symbols.
*/
/** Enter a constant into symbol table.
* @param name The constant's name.
* @param type The constant's type.
*/
type,
return c;
}
/** Enter a binary operation into symbol table.
* @param name The name of the operator.
* @param left The type of the left operand.
* @param right The type of the left operand.
* @param res The operation's result type.
* @param opcode The operation's bytecode instruction.
*/
int opcode) {
new OperatorSymbol(
predefClass));
}
/** Enter a binary operation, as above but with two opcodes,
* which get encoded as (opcode1 << ByteCodeTags.preShift) + opcode2.
* @param opcode1 First opcode.
* @param opcode2 Second opcode.
*/
}
/** Enter a unary operation into symbol table.
* @param name The name of the operator.
* @param arg The type of the operand.
* @param res The operation's result type.
* @param opcode The operation's bytecode instruction.
*/
int opcode) {
res,
return sym;
}
/** Enter a class into symbol table.
* @param The name of the class.
*/
}
try {
} catch (CompletionFailure e) {
}
}
};
}
}
try {
} catch (CompletionFailure e) {
n,
sym);
new MethodSymbol(PUBLIC,
sym);
}
}
};
}
}
/** Constructor; enters all predefined identifiers and operators
* into symbol table.
*/
// Create the unknown type
public <R, P> R accept(TypeVisitor<R, P> v, P p) {
return v.visitUnknown(this, p);
}
};
// create the basic builtin symbols
}
};
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
return v.visitUnknown(this, p);
}
};
// create the error symbols
unknownSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.fromString("<any?>"), null, rootPackage);
// initialize builtin types
// the builtin class of all arrays
// VGJ
// the builtin class of all methods
// Create class to hold all predefined constants and operations.
// Enter symbols for basic types.
// Enter symbol for the errSymbol
// Enter predefined classes.
enumSym);
? enterClass("java.lang.Iterable")
: enterClass("java.util.Collection");
// Enter a synthetic class that is used to mark internal
// proprietary classes in ct.sym. This class does not have a
// class file.
this.proprietaryType = proprietaryType;
// Enter a class for arrays.
// The class implements java.lang.Cloneable and java.io.Serializable.
// It has a final length field and a clone method.
arrayCloneMethod = new MethodSymbol(
// Enter operators.
// string concatenation
// these errors would otherwise be matched as string concatenation
}
}