blob: 4fc8dea759bd8639db03b95a886e8fa0155184a9 [file] [log] [blame]
/*
* Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.dev.jjs.ast;
import com.google.gwt.dev.jjs.SourceInfo;
/**
* Base class for any reference type.
*/
public abstract class JReferenceType extends JType implements CanBeAbstract {
public JReferenceType(SourceInfo info, String name) {
super(info, name, JNullLiteral.INSTANCE);
}
/**
* Returns <code>true</code> if it's possible for this type to be
* <code>null</code>.
*
* @see JNonNullType
*/
public boolean canBeNull() {
return true;
}
@Override
public String getJavahSignatureName() {
return "L" + name.replaceAll("_", "_1").replace('.', '_') + "_2";
}
@Override
public String getJsniSignatureName() {
return "L" + name.replace('.', '/') + ';';
}
public String getShortName() {
int dotpos = name.lastIndexOf('.');
return name.substring(dotpos + 1);
}
/**
* Returns this type's super class, or <code>null</code> if this type is
* {@link Object} or the {@link JNullType}.
*/
public abstract JClassType getSuperClass();
/**
* If this type is a non-null type, returns the underlying (original) type.
*/
public JReferenceType getUnderlyingType() {
return this;
}
}