Rename getOutType() -> getType()

This commit is contained in:
Andrey Breslav
2012-02-24 18:50:40 +04:00
parent 1f4f4e5c24
commit d22f4eb144
42 changed files with 100 additions and 109 deletions
@@ -119,7 +119,7 @@ public abstract class ClassBodyCodegen {
if(state.getStandardLibrary().isVolatile(propertyDescriptor)) {
modifiers |= Opcodes.ACC_VOLATILE;
}
v.newField(p, modifiers, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getOutType()).getDescriptor(), null, null);
v.newField(p, modifiers, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getType()).getDescriptor(), null, null);
}
}
}
@@ -113,7 +113,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
final String funClass = getInternalClassName(funDescriptor);
signatureWriter.visitClassType(funClass);
for (ValueParameterDescriptor parameter : parameters) {
appendType(signatureWriter, parameter.getOutType(), '=');
appendType(signatureWriter, parameter.getType(), '=');
}
appendType(signatureWriter, funDescriptor.getReturnType(), '=');
@@ -233,7 +233,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
final List<ValueParameterDescriptor> params = funDescriptor.getValueParameters();
for (ValueParameterDescriptor param : params) {
StackValue.local(count, JetTypeMapper.TYPE_OBJECT).put(JetTypeMapper.TYPE_OBJECT, iv);
StackValue.onStack(JetTypeMapper.TYPE_OBJECT).upcast(state.getTypeMapper().mapType(param.getOutType()), iv);
StackValue.onStack(JetTypeMapper.TYPE_OBJECT).upcast(state.getTypeMapper().mapType(param.getType()), iv);
count++;
}
@@ -280,7 +280,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
for (DeclarationDescriptor descriptor : closure.keySet()) {
if(descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
final Type sharedVarType = exprContext.getTypeMapper().getSharedVarType(descriptor);
final Type type = sharedVarType != null ? sharedVarType : state.getTypeMapper().mapType(((VariableDescriptor) descriptor).getOutType());
final Type type = sharedVarType != null ? sharedVarType : state.getTypeMapper().mapType(((VariableDescriptor) descriptor).getType());
argTypes[i++] = type;
}
else if(CodegenUtil.isNamedFun(descriptor, state.getBindingContext()) && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
@@ -257,13 +257,13 @@ public abstract class CodegenContext {
CallableMemberDescriptor.Kind.DECLARATION
);
JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null;
myAccessor.setType(pd.getOutType(), Collections.<TypeParameterDescriptor>emptyList(), pd.getExpectedThisObject(), receiverType);
myAccessor.setType(pd.getType(), Collections.<TypeParameterDescriptor>emptyList(), pd.getExpectedThisObject(), receiverType);
PropertyGetterDescriptor pgd = new PropertyGetterDescriptor(
myAccessor, Collections.<AnnotationDescriptor>emptyList(), myAccessor.getModality(),
myAccessor.getVisibility(),
false, false, CallableMemberDescriptor.Kind.DECLARATION);
pgd.initialize(myAccessor.getOutType());
pgd.initialize(myAccessor.getType());
PropertySetterDescriptor psd = new PropertySetterDescriptor(
myAccessor, Collections.<AnnotationDescriptor>emptyList(), myAccessor.getModality(),
@@ -353,7 +353,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
JetType iteratorType = iteratorDescriptor.getReturnType();
Type asmIterType = boxType(asmType(iteratorType));
JetType paramType = parameterDescriptor.getOutType();
JetType paramType = parameterDescriptor.getType();
Type asmParamType = asmType(paramType);
int iteratorVar = myFrameMap.enterTemp();
@@ -428,7 +428,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
}
public void invoke() {
JetType paramType = parameterDescriptor.getOutType();
JetType paramType = parameterDescriptor.getType();
Type asmParamType = asmType(paramType);
myFrameMap.enter(parameterDescriptor, asmParamType.getSize());
@@ -801,7 +801,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
if(entry.getKey() instanceof VariableDescriptor && !(entry.getKey() instanceof PropertyDescriptor)) {
Type sharedVarType = typeMapper.getSharedVarType(entry.getKey());
if(sharedVarType == null)
sharedVarType = state.getTypeMapper().mapType(((VariableDescriptor) entry.getKey()).getOutType());
sharedVarType = state.getTypeMapper().mapType(((VariableDescriptor) entry.getKey()).getType());
consArgTypes.add(sharedVarType);
entry.getValue().getOuterValue().put(sharedVarType, v);
}
@@ -833,7 +833,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
assert variableDescriptor != null;
final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor);
final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getOutType());
final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getType());
myFrameMap.enter(variableDescriptor, type.getSize());
}
@@ -874,7 +874,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
int index = myFrameMap.leave(variableDescriptor);
final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor);
final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getOutType());
final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getType());
if(sharedVarType != null) {
v.aconst(null);
v.store(index, TYPE_OBJECT);
@@ -983,7 +983,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
if (index >= 0) {
if(descriptor instanceof VariableDescriptor) {
Type sharedVarType = typeMapper.getSharedVarType(descriptor);
final JetType outType = ((VariableDescriptor) descriptor).getOutType();
final JetType outType = ((VariableDescriptor) descriptor).getType();
if(sharedVarType != null) {
return StackValue.shared(index, asmType(outType));
}
@@ -1231,7 +1231,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
ownerParam = callableMethod.getDefaultImplParam();
}
return StackValue.property(propertyDescriptor.getName(), owner, ownerParam, asmType(propertyDescriptor.getOutType()), isStatic, isInterface, isSuper, getter, setter, invokeOpcode);
return StackValue.property(propertyDescriptor.getName(), owner, ownerParam, asmType(propertyDescriptor.getType()), isStatic, isInterface, isSuper, getter, setter, invokeOpcode);
}
@Override
@@ -1511,7 +1511,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
}
else if(resolvedValueArgument instanceof VarargValueArgument) {
VarargValueArgument valueArgument = (VarargValueArgument) resolvedValueArgument;
JetType outType = valueParameterDescriptor.getOutType();
JetType outType = valueParameterDescriptor.getType();
Type type = asmType(outType);
assert type.getSort() == Type.ARRAY;
@@ -1682,7 +1682,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
StackValue leftValue = gen(expr);
FunctionDescriptor op = (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
assert op != null;
leftValue.put(asmType(op.getValueParameters().get(0).getOutType()), v);
leftValue.put(asmType(op.getValueParameters().get(0).getType()), v);
genToJVMStack(expression.getRight());
v.swap();
invokeFunctionNoParams(op, Type.BOOLEAN_TYPE, v);
@@ -2209,7 +2209,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor);
assert variableDescriptor != null;
Type varType = asmType(variableDescriptor.getOutType());
Type varType = asmType(variableDescriptor.getType());
if(sharedVarType != null) {
v.anew(sharedVarType);
v.dup();
@@ -2371,7 +2371,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
final List<JetExpression> indices = expression.getIndexExpressions();
FunctionDescriptor operationDescriptor = (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression);
assert operationDescriptor != null;
if (arrayType.getSort() == Type.ARRAY && indices.size() == 1 && operationDescriptor.getValueParameters().get(0).getOutType().equals(state.getStandardLibrary().getIntType())) {
if (arrayType.getSort() == Type.ARRAY && indices.size() == 1 && operationDescriptor.getValueParameters().get(0).getType().equals(state.getStandardLibrary().getIntType())) {
gen(array, arrayType);
for (JetExpression index : indices) {
gen(index, Type.INT_TYPE);
@@ -2499,7 +2499,7 @@ If finally block is present, its last expression is the value of try expression.
VariableDescriptor descriptor = bindingContext.get(BindingContext.VALUE_PARAMETER, clause.getCatchParameter());
assert descriptor != null;
Type descriptorType = asmType(descriptor.getOutType());
Type descriptorType = asmType(descriptor.getType());
myFrameMap.enter(descriptor, 1);
int index = lookupLocal(descriptor);
v.store(index, descriptorType);
@@ -2614,7 +2614,7 @@ If finally block is present, its last expression is the value of try expression.
final JetProperty var = ((JetBindingPattern) pattern).getVariableDeclaration();
final VariableDescriptor variableDescriptor = bindingContext.get(BindingContext.VARIABLE, var);
assert variableDescriptor != null;
final Type varType = asmType(variableDescriptor.getOutType());
final Type varType = asmType(variableDescriptor.getType());
myFrameMap.enter(variableDescriptor, varType.getSize());
expressionToMatch.dupReceiver(v);
expressionToMatch.put(varType, v);
@@ -153,7 +153,7 @@ public class FunctionCodegen {
if(parameterDescriptor.hasDefaultValue()) {
av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_HAS_DEFAULT_VALUE_FIELD, true);
}
if(parameterDescriptor.getOutType().isNullable()) {
if(parameterDescriptor.getType().isNullable()) {
av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, true);
}
if (jvmSignature.getKotlinParameterTypes() != null && jvmSignature.getKotlinParameterTypes().get(i) != null) {
@@ -205,7 +205,7 @@ public class FunctionCodegen {
for (ValueParameterDescriptor parameter : paramDescrs) {
Type sharedVarType = typeMapper.getSharedVarType(parameter);
if (sharedVarType != null) {
Type localVarType = typeMapper.mapType(parameter.getOutType());
Type localVarType = typeMapper.mapType(parameter.getType());
int index = frameMap.getIndex(parameter);
mv.visitTypeInsn(NEW, sharedVarType.getInternalName());
mv.visitInsn(DUP);
@@ -239,7 +239,7 @@ public class FunctionCodegen {
}
for (ValueParameterDescriptor parameter : paramDescrs) {
Type type = typeMapper.mapType(parameter.getOutType());
Type type = typeMapper.mapType(parameter.getType());
// TODO: specify signature
mv.visitLocalVariable(parameter.getName(), type.getDescriptor(), null, methodBegin, methodEnd, k);
k += type.getSize();
@@ -451,7 +451,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
for (DeclarationDescriptor descriptor : closure.closure.keySet()) {
if(descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
final Type sharedVarType = typeMapper.getSharedVarType(descriptor);
final Type type = sharedVarType != null ? sharedVarType : state.getTypeMapper().mapType(((VariableDescriptor) descriptor).getOutType());
final Type type = sharedVarType != null ? sharedVarType : state.getTypeMapper().mapType(((VariableDescriptor) descriptor).getType());
consArgTypes.add(insert++, new JvmMethodParameterSignature(type, "", JvmMethodParameterKind.SHARED_VAR));
}
else if(descriptor instanceof FunctionDescriptor) {
@@ -612,7 +612,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if(varDescr instanceof VariableDescriptor && !(varDescr instanceof PropertyDescriptor)) {
Type sharedVarType = typeMapper.getSharedVarType(varDescr);
if(sharedVarType == null) {
sharedVarType = typeMapper.mapType(((VariableDescriptor) varDescr).getOutType());
sharedVarType = typeMapper.mapType(((VariableDescriptor) varDescr).getType());
}
iv.load(0, JetTypeMapper.TYPE_OBJECT);
iv.load(k, StackValue.refType(sharedVarType));
@@ -628,7 +628,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
for (JetParameter parameter : constructorParameters) {
if (parameter.getValOrVarNode() != null) {
VariableDescriptor descriptor = paramDescrs.get(curParam);
Type type = typeMapper.mapType(descriptor.getOutType());
Type type = typeMapper.mapType(descriptor.getType());
iv.load(0, classType);
iv.load(frameMap.getIndex(descriptor), type);
iv.putfield(classname, descriptor.getName(), type.getDescriptor());
@@ -864,9 +864,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if(compileTimeValue != null) {
assert compileTimeValue != null;
Object value = compileTimeValue.getValue();
Type type = typeMapper.mapType(propertyDescriptor.getOutType());
Type type = typeMapper.mapType(propertyDescriptor.getType());
if(JetTypeMapper.isPrimitive(type)) {
if( !propertyDescriptor.getOutType().isNullable() && value instanceof Number) {
if( !propertyDescriptor.getType().isNullable() && value instanceof Number) {
if(type == Type.INT_TYPE && ((Number)value).intValue() == 0)
continue;
if(type == Type.BYTE_TYPE && ((Number)value).byteValue() == 0)
@@ -892,12 +892,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
iv.load(0, JetTypeMapper.TYPE_OBJECT);
Type type = codegen.expressionType(initializer);
if(propertyDescriptor.getOutType().isNullable())
if(propertyDescriptor.getType().isNullable())
type = JetTypeMapper.boxType(type);
codegen.gen(initializer, type);
// @todo write directly to the field. Fix test excloset.jet::test6
String owner = typeMapper.getOwner(propertyDescriptor, OwnerKind.IMPLEMENTATION);
StackValue.property(propertyDescriptor.getName(), owner, owner, typeMapper.mapType(propertyDescriptor.getOutType()), false, false, false, null, null, 0).store(iv);
StackValue.property(propertyDescriptor.getName(), owner, owner, typeMapper.mapType(propertyDescriptor.getType()), false, false, false, null, null, 0).store(iv);
}
}
@@ -488,7 +488,7 @@ public class JetTypeMapper {
for (ValueParameterDescriptor parameter : parameters) {
signatureVisitor.writeParameterType(JvmMethodParameterKind.VALUE);
mapType(parameter.getOutType(), signatureVisitor);
mapType(parameter.getType(), signatureVisitor);
signatureVisitor.writeParameterTypeEnd();
}
@@ -576,7 +576,7 @@ public class JetTypeMapper {
}
for (ValueParameterDescriptor parameter : parameters) {
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
mapType(parameter.getOutType(), signatureWriter);
mapType(parameter.getType(), signatureWriter);
signatureWriter.writeParameterTypeEnd();
}
@@ -617,7 +617,7 @@ public class JetTypeMapper {
signatureWriter.writeParametersEnd();
signatureWriter.writeReturnType();
mapType(descriptor.getOutType(), signatureWriter);
mapType(descriptor.getType(), signatureWriter);
signatureWriter.writeReturnTypeEnd();
JvmMethodSignature jvmMethodSignature = signatureWriter.makeJvmMethodSignature(name);
@@ -636,7 +636,7 @@ public class JetTypeMapper {
writeFormalTypeParameters(descriptor.getTypeParameters(), signatureWriter);
JetType outType = descriptor.getOutType();
JetType outType = descriptor.getType();
signatureWriter.writeParametersStart();
@@ -687,7 +687,7 @@ public class JetTypeMapper {
for (ValueParameterDescriptor parameter : parameters) {
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
mapType(parameter.getOutType(), signatureWriter);
mapType(parameter.getType(), signatureWriter);
signatureWriter.writeParameterTypeEnd();
}
@@ -864,7 +864,7 @@ public class JetTypeMapper {
else if (descriptor instanceof VariableDescriptor) {
Boolean aBoolean = bindingContext.get(BindingContext.MUST_BE_WRAPPED_IN_A_REF, (VariableDescriptor) descriptor);
if (aBoolean != null && aBoolean) {
JetType outType = ((VariableDescriptor) descriptor).getOutType();
JetType outType = ((VariableDescriptor) descriptor).getType();
return StackValue.sharedTypeForType(mapType(outType));
}
else {
@@ -61,7 +61,7 @@ public class ObjectOrClosureCodegen {
if (idx < 0) return null;
final Type sharedVarType = state.getTypeMapper().getSharedVarType(vd);
Type localType = state.getTypeMapper().mapType(vd.getOutType());
Type localType = state.getTypeMapper().mapType(vd.getType());
final Type type = sharedVarType != null ? sharedVarType : localType;
StackValue outerValue = StackValue.local(idx, type);
@@ -30,10 +30,6 @@ import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.InstructionAdapter;
import org.objectweb.asm.commons.Method;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static org.objectweb.asm.Opcodes.ACC_SYNTHETIC;
/**
* @author max
@@ -99,7 +95,7 @@ public class PropertyCodegen {
if(state.getStandardLibrary().isVolatile(propertyDescriptor)) {
modifiers |= Opcodes.ACC_VOLATILE;
}
FieldVisitor fieldVisitor = v.newField(p, modifiers, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getOutType()).getDescriptor(), null, value);
FieldVisitor fieldVisitor = v.newField(p, modifiers, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getType()).getDescriptor(), null, value);
AnnotationCodegen.forField(fieldVisitor).genAnnotations(propertyDescriptor, state.getTypeMapper());
}
}
@@ -179,7 +175,7 @@ public class PropertyCodegen {
if (kind != OwnerKind.NAMESPACE) {
iv.load(0, JetTypeMapper.TYPE_OBJECT);
}
final Type type = state.getTypeMapper().mapType(propertyDescriptor.getOutType());
final Type type = state.getTypeMapper().mapType(propertyDescriptor.getType());
if (kind instanceof OwnerKind.DelegateKind) {
OwnerKind.DelegateKind dk = (OwnerKind.DelegateKind) kind;
dk.getDelegate().put(JetTypeMapper.TYPE_OBJECT, iv);
@@ -240,7 +236,7 @@ public class PropertyCodegen {
if (v.generateCode() && (!isTrait || kind instanceof OwnerKind.DelegateKind)) {
mv.visitCode();
InstructionAdapter iv = new InstructionAdapter(mv);
final Type type = state.getTypeMapper().mapType(propertyDescriptor.getOutType());
final Type type = state.getTypeMapper().mapType(propertyDescriptor.getType());
int paramCode = 0;
if (kind != OwnerKind.NAMESPACE) {
iv.load(0, JetTypeMapper.TYPE_OBJECT);
@@ -593,7 +593,7 @@ public abstract class StackValue {
List<ValueParameterDescriptor> valueParameters = resolvedGetCall.getResultingDescriptor().getValueParameters();
int firstParamIndex = -1;
for(int i = valueParameters.size()-1; i >= 0; --i) {
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getOutType());
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType());
int sz = type.getSize();
frame.enterTemp(sz);
lastIndex += sz;
@@ -673,7 +673,7 @@ public abstract class StackValue {
int index = firstParamIndex;
for(int i = 0; i != valueParameters.size(); ++i) {
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getOutType());
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType());
int sz = type.getSize();
v.load(index-sz, type);
index -= sz;
@@ -701,7 +701,7 @@ public abstract class StackValue {
index = firstParamIndex;
for(int i = 0; i != valueParameters.size(); ++i) {
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getOutType());
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType());
int sz = type.getSize();
v.load(index-sz, type);
index -= sz;
@@ -725,7 +725,7 @@ public abstract class StackValue {
return false;
for (ValueParameterDescriptor valueParameter : valueParameters) {
if (codegen.typeMapper.mapType(valueParameter.getOutType()).getSize() != 1)
if (codegen.typeMapper.mapType(valueParameter.getType()).getSize() != 1)
return false;
}