コード例 #1
0
ファイル: AsmUtil.java プロジェクト: bashor/kotlin
  public static void genNotNullAssertionsForParameters(
      @NotNull InstructionAdapter v,
      @NotNull GenerationState state,
      @NotNull FunctionDescriptor descriptor,
      @NotNull FrameMap frameMap) {
    if (!state.isGenerateNotNullParamAssertions()) return;

    // Private method is not accessible from other classes, no assertions needed
    if (getVisibilityAccessFlag(descriptor) == ACC_PRIVATE) return;

    for (ValueParameterDescriptor parameter : descriptor.getValueParameters()) {
      JetType type = parameter.getReturnType();
      if (type == null || isNullableType(type)) continue;

      int index = frameMap.getIndex(parameter);
      Type asmType = state.getTypeMapper().mapReturnType(type);
      if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
        v.load(index, asmType);
        v.visitLdcInsn(descriptor.getName().asString());
        v.invokestatic(
            "jet/runtime/Intrinsics",
            "checkParameterIsNotNull",
            "(Ljava/lang/Object;Ljava/lang/String;)V");
      }
    }
  }