text:
#include "precompiled.hpp"
#include "interpreter/bytecodes.hpp"
#include "shark/llvmHeaders.hpp"
#include "shark/llvmValue.hpp"
#include "shark/sharkBlock.hpp"
#include "shark/sharkBuilder.hpp"
#include "shark/sharkConstant.hpp"
#include "shark/sharkState.hpp"
#include "shark/sharkValue.hpp"
#include "shark/shark_globals.hpp"
#include "utilities/debug.hpp"

using namespace llvm;

void SharkBlock::parse_bytecode(int start, int limit) {
  SharkValue *a, *b, *c, *d;
  int i;

  // Ensure the current state is initialized before we emit any code,
  // so that any setup code for the state is at the start of the block
  current_state();

  // Parse the bytecodes
  iter()->reset_to_bci(start);
  while (iter()->next_bci() < limit) {
    NOT_PRODUCT(a = b = c = d = NULL);
    iter()->next();

    if (SharkTraceBytecodes)
      tty->print_cr("%4d: %s", bci(), Bytecodes::name(bc()));

    if (has_trap() && trap_bci() == bci()) {
      do_trap(trap_request());
      return;
    }

    if (UseLoopSafepoints) {
      // XXX if a lcmp is followed by an if_?? then C2 maybe-inserts
      // the safepoint before the lcmp rather than before the if.
      // Maybe we should do this too.  See parse2.cpp for details.
      switch (bc()) {
      case Bytecodes::_goto:
      case Bytecodes::_ifnull:
      case Bytecodes::_ifnonnull:
      case Bytecodes::_if_acmpeq:
      case Bytecodes::_if_acmpne:
      case Bytecodes::_ifeq:
      case Bytecodes::_ifne:
      case Bytecodes::_iflt:
      case Bytecodes::_ifle:
      case Bytecodes::_ifgt:
      case Bytecodes::_ifge:
      case Bytecodes::_if_icmpeq:
      case Bytecodes::_if_icmpne:
      case Bytecodes::_if_icmplt:
      case Bytecodes::_if_icmple:
      case Bytecodes::_if_icmpgt:
      case Bytecodes::_if_icmpge:
        if (iter()->get_dest() <= bci())
          maybe_add_backedge_safepoint();
        break;

      case Bytecodes::_goto_w:
        if (iter()->get_far_dest() <= bci())
          maybe_add_backedge_safepoint();
        break;

      case Bytecodes::_tableswitch:
      case Bytecodes::_lookupswitch:
        if (switch_default_dest() <= bci()) {
          maybe_add_backedge_safepoint();
          break;
        }
        int len = switch_table_length();
        for (int i = 0; i < len; i++) {
          if (switch_dest(i) <= bci()) {
            maybe_add_backedge_safepoint();
            break;
          }
        }
        break;
      }
    }

    switch (bc()) {
    case Bytecodes::_nop:
      break;

    case Bytecodes::_aconst_null:
      push(SharkValue::null());
      break;

    case Bytecodes::_iconst_m1:
      push(SharkValue::jint_constant(-1));
      break;
    case Bytecodes::_iconst_0:
      push(SharkValue::jint_constant(0));
      break;
    case Bytecodes::_iconst_1:
      push(SharkValue::jint_constant(1));
      break;
    case Bytecodes::_iconst_2:
      push(SharkValue::jint_constant(2));
      break;
    case Bytecodes::_iconst_3:
      push(SharkValue::jint_constant(3));
      break;
    case Bytecodes::_iconst_4:
      push(SharkValue::jint_constant(4));
      break;
    case Bytecodes::_iconst_5:
      push(SharkValue::jint_constant(5));
      break;

    case Bytecodes::_lconst_0:
      push(SharkValue::jlong_constant(0));
      break;
    case Bytecodes::_lconst_1:
      push(SharkValue::jlong_constant(1));
      break;

    case Bytecodes::_fconst_0:
      push(SharkValue::jfloat_constant(0));
      break;
    case Bytecodes::_fconst_1:
      push(SharkValue::jfloat_constant(1));
      break;
    case Bytecodes::_fconst_2:
      push(SharkValue::jfloat_constant(2));
      break;

    case Bytecodes::_dconst_0:
      push(SharkValue::jdouble_constant(0));
      break;
    case Bytecodes::_dconst_1:
      push(SharkValue::jdouble_constant(1));
      break;

    case Bytecodes::_bipush:
      push(SharkValue::jint_constant(iter()->get_constant_u1()));
      break;
    case Bytecodes::_sipush:
      push(SharkValue::jint_constant(iter()->get_constant_u2()));
      break;

    case Bytecodes::_ldc:
    case Bytecodes::_ldc_w:
    case Bytecodes::_ldc2_w:
      push(SharkConstant::for_ldc(iter())->value(builder()));
      break;

    case Bytecodes::_iload_0:
    case Bytecodes::_lload_0:
    case Bytecodes::_fload_0:
    case Bytecodes::_dload_0:
    case Bytecodes::_aload_0:
      push(local(0));
      break;
    case Bytecodes::_iload_1:
    case Bytecodes::_lload_1:
    case Bytecodes::_fload_1:
    case Bytecodes::_dload_1:
    case Bytecodes::_aload_1:
      push(local(1));
      break;
    case Bytecodes::_iload_2:
    case Bytecodes::_lload_2:
    case Bytecodes::_fload_2:
    case Bytecodes::_dload_2:
    case Bytecodes::_aload_2:
      push(local(2));
      break;
    case Bytecodes::_iload_3:
    case Bytecodes::_lload_3:
    case Bytecodes::_fload_3:
    case Bytecodes::_dload_3:
    case Bytecodes::_aload_3:
      push(local(3));
      break;
    case Bytecodes::_iload:
    case Bytecodes::_lload:
    case Bytecodes::_fload:
    case Bytecodes::_dload:
    case Bytecodes::_aload:
      push(local(iter()->get_index()));
      break;

    case Bytecodes::_baload:
      do_aload(T_BYTE);
      break;
    case Bytecodes::_caload:
      do_aload(T_CHAR);
      break;
    case Bytecodes::_saload:
      do_aload(T_SHORT);
      break;
    case Bytecodes::_iaload:
      do_aload(T_INT);
      break;
    case Bytecodes::_laload:
      do_aload(T_LONG);
      break;
    case Bytecodes::_faload:
      do_aload(T_FLOAT);
      break;
    case Bytecodes::_daload:
      do_aload(T_DOUBLE);
      break;
    case Bytecodes::_aaload:
      do_aload(T_OBJECT);
      break;

    case Bytecodes::_istore_0:
    case Bytecodes::_lstore_0:
    case Bytecodes::_fstore_0:
    case Bytecodes::_dstore_0:
    case Bytecodes::_astore_0:
      set_local(0, pop());
      break;
    case Bytecodes::_istore_1:
    case Bytecodes::_lstore_1:
    case Bytecodes::_fstore_1:
    case Bytecodes::_dstore_1:
    case Bytecodes::_astore_1:
      set_local(1, pop());
      break;
    case Bytecodes::_istore_2:
    case Bytecodes::_lstore_2:
    case Bytecodes::_fstore_2:
    case Bytecodes::_dstore_2:
    case Bytecodes::_astore_2:
      set_local(2, pop());
      break;
    case Bytecodes::_istore_3:
    case Bytecodes::_lstore_3:
    case Bytecodes::_fstore_3:
    case Bytecodes::_dstore_3:
    case Bytecodes::_astore_3:
      set_local(3, pop());
      break;
    case Bytecodes::_istore:
    case Bytecodes::_lstore:
    case Bytecodes::_fstore:
    case Bytecodes::_dstore:
    case Bytecodes::_astore:
      set_local(iter()->get_index(), pop());
      break;

    case Bytecodes::_bastore:
      do_astore(T_BYTE);
      break;
    case Bytecodes::_castore:
      do_astore(T_CHAR);
      break;
    case Bytecodes::_sastore:
      do_astore(T_SHORT);
      break;
    case Bytecodes::_iastore:
      do_astore(T_INT);
      break;
    case Bytecodes::_lastore:
      do_astore(T_LONG);
      break;
    case Bytecodes::_fastore:
      do_astore(T_FLOAT);
      break;
    case Bytecodes::_dastore:
      do_astore(T_DOUBLE);
      break;
    case Bytecodes::_aastore:
      do_astore(T_OBJECT);
      break;

    case Bytecodes::_pop:
      xpop();
      break;
    case Bytecodes::_pop2:
      xpop();
      xpop();
      break;
    case Bytecodes::_swap:
      a = xpop();
      b = xpop();
      xpush(a);
      xpush(b);
      break;
    case Bytecodes::_dup:
      a = xpop();
      xpush(a);
      xpush(a);
      break;
    case Bytecodes::_dup_x1:
      a = xpop();
      b = xpop();
      xpush(a);
      xpush(b);
      xpush(a);
      break;
    case Bytecodes::_dup_x2:
      a = xpop();
      b = xpop();
      c = xpop();
      xpush(a);
      xpush(c);
      xpush(b);
      xpush(a);
      break;
    case Bytecodes::_dup2:
      a = xpop();
      b = xpop();
      xpush(b);
      xpush(a);
      xpush(b);
      xpush(a);
      break;
    case Bytecodes::_dup2_x1:
      a = xpop();
      b = xpop();
      c = xpop();
      xpush(b);
      xpush(a);
      xpush(c);
      xpush(b);
      xpush(a);
      break;
    case Bytecodes::_dup2_x2:
      a = xpop();
      b = xpop();
      c = xpop();
      d = xpop();
      xpush(b);
      xpush(a);
      xpush(d);
      xpush(c);
      xpush(b);
      xpush(a);
      break;

    case Bytecodes::_arraylength:
      do_arraylength();
      break;

    case Bytecodes::_getfield:
      do_getfield();
      break;
    case Bytecodes::_getstatic:
      do_getstatic();
      break;
    case Bytecodes::_putfield:
      do_putfield();
      break;
    case Bytecodes::_putstatic:
      do_putstatic();
      break;

    case Bytecodes::_iadd:
      b = pop();
      a = pop();
      push(SharkValue::create_jint(
        builder()->CreateAdd(a->jint_value(), b->jint_value()), false));
      break;
    case Bytecodes::_isub:
      b = pop();
      a = pop();
      push(SharkValue::create_jint(
        builder()->CreateSub(a->jint_value(), b->jint_value()), false));
      break;
    case Bytecodes::_imul:
      b = pop();
      a = pop();
      push(SharkValue::create_jint(
        builder()->CreateMul(a->jint_value(), b->jint_value()), false));
      break;
    case Bytecodes::_idiv:
      do_idiv();
      break;
    case Bytecodes::_irem:
      do_irem();
      break;
    case Bytecodes::_ineg:
      a = pop();
      push(SharkValue::create_jint(
        builder()->CreateNeg(a->jint_value()), a->zero_checked()));
      break;
    case Bytecodes::_ishl:
      b = pop();
      a = pop();
      push(SharkValue::create_jint(
        builder()->CreateShl(
          a->jint_value(),
          builder()->CreateAnd(
            b->jint_value(), LLVMValue::jint_constant(0x1f))), false));
      break;
    case Bytecodes::_ishr:
      b = pop();
      a = pop();
      push(SharkValue::create_jint(
        builder()->CreateAShr(
          a->jint_value(),
          builder()->CreateAnd(
            b->jint_value(), LLVMValue::jint_constant(0x1f))), false));
      break;
    case Bytecodes::_iushr:
      b = pop();
      a = pop();
      push(SharkValue::create_jint(
        builder()->CreateLShr(
          a->jint_value(),
          builder()->CreateAnd(
            b->jint_value(), LLVMValue::jint_constant(0x1f))), false));
      break;
    case Bytecodes::_iand:
      b = pop();
      a = pop();
      push(SharkValue::create_jint(
        builder()->CreateAnd(a->jint_value(), b->jint_value()), false));
      break;
    case Bytecodes::_ior:
      b = pop();
      a = pop();
      push(SharkValue::create_jint(
        builder()->CreateOr(a->jint_value(), b->jint_value()),
        a->zero_checked() && b->zero_checked()));
      break;
    case Bytecodes::_ixor:
      b = pop();
      a = pop();
      push(SharkValue::create_jint(
        builder()->CreateXor(a->jint_value(), b->jint_value()), false));
      break;

    case Bytecodes::_ladd:
      b = pop();
      a = pop();
      push(SharkValue::create_jlong(
        builder()->CreateAdd(a->jlong_value(), b->jlong_value()), false));
      break;
    case Bytecodes::_lsub:
      b = pop();
      a = pop();
      push(SharkValue::create_jlong(
        builder()->CreateSub(a->jlong_value(), b->jlong_value()), false));
      break;
    case Bytecodes::_lmul:
      b = pop();
      a = pop();
      push(SharkValue::create_jlong(
        builder()->CreateMul(a->jlong_value(), b->jlong_value()), false));
      break;
    case Bytecodes::_ldiv:
      do_ldiv();
      break;
    case Bytecodes::_lrem:
      do_lrem();
      break;
    case Bytecodes::_lneg:
      a = pop();
      push(SharkValue::create_jlong(
        builder()->CreateNeg(a->jlong_value()), a->zero_checked()));
      break;
    case Bytecodes::_lshl:
      b = pop();
      a = pop();
      push(SharkValue::create_jlong(
        builder()->CreateShl(
          a->jlong_value(),
          builder()->CreateIntCast(
            builder()->CreateAnd(
              b->jint_value(), LLVMValue::jint_constant(0x3f)),
            SharkType::jlong_type(), true)), false));
      break;
    case Bytecodes::_lshr:
      b = pop();
      a = pop();
      push(SharkValue::create_jlong(
        builder()->CreateAShr(
          a->jlong_value(),
          builder()->CreateIntCast(
            builder()->CreateAnd(
              b->jint_value(), LLVMValue::jint_constant(0x3f)),
            SharkType::jlong_type(), true)), false));
      break;
    case Bytecodes::_lushr:
      b = pop();
      a = pop();
      push(SharkValue::create_jlong(
        builder()->CreateLShr(
          a->jlong_value(),
          builder()->CreateIntCast(
            builder()->CreateAnd(
              b->jint_value(), LLVMValue::jint_constant(0x3f)),
            SharkType::jlong_type(), true)), false));
      break;
    case Bytecodes::_land:
      b = pop();
      a = pop();
      push(SharkValue::create_jlong(
        builder()->CreateAnd(a->jlong_value(), b->jlong_value()), false));
      break;
    case Bytecodes::_lor:
      b = pop();
      a = pop();
      push(SharkValue::create_jlong(
        builder()->CreateOr(a->jlong_value(), b->jlong_value()),
        a->zero_checked() && b->zero_checked()));
      break;
    case Bytecodes::_lxor:
      b = pop();
      a = pop();
      push(SharkValue::create_jlong(
        builder()->CreateXor(a->jlong_value(), b->jlong_value()), false));
      break;

    case Bytecodes::_fadd:
      b = pop();
      a = pop();
      push(SharkValue::create_jfloat(
        builder()->CreateFAdd(a->jfloat_value(), b->jfloat_value())));
      break;
    case Bytecodes::_fsub:
      b = pop();
      a = pop();
      push(SharkValue::create_jfloat(
        builder()->CreateFSub(a->jfloat_value(), b->jfloat_value())));
      break;
    case Bytecodes::_fmul:
      b = pop();
      a = pop();
      push(SharkValue::create_jfloat(
        builder()->CreateFMul(a->jfloat_value(), b->jfloat_value())));
      break;
    case Bytecodes::_fdiv:
      b = pop();
      a = pop();
      push(SharkValue::create_jfloat(
        builder()->CreateFDiv(a->jfloat_value(), b->jfloat_value())));
      break;
    case Bytecodes::_frem:
      b = pop();
      a = pop();
      push(SharkValue::create_jfloat(
        builder()->CreateFRem(a->jfloat_value(), b->jfloat_value())));
      break;
    case Bytecodes::_fneg:
      a = pop();
      push(SharkValue::create_jfloat(
        builder()->CreateFNeg(a->jfloat_value())));
      break;

    case Bytecodes::_dadd:
      b = pop();
      a = pop();
      push(SharkValue::create_jdouble(
        builder()->CreateFAdd(a->jdouble_value(), b->jdouble_value())));
      break;
    case Bytecodes::_dsub:
      b = pop();
      a = pop();
      push(SharkValue::create_jdouble(
        builder()->CreateFSub(a->jdouble_value(), b->jdouble_value())));
      break;
    case Bytecodes::_dmul:
      b = pop();
      a = pop();
      push(SharkValue::create_jdouble(
        builder()->CreateFMul(a->jdouble_value(), b->jdouble_value())));
      break;
    case Bytecodes::_ddiv:
      b = pop();
      a = pop();
      push(SharkValue::create_jdouble(
        builder()->CreateFDiv(a->jdouble_value(), b->jdouble_value())));
      break;
    case Bytecodes::_drem:
      b = pop();
      a = pop();
      push(SharkValue::create_jdouble(
        builder()->CreateFRem(a->jdouble_value(), b->jdouble_value())));
      break;
    case Bytecodes::_dneg:
      a = pop();
      push(SharkValue::create_jdouble(
        builder()->CreateFNeg(a->jdouble_value())));
      break;

    case Bytecodes::_iinc:
      i = iter()->get_index();
      set_local(
        i,
        SharkValue::create_jint(
          builder()->CreateAdd(
            LLVMValue::jint_constant(iter()->get_iinc_con()),
            local(i)->jint_value()), false));
      break;

    case Bytecodes::_lcmp:
      do_lcmp();
      break;

    case Bytecodes::_fcmpl:
      do_fcmp(false, false);
      break;
    case Bytecodes::_fcmpg:
      do_fcmp(false, true);
      break;
    case Bytecodes::_dcmpl:
      do_fcmp(true, false);
      break;
    case Bytecodes::_dcmpg:
      do_fcmp(true, true);
      break;

    case Bytecodes::_i2l:
      a = pop();
      push(SharkValue::create_jlong(
        builder()->CreateIntCast(
          a->jint_value(), SharkType::jlong_type(), true), a->zero_checked()));
      break;
    case Bytecodes::_i2f:
      push(SharkValue::create_jfloat(
        builder()->CreateSIToFP(
          pop()->jint_value(), SharkType::jfloat_type())));
      break;
    case Bytecodes::_i2d:
      push(SharkValue::create_jdouble(
        builder()->CreateSIToFP(
          pop()->jint_value(), SharkType::jdouble_type())));
      break;

    case Bytecodes::_l2i:
      push(SharkValue::create_jint(
        builder()->CreateIntCast(
          pop()->jlong_value(), SharkType::jint_type(), true), false));
      break;
    case Bytecodes::_l2f:
      push(SharkValue::create_jfloat(
        builder()->CreateSIToFP(
          pop()->jlong_value(), SharkType::jfloat_type())));
      break;
    case Bytecodes::_l2d:
      push(SharkValue::create_jdouble(
        builder()->CreateSIToFP(
          pop()->jlong_value(), SharkType::jdouble_type())));
      break;

    case Bytecodes::_f2i:
      push(SharkValue::create_jint(
        builder()->CreateCall(
          builder()->f2i(), pop()->jfloat_value()), false));
      break;
    case Bytecodes::_f2l:
      push(SharkValue::create_jlong(
        builder()->CreateCall(
          builder()->f2l(), pop()->jfloat_value()), false));
      break;
    case Bytecodes::_f2d:
      push(SharkValue::create_jdouble(
        builder()->CreateFPExt(
          pop()->jfloat_value(), SharkType::jdouble_type())));
      break;

    case Bytecodes::_d2i:
      push(SharkValue::create_jint(
        builder()->CreateCall(
          builder()->d2i(), pop()->jdouble_value()), false));
      break;
    case Bytecodes::_d2l:
      push(SharkValue::create_jlong(
        builder()->CreateCall(
          builder()->d2l(), pop()->jdouble_value()), false));
      break;
    case Bytecodes::_d2f:
      push(SharkValue::create_jfloat(
        builder()->CreateFPTrunc(
          pop()->jdouble_value(), SharkType::jfloat_type())));
      break;

    case Bytecodes::_i2b:
      push(SharkValue::create_jint(
        builder()->CreateAShr(
          builder()->CreateShl(
            pop()->jint_value(),
            LLVMValue::jint_constant(24)),
          LLVMValue::jint_constant(24)), false));
      break;
    case Bytecodes::_i2c:
      push(SharkValue::create_jint(
        builder()->CreateAnd(
            pop()->jint_value(),
            LLVMValue::jint_constant(0xffff)), false));
      break;
    case Bytecodes::_i2s:
      push(SharkValue::create_jint(
        builder()->CreateAShr(
          builder()->CreateShl(
            pop()->jint_value(),
            LLVMValue::jint_constant(16)),
          LLVMValue::jint_constant(16)), false));
      break;

    case Bytecodes::_return:
      do_return(T_VOID);
      break;
    case Bytecodes::_ireturn:
      do_return(T_INT);
      break;
    case Bytecodes::_lreturn:
      do_return(T_LONG);
      break;
    case Bytecodes::_freturn:
      do_return(T_FLOAT);
      break;
    case Bytecodes::_dreturn:
      do_return(T_DOUBLE);
      break;
    case Bytecodes::_areturn:
      do_return(T_OBJECT);
      break;

    case Bytecodes::_athrow:
      do_athrow();
      break;

    case Bytecodes::_goto:
    case Bytecodes::_goto_w:
      do_goto();
      break;

    case Bytecodes::_jsr:
    case Bytecodes::_jsr_w:
      do_jsr();
      break;

    case Bytecodes::_ret:
      do_ret();
      break;

    case Bytecodes::_ifnull:
      do_if(ICmpInst::ICMP_EQ, SharkValue::null(), pop());
      break;
    case Bytecodes::_ifnonnull:
      do_if(ICmpInst::ICMP_NE, SharkValue::null(), pop());
      break;
    case Bytecodes::_if_acmpeq:
      b = pop();
      a = pop();
      do_if(ICmpInst::ICMP_EQ, b, a);
      break;
    case Bytecodes::_if_acmpne:
      b = pop();
      a = pop();
      do_if(ICmpInst::ICMP_NE, b, a);
      break;
    case Bytecodes::_ifeq:
      do_if(ICmpInst::ICMP_EQ, SharkValue::jint_constant(0), pop());
      break;
    case Bytecodes::_ifne:
      do_if(ICmpInst::ICMP_NE, SharkValue::jint_constant(0), pop());
      break;
    case Bytecodes::_iflt:
      do_if(ICmpInst::ICMP_SLT, SharkValue::jint_constant(0), pop());
      break;
    case Bytecodes::_ifle:
      do_if(ICmpInst::ICMP_SLE, SharkValue::jint_constant(0), pop());
      break;
    case Bytecodes::_ifgt:
      do_if(ICmpInst::ICMP_SGT, SharkValue::jint_constant(0), pop());
      break;
    case Bytecodes::_ifge:
      do_if(ICmpInst::ICMP_SGE, SharkValue::jint_constant(0), pop());
      break;
    case Bytecodes::_if_icmpeq:
      b = pop();
      a = pop();
      do_if(ICmpInst::ICMP_EQ, b, a);
      break;
    case Bytecodes::_if_icmpne:
      b = pop();
      a = pop();
      do_if(ICmpInst::ICMP_NE, b, a);
      break;
    case Bytecodes::_if_icmplt:
      b = pop();
      a = pop();
      do_if(ICmpInst::ICMP_SLT, b, a);
      break;
    case Bytecodes::_if_icmple:
      b = pop();
      a = pop();
      do_if(ICmpInst::ICMP_SLE, b, a);
      break;
    case Bytecodes::_if_icmpgt:
      b = pop();
      a = pop();
      do_if(ICmpInst::ICMP_SGT, b, a);
      break;
    case Bytecodes::_if_icmpge:
      b = pop();
      a = pop();
      do_if(ICmpInst::ICMP_SGE, b, a);
      break;

    case Bytecodes::_tableswitch:
    case Bytecodes::_lookupswitch:
      do_switch();
      break;

    case Bytecodes::_invokestatic:
    case Bytecodes::_invokespecial:
    case Bytecodes::_invokevirtual:
    case Bytecodes::_invokeinterface:
      do_call();
      break;

    case Bytecodes::_instanceof:
      // This is a very common construct:
      //
      //  if (object instanceof Klass) {
      //    something = (Klass) object;
      //    ...
      //  }
      //
      // which gets compiled to something like this:
      //
      //  28: aload 9
      //  30: instanceof <Class Klass>
      //  33: ifeq 52
      //  36: aload 9
      //  38: checkcast <Class Klass>
      //
      // Handling both bytecodes at once allows us
      // to eliminate the checkcast.
      if (iter()->next_bci() < limit &&
          (iter()->next_bc() == Bytecodes::_ifeq ||
           iter()->next_bc() == Bytecodes::_ifne) &&
          (!UseLoopSafepoints ||
           iter()->next_get_dest() > iter()->next_bci())) {
        if (maybe_do_instanceof_if()) {
          iter()->next();
          if (SharkTraceBytecodes)
            tty->print_cr("%4d: %s", bci(), Bytecodes::name(bc()));
          break;
        }
      }
      // fall through
    case Bytecodes::_checkcast:
      do_instance_check();
      break;

    case Bytecodes::_new:
      do_new();
      break;
    case Bytecodes::_newarray:
      do_newarray();
      break;
    case Bytecodes::_anewarray:
      do_anewarray();
      break;
    case Bytecodes::_multianewarray:
      do_multianewarray();
      break;

    case Bytecodes::_monitorenter:
      do_monitorenter();
      break;
    case Bytecodes::_monitorexit:
      do_monitorexit();
      break;

    default:
      ShouldNotReachHere();
    }
  }
}

SharkState* SharkBlock::initial_current_state() {
  return entry_state()->copy();
}

int SharkBlock::switch_default_dest() {
  return iter()->get_dest_table(0);
}

int SharkBlock::switch_table_length() {
  switch(bc()) {
  case Bytecodes::_tableswitch:
    return iter()->get_int_table(2) - iter()->get_int_table(1) + 1;

  case Bytecodes::_lookupswitch:
    return iter()->get_int_table(1);

  default:
    ShouldNotReachHere();
  }
}

int SharkBlock::switch_key(int i) {
  switch(bc()) {
  case Bytecodes::_tableswitch:
    return iter()->get_int_table(1) + i;

  case Bytecodes::_lookupswitch:
    return iter()->get_int_table(2 + 2 * i);

  default:
    ShouldNotReachHere();
  }
}

int SharkBlock::switch_dest(int i) {
  switch(bc()) {
  case Bytecodes::_tableswitch:
    return iter()->get_dest_table(i + 3);

  case Bytecodes::_lookupswitch:
    return iter()->get_dest_table(2 + 2 * i + 1);

  default:
    ShouldNotReachHere();
  }
}

void SharkBlock::do_div_or_rem(bool is_long, bool is_rem) {
  SharkValue *sb = pop();
  SharkValue *sa = pop();

  check_divide_by_zero(sb);

  Value *a, *b, *p, *q;
  if (is_long) {
    a = sa->jlong_value();
    b = sb->jlong_value();
    p = LLVMValue::jlong_constant(0x8000000000000000LL);
    q = LLVMValue::jlong_constant(-1);
  }
  else {
    a = sa->jint_value();
    b = sb->jint_value();
    p = LLVMValue::jint_constant(0x80000000);
    q = LLVMValue::jint_constant(-1);
  }

  BasicBlock *ip           = builder()->GetBlockInsertionPoint();
  BasicBlock *special_case = builder()->CreateBlock(ip, "special_case");
  BasicBlock *general_case = builder()->CreateBlock(ip, "general_case");
  BasicBlock *done         = builder()->CreateBlock(ip, "done");

  builder()->CreateCondBr(
    builder()->CreateAnd(
      builder()->CreateICmpEQ(a, p),
      builder()->CreateICmpEQ(b, q)),
    special_case, general_case);

  builder()->SetInsertPoint(special_case);
  Value *special_result;
  if (is_rem) {
    if (is_long)
      special_result = LLVMValue::jlong_constant(0);
    else
      special_result = LLVMValue::jint_constant(0);
  }
  else {
    special_result = a;
  }
  builder()->CreateBr(done);

  builder()->SetInsertPoint(general_case);
  Value *general_result;
  if (is_rem)
    general_result = builder()->CreateSRem(a, b);
  else
    general_result = builder()->CreateSDiv(a, b);
  builder()->CreateBr(done);

  builder()->SetInsertPoint(done);
  PHINode *result;
  if (is_long)
    result = builder()->CreatePHI(SharkType::jlong_type(), "result");
  else
    result = builder()->CreatePHI(SharkType::jint_type(), "result");
  result->addIncoming(special_result, special_case);
  result->addIncoming(general_result, general_case);

  if (is_long)
    push(SharkValue::create_jlong(result, false));
  else
    push(SharkValue::create_jint(result, false));
}

void SharkBlock::do_field_access(bool is_get, bool is_field) {
  bool will_link;
  ciField *field = iter()->get_field(will_link);
  assert(will_link, "typeflow responsibility");
  assert(is_field != field->is_static(), "mismatch");

  // Pop the value off the stack where necessary
  SharkValue *value = NULL;
  if (!is_get)
    value = pop();

  // Find the object we're accessing, if necessary
  Value *object = NULL;
  if (is_field) {
    SharkValue *value = pop();
    check_null(value);
    object = value->generic_value();
  }
  if (is_get && field->is_constant()) {
    SharkConstant *constant = SharkConstant::for_field(iter());
    if (constant->is_loaded())
      value = constant->value(builder());
  }
  if (!is_get || value == NULL) {
    if (!is_field)
      object = builder()->CreateInlineOop(field->holder());

    BasicType   basic_type = field->type()->basic_type();
    const Type *stack_type = SharkType::to_stackType(basic_type);
    const Type *field_type = SharkType::to_arrayType(basic_type);

    Value *addr = builder()->CreateAddressOfStructEntry(
      object, in_ByteSize(field->offset_in_bytes()),
      PointerType::getUnqual(field_type),
      "addr");

    // Do the access
    if (is_get) {
      Value *field_value = builder()->CreateLoad(addr);

      if (field_type != stack_type) {
        field_value = builder()->CreateIntCast(
          field_value, stack_type, basic_type != T_CHAR);
      }

      value = SharkValue::create_generic(field->type(), field_value, false);
    }
    else {
      Value *field_value = value->generic_value();

      if (field_type != stack_type) {
        field_value = builder()->CreateIntCast(
          field_value, field_type, basic_type != T_CHAR);
      }

      builder()->CreateStore(field_value, addr);

      if (!field->type()->is_primitive_type())
        builder()->CreateUpdateBarrierSet(oopDesc::bs(), addr);

      if (field->is_volatile())
        builder()->CreateMemoryBarrier(SharkBuilder::BARRIER_STORELOAD);
    }
  }

  // Push the value onto the stack where necessary
  if (is_get)
    push(value);
}

void SharkBlock::do_lcmp() {
  Value *b = pop()->jlong_value();
  Value *a = pop()->jlong_value();

  BasicBlock *ip   = builder()->GetBlockInsertionPoint();
  BasicBlock *ne   = builder()->CreateBlock(ip, "lcmp_ne");
  BasicBlock *lt   = builder()->CreateBlock(ip, "lcmp_lt");
  BasicBlock *gt   = builder()->CreateBlock(ip, "lcmp_gt");
  BasicBlock *done = builder()->CreateBlock(ip, "done");

  BasicBlock *eq = builder()->GetInsertBlock();
  builder()->CreateCondBr(builder()->CreateICmpEQ(a, b), done, ne);

  builder()->SetInsertPoint(ne);
  builder()->CreateCondBr(builder()->CreateICmpSLT(a, b), lt, gt);

  builder()->SetInsertPoint(lt);
  builder()->CreateBr(done);

  builder()->SetInsertPoint(gt);
  builder()->CreateBr(done);

  builder()->SetInsertPoint(done);
  PHINode *result = builder()->CreatePHI(SharkType::jint_type(), "result");
  result->addIncoming(LLVMValue::jint_constant(-1), lt);
  result->addIncoming(LLVMValue::jint_constant(0),  eq);
  result->addIncoming(LLVMValue::jint_constant(1),  gt);

  push(SharkValue::create_jint(result, false));
}

void SharkBlock::do_fcmp(bool is_double, bool unordered_is_greater) {
  Value *a, *b;
  if (is_double) {
    b = pop()->jdouble_value();
    a = pop()->jdouble_value();
  }
  else {
    b = pop()->jfloat_value();
    a = pop()->jfloat_value();
  }

  BasicBlock *ip      = builder()->GetBlockInsertionPoint();
  BasicBlock *ordered = builder()->CreateBlock(ip, "ordered");
  BasicBlock *ge      = builder()->CreateBlock(ip, "fcmp_ge");
  BasicBlock *lt      = builder()->CreateBlock(ip, "fcmp_lt");
  BasicBlock *eq      = builder()->CreateBlock(ip, "fcmp_eq");
  BasicBlock *gt      = builder()->CreateBlock(ip, "fcmp_gt");
  BasicBlock *done    = builder()->CreateBlock(ip, "done");

  builder()->CreateCondBr(
    builder()->CreateFCmpUNO(a, b),
    unordered_is_greater ? gt : lt, ordered);

  builder()->SetInsertPoint(ordered);
  builder()->CreateCondBr(builder()->CreateFCmpULT(a, b), lt, ge);

  builder()->SetInsertPoint(ge);
  builder()->CreateCondBr(builder()->CreateFCmpUGT(a, b), gt, eq);

  builder()->SetInsertPoint(lt);
  builder()->CreateBr(done);

  builder()->SetInsertPoint(gt);
  builder()->CreateBr(done);

  builder()->SetInsertPoint(eq);
  builder()->CreateBr(done);

  builder()->SetInsertPoint(done);
  PHINode *result = builder()->CreatePHI(SharkType::jint_type(), "result");
  result->addIncoming(LLVMValue::jint_constant(-1), lt);
  result->addIncoming(LLVMValue::jint_constant(0),  eq);
  result->addIncoming(LLVMValue::jint_constant(1),  gt);

  push(SharkValue::create_jint(result, false));
}

void SharkBlock::emit_IR() {
  ShouldNotCallThis();
}

SharkState* SharkBlock::entry_state() {
  ShouldNotCallThis();
}

void SharkBlock::do_zero_check(SharkValue* value) {
  ShouldNotCallThis();
}

void SharkBlock::maybe_add_backedge_safepoint() {
  ShouldNotCallThis();
}

bool SharkBlock::has_trap() {
  return false;
}

int SharkBlock::trap_request() {
  ShouldNotCallThis();
}

int SharkBlock::trap_bci() {
  ShouldNotCallThis();
}

void SharkBlock::do_trap(int trap_request) {
  ShouldNotCallThis();
}

void SharkBlock::do_arraylength() {
  ShouldNotCallThis();
}

void SharkBlock::do_aload(BasicType basic_type) {
  ShouldNotCallThis();
}

void SharkBlock::do_astore(BasicType basic_type) {
  ShouldNotCallThis();
}

void SharkBlock::do_return(BasicType type) {
  ShouldNotCallThis();
}

void SharkBlock::do_athrow() {
  ShouldNotCallThis();
}

void SharkBlock::do_goto() {
  ShouldNotCallThis();
}

void SharkBlock::do_jsr() {
  ShouldNotCallThis();
}

void SharkBlock::do_ret() {
  ShouldNotCallThis();
}

void SharkBlock::do_if(ICmpInst::Predicate p, SharkValue* b, SharkValue* a) {
  ShouldNotCallThis();
}

void SharkBlock::do_switch() {
  ShouldNotCallThis();
}

void SharkBlock::do_call() {
  ShouldNotCallThis();
}

void SharkBlock::do_instance_check() {
  ShouldNotCallThis();
}

bool SharkBlock::maybe_do_instanceof_if() {
  ShouldNotCallThis();
}

void SharkBlock::do_new() {
  ShouldNotCallThis();
}

void SharkBlock::do_newarray() {
  ShouldNotCallThis();
}

void SharkBlock::do_anewarray() {
  ShouldNotCallThis();
}

void SharkBlock::do_multianewarray() {
  ShouldNotCallThis();
}

void SharkBlock::do_monitorenter() {
  ShouldNotCallThis();
}

void SharkBlock::do_monitorexit() {
  ShouldNotCallThis();
}


text:
import {Component, ViewEncapsulation} from '@angular/core';
import {FormGroup, AbstractControl, FormBuilder, Validators} from '@angular/forms';

@Component({
  selector: 'login',
  encapsulation: ViewEncapsulation.None,
  styles: [require('./login.scss')],
  template: require('./login.html'),
})
export class Login {

  public form:FormGroup;
  public email:AbstractControl;
  public password:AbstractControl;
  public submitted:boolean = false;

  constructor(fb:FormBuilder) {
    this.form = fb.group({
      'email': ['', Validators.compose([Validators.required, Validators.minLength(4)])],
      'password': ['', Validators.compose([Validators.required, Validators.minLength(4)])]
    });

    this.email = this.form.controls['email'];
    this.password = this.form.controls['password'];
  }

  public onSubmit(values:Object):void {
    this.submitted = true;
    if (this.form.valid) {
      // your code goes here
      // console.log(values);
    }
  }
}

redpajama_set_name: RedPajamaGithub


text:
package net.md_5.bungee.protocol;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.CorruptedFrameException;

import java.util.List;

public class Varint21FrameDecoder extends ByteToMessageDecoder
{

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
    {
        in.markReaderIndex();

        final byte[] buf = new byte[ 3 ];
        for ( int i = 0; i < buf.length; i++ )
        {
            if ( !in.isReadable() )
            {
                in.resetReaderIndex();
                return;
            }

            buf[i] = in.readByte();
            if ( buf[i] >= 0 )
            {
                int length = DefinedPacket.readVarInt( Unpooled.wrappedBuffer( buf ) );

                if ( in.readableBytes() < length )
                {
                    in.resetReaderIndex();
                    return;
                } else
                {
                    out.add( in.readBytes( length ) );
                    return;
                }
            }
        }

        throw new CorruptedFrameException( "length wider than 21-bit" );
    }
}


text:
<?php

namespace League\CommonMark;

use League\CommonMark\Block\Element\Document;

interface DocParserInterface
{
    /**
     * @param string $input
     *
     * @throws \RuntimeException
     *
     * @return Document
     */
    public function parse(string $input): Document;
}


text:
using System.Globalization;

namespace NMoneys.Support
{
	internal static class Culture
	{
		public static CultureInfo Get(string name)
		{
#if NET
			return CultureInfo.GetCultureInfo(name);
#else
			return new CultureInfo(name);
#endif
		}
	}
}


text:
using ElectronicObserver.Data.Battle.Phase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ElectronicObserver.Data.Battle
{

	/// <summary>
	/// 通常艦隊 vs 通常艦隊 航空戦
	/// </summary>
	public class BattleAirBattle : BattleDay
	{

		public PhaseAirBattle AirBattle2 { get; protected set; }

		public override void LoadFromResponse(string apiname, dynamic data)
		{
			base.LoadFromResponse(apiname, (object)data);

			JetBaseAirAttack = new PhaseJetBaseAirAttack(this, "噴式基地航空隊攻撃");
			JetAirBattle = new PhaseJetAirBattle(this, "噴式航空戦");
			BaseAirAttack = new PhaseBaseAirAttack(this, "基地航空隊攻撃");
			FriendlySupportInfo = new PhaseFriendlySupportInfo(this, "友軍艦隊");
			FriendlyAirBattle = new PhaseFriendlyAirBattle(this, "友軍支援航空攻撃");
			AirBattle = new PhaseAirBattle(this, "第一次航空戦");
			Support = new PhaseSupport(this, "支援攻撃");
			AirBattle2 = new PhaseAirBattle(this, "第二次航空戦", "2");

			foreach (var phase in GetPhases())
				phase.EmulateBattle(_resultHPs, _attackDamages);

		}

		public override string APIName => "api_req_sortie/airbattle";

		public override string BattleName => "通常艦隊 航空戦";

		public override IEnumerable<PhaseBase> GetPhases()
		{
			yield return Initial;
			yield return Searching;
			yield return JetBaseAirAttack;
			yield return JetAirBattle;
			yield return BaseAirAttack;
			yield return FriendlySupportInfo;
			yield return FriendlyAirBattle;
			yield return AirBattle;
			yield return Support;
			yield return AirBattle2;
		}

	}
}


text:
/**
 * This package and its subpackages contains interface and classes that constitute the CloudKeeper domain model.
 */
@NonNullByDefault
package xyz.cloudkeeper.model;

import xyz.cloudkeeper.model.util.NonNullByDefault;


text:
<?php

namespace Symfony\Component\Notifier\Bridge\Sms77\Tests;

use Symfony\Component\Notifier\Bridge\Sms77\Sms77Transport;
use Symfony\Component\Notifier\Message\ChatMessage;
use Symfony\Component\Notifier\Message\MessageInterface;
use Symfony\Component\Notifier\Message\SmsMessage;
use Symfony\Component\Notifier\Test\TransportTestCase;
use Symfony\Contracts\HttpClient\HttpClientInterface;

final class Sms77TransportTest extends TransportTestCase
{
    public function createTransport(HttpClientInterface $client = null, string $from = null): Sms77Transport
    {
        return new Sms77Transport('apiKey', $from, $client ?? $this->createMock(HttpClientInterface::class));
    }

    public function toStringProvider(): iterable
    {
        yield ['sms77://gateway.sms77.io', $this->createTransport()];
        yield ['sms77://gateway.sms77.io?from=TEST', $this->createTransport(null, 'TEST')];
    }

    public function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0611223344', 'Hello!')];
    }

    public function unsupportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
        yield [$this->createMock(MessageInterface::class)];
    }
}


text:
@import CoreLocation;
@import CoreBluetooth;
@import MapKit;

//NSLocationWhenInUseUsageDescription key specified in your Info.plist
//NSLocationAlwaysUsageDescription key specified in your Info.plist
@interface WTLocation : NSObject<CLLocationManagerDelegate, CBPeripheralManagerDelegate>

@property (nonatomic, strong) CLLocationManager *locationManager;

//@property (nonatomic, weak) IBOutlet UITableView *beaconTableView;
//
//@property (nonatomic, weak) IBOutlet UIScrollView *logScrollView;
//@property (nonatomic, weak) IBOutlet UILabel *currentLocationLabel;

@property (nonatomic, weak) id<CLLocationManagerDelegate> locationDelegate;

+ (instancetype)sharedManager;

- (void)openSettingApp;
- (void)requestWhenInUseAuthorization;
- (void)requestAlwaysAuthorization;

@end

@protocol MyProtocol <NSObject>

@end

#import <CoreLocation/CoreLocation.h>

//UIRequiredDeviceCapabilities relevant to location services
//location-services string if you require location services in general.
//gps string if your app requires the accuracy offered only by GPS hardware.
@interface WTLocation(location)<CLLocationManagerDelegate>

- (BOOL)isLocationServicesEnabled;

- (CLActivityType)currentActivityType;
- (void)changeActivityType:(CLActivityType)activityType;

- (void)startStandardUpdates;
- (void)stopStandardUpdates;

- (void)startSignificantChangeUpdates;
- (void)stopSignificantChangeUpdates;

// background
- (BOOL)isDeferredLocationUpdatesAvailable;

@end

//Devices with a magnetometer can report the direction in which a device is pointing, also known as its heading.
//Devices with GPS hardware can report the direction in which a device is moving, also known as its course. (use location.course)

//UIRequiredDeviceCapabilities relevant to location services
//magnetometer—Include this string if your app requires heading information.
//gps—Include this string if your app requires course-related information.
//In both cases, also include the location-services string.
@interface WTLocation(heading)<CLLocationManagerDelegate>

@end

@interface WTLocation(GeographicalRegions)<CLLocationManagerDelegate>

@end

@interface WTLocation(monitor)<CLLocationManagerDelegate, CBPeripheralManagerDelegate>

//@property (nonatomic, strong) CBPeripheralManager *peripheralManager;
//@property (nonatomic, strong) CLBeaconRegion *advertiseBeaconRegion;

@end

@interface WTLocation(range)<CLLocationManagerDelegate, CBPeripheralManagerDelegate>

//@property (nonatomic, strong) CBPeripheralManager *peripheralManager;
//@property (nonatomic, strong) CLBeaconRegion *advertiseBeaconRegion;

@end

#define kWTLocationProximityUUID @"kWTLocationProximityUUID"
#define kWTLocationIdentifier @"kWTLocationIdentifier"
#define kWTLocationMajorValue @"kWTLocationMajorValue"
#define kWTLocationMinorValue @"kWTLocationMinorValue"

#import <CoreBluetooth/CoreBluetooth.h>
@interface WTLocation(advertise)<CLLocationManagerDelegate, CBPeripheralManagerDelegate>

@property (nonatomic, strong) CBPeripheralManager *peripheralManager;
@property (nonatomic, strong) CLBeaconRegion *advertiseBeaconRegion;

@end

@protocol aaaaa <NSObject>

@end


text:
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you 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.
-->

<<<<<<< HEAD
# Apache<sup>®</sup> DataSketches™
## A software library of stochastic streaming algorithms

Apache DataSketches is an open source, high-performance library of stochastic streaming algorithms commonly called "sketches" in the data sciences. Sketches are small, stateful programs that process massive data as a stream and provide approximate answers, with mathematical guarantees, to computationally difficult queries orders-of-magnitude faster than traditional, exact methods.

We started this project at Yahoo in 2012 and went open-source in 2015. In December 2020, we became a Top-Level Project at the Apache Software Foundation.

[Please visit us at datasketches.apache.org!](https://datasketches.apache.org)

* [Ways to contact us](https://datasketches.apache.org/docs/Community/index.html)

* [Finding our code releases](https://datasketches.apache.org/docs/Community/Downloads.html)

* [Transitioning from our previous GitHub site](https://datasketches.apache.org/docs/Community/Transitioning.html)

=======
# Apache DataSketches (incubating)
## A software library of stochastic streaming algorithms

Apache DataSketches is an open source, high-performance library of stochastic streaming algorithms commonly called "sketches" in the data sciences. Sketches are small, stateful programs that process massive data as a stream and provide approximate answers, with mathematical guarantees, to computationally difficult queries orders-of-magnitude faster than traditional, exact methods.

After 8 years of development and 5 years as in Open Source, we have begun the important migration from a stand-alone GitHub site to being a member of the Apache Software Foundation community.  While we undergo this migration, we beg your patience.

* Ways to contact us:
    * We have two ASF [the-ASF.slack.com](http://the-ASF.slack.com) slack channels:
        * datasketches -- general user questions
        * datasketches-dev -- similar to our Apache [dev@datasketches.apache.org](mailto:dev@datasketches.apache.org), except more interactive, but not as easily searchable.
    * For discussions about problems with any of our sketch repository components (core-java, core-cpp, Hive, Pig, Vector, Android, etc.)
        * [Google-groups forum](https://groups.google.com/forum/#!forum/sketches-user)
    * For issues about a specific component, please open issues on the appropriate GitHub repository listed below.
    * If you wish to contribute to our sketch development please contact us on our development email list
        * [dev@datasketches.apache.org](mailto:dev@datasketches.apache.org)

* Finding our code releases:
    * Apache releases (versions 1.X.X):
        * Zip source: [dist.apache.org/repos/dist/release/incubator/datasketches/](https://dist.apache.org/repos/dist/release/incubator/datasketches/)
        * Jar Artifacts (Java only): [repository.apache.org/#nexus-search;quick~datasketches](https://repository.apache.org/#nexus-search;quick~datasketches)
    * Pre-Apache releases (versions 0.X.X)
        * Jar Artifacts (Java only): [search.maven.org/classic/#search%7Cga%7C1%7Ccom.yahoo.datasketches](https://search.maven.org/classic/#search%7Cga%7C1%7Ccom.yahoo.datasketches)

* As the repositories under GitHub.io/DataSketches migrate they will disapear from the the GitHub.com/DataSketches organization page. Please refer to this list be directed to the new locations.
  * View all of our Apache DataSketches repositories as a [list](https://github.com/apache?utf8=%E2%9C%93&q=datasketches)
  * Names in **BOLD** are of the old github.com/datasketches/ organization repositories.

* Web Site and Web Site Source
  * **datasketches.github.io** moved to [datasketches.apache.org](https://datasketches.apache.org)
  * **github.com/DataSketches/DataSketches.github.io** moved to [github.com/apache/incubator-datasketches-website](https://github.com/apache/incubator-datasketches-website)

* Java Core
  * **sketches-core** moved to [incubator-datasketches-java](https://github.com/apache/incubator-datasketches-java) This is the **core** library that contains all sketch algorithms written in Java.
  * **memory** moved to [incubator-datasketches-memory](https://github.com/apache/incubator-datasketches-memory) Low-level component used by other java components.

* Java Adaptors
  * **sketches-hive** moved to [incubator-datasketches-hive](https://github.com/apache/incubator-datasketches-hive) Adapts the Java core to Apache Hive.
  * **sketches-pig** moved to [incubator-datasketches-pig](https://github.com/apache/incubator-datasketches-pig) Adapts the Java core to Apache Pig.
  * **sketches-vector** moved to [incubator-datasketches-vector](https://github.com/apache/incubator-datasketches-vector) Experimental sketches for vector and matrix processing.
  * [Apache Druid adaptors](https://github.com/apache/druid/tree/master/extensions-core/datasketches)

* C++ / Python Core
  * **sketches-core-cpp** moved to [incubator-datasketches-cpp](https://github.com/apache/incubator-datasketches-cpp) This is the **core** library that contains all major sketch algorithms written in C++ and Python.

* C++ Adaptors
  * **sketches-postgres** moved to [incubator-datasketches-postgresql](https://github.com/apache/incubator-datasketches-postgresql) Adapts the C++ core to PostgreSQL.

* Java and C++
  * **characterization** moved to [incubator-datasketches-characterization](https://github.com/apache/incubator-datasketches-characterization) Java and C++ Characterization suites for benchmarking and exhaustive testing.

* Obsolete Components
  * [sketches-android](https://github.com/DataSketches/sketches-android) An experimental proof-of-concept sketch for the Android cell-phone.
  * [sketches-misc](https://github.com/DataSketches/sketches-misc)
  * [experimental](https://github.com/DataSketches/experimental)
  * [characterization-cpp](https://github.com/DataSketches/characterization-cpp)
  * [experimental-cpp](https://github.com/DataSketches/experimental-cpp)

* Command Line Functions (Mostly obsolete. These may move to Apache later or replaced by Python)
  * [homebrew-sketches-cmd](https://github.com/DataSketches/homebrew-sketches-cmd)
  * [sketches-cmd](https://github.com/DataSketches/sketches-cmd)
  * [homebrew-sketches](https://github.com/DataSketches/homebrew-sketches)

-----

Disclaimer: Apache DataSketches is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
>>>>>>> branch 'master' of git@github.com:DataSketches/DataSketches.github.io.git


text:
import os
import sys

pybabel = 'pybabel'
os.system(pybabel + ' extract -F babel.cfg -k lazy_gettext -o messages.pot app')
os.system(pybabel + ' update -i messages.pot -d app/translations')
os.unlink('messages.pot')


text:
Aria.classDefinition({
    $classpath : "test.aria.widgets.form.autocomplete.backspacetab.SlowHandler",
    $dependencies : ["aria.resources.handlers.LCResourcesHandlerBean"],
    $statics : {
        SUGGESTION_BEAN : "aria.resources.handlers.LCResourcesHandlerBean.Suggestion"
    },
    $constructor : function () {
        /**
         * Timer that controls the suggestions from the fake server
         * @type String
         */
        this._suggestionTimer = null;
    },
    $prototype : {
        /**
         * Call the callback with an array of suggestions in its arguments. Suggestions that are exact match are marked
         * with parameter exactMatch set to true.
         * @param {String} textEntry
         * @param {Function} callback
         */
        getSuggestions : function (textEntry, callback) {
            // Simply wait one second before givin back some suggestions
            if (this._suggestionTimer) {
                aria.core.Timer.cancelCallback(this._suggestionTimer);
            }

            this._suggestionTimer = aria.core.Timer.addCallback({
                fn : this._fakeSuggestions,
                scope : this,
                delay : 1000,
                args : callback
            });
        },

        _fakeSuggestions : function (callback) {
            this.$callback(callback, [{
                        label : "No matter what you type",
                        code : "matter"
                    }, {
                        label : "You always get the same results",
                        code : "always"
                    }, {
                        label : "After a time delay",
                        code : "time"
                    }]);
        },

        getDefaultTemplate : function () {
            return "test.aria.widgets.form.autocomplete.backspacetab.SlowHandlerTemplate";
        },

        suggestionToLabel : function (suggestion) {
            return suggestion.label;
        }
    }
});


text:
<root>
  <item name='android.support.v7.widget.RecyclerView.Adapter VH onCreateViewHolder(android.view.ViewGroup, int) 0'>
    <annotation name='javax.annotation.Nonnull' />
  </item>
  <item name='android.support.v7.widget.RecyclerView.Adapter void onBindViewHolder(VH, int) 0'>
    <annotation name='javax.annotation.Nonnull' />
  </item>
</root>


text:
package example.generatePojo.spi.json;

import example.generatePojo.PojoExtractor;
import example.generatePojo.model.AbstractType;
import example.generatePojo.spi.CodeWriterSupport;
import example.generatePojo.model.Pojo;
import example.generatePojo.model.Property;
import example.generatePojo.model.Type;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.collect.Iterables;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author Maarten Van Puymbroeck
 */
public class JSonExampleWriter extends CodeWriterSupport<Pojo> {

    private static final Collection<Class<?>> INTEGER_CLASSES = Arrays.<Class<?>> asList(BigInteger.class, Long.class, Long.TYPE, Integer.class, Integer.TYPE, Short.class, Short.TYPE, Byte.class, Byte.TYPE);
    private static final Collection<Class<?>> DECIMAL_CLASSES = Arrays.<Class<?>> asList(BigDecimal.class, Double.class, Double.TYPE, Float.class, Float.TYPE);

    private final PojoExtractor<Class<?>> extractor;

    public JSonExampleWriter(Path src, PojoExtractor<Class<?>> extractor) {
        super(src);
        this.extractor = extractor;
    }

    @Override
    protected Path getTarget(Pojo pojo) {
        return Paths.get(pojo.getSimpleName() + ".json");
    }

    @Override
    protected Iterable<String> toCode(Pojo pojo) {
        return Iterables.concat(
            line("{"),
            propertiesToCode(pojo, ""),
            line("}")
        );
    }

    private Iterable<String> propertiesToCode(Pojo pojo, String prefix){
        return removeLastComma(Iterables.concat(Iterables.transform(pojo.getProperties(), toCode(prefix))));
    }

    private Iterable<String> toCode(Property property, String prefix){
        return toExampleValue(MessageFormat.format("{0}\"{1}\": ", prefix, property.getName()), prefix + "    ", property.getType(), ",", Optional.of(property.getName()));
    }

    private Iterable<String> toExampleValue(String firstLinePrefix, String prefix, Type propertyType, String lastLinePostfix, Optional<String> propertyName){
       if (isSimpleValue(propertyType)){
           return line(firstLinePrefix + toSimpleExampleValue(propertyType, propertyName) + lastLinePostfix);
       } else if (propertyType.getRawClass().isArray() || Collection.class.isAssignableFrom(propertyType.getRawClass())){
           return toCollectionExampleValue(firstLinePrefix, prefix, propertyType, lastLinePostfix);
       } else {
           return toObjectExampleValue(firstLinePrefix, prefix, propertyType, lastLinePostfix);
       }
    }

    private boolean isSimpleValue(Type propertyType){
        Class<?> type = propertyType.getRawClass();
        return type.isEnum()
                || type.isPrimitive()
                || type.getName().startsWith("java.lang")
                || java.util.Date.class.isAssignableFrom(type)
                || java.lang.Number.class.isAssignableFrom(type)
                || isValueType(type)
                ;
    };

    private boolean isValueType(Class<?> type){
        return (! type.isInterface()) &&
            (    (type.getConstructors().length == 0 && type.getDeclaredFields().length == 1)
              || (type.getConstructors().length == 1 && type.getConstructors()[0].getParameterTypes().length == 1) );
    }

    private Class<?> getInnerValueType(Class<?> valueType){
        if (valueType.getConstructors().length == 1 && valueType.getConstructors()[0].getParameterTypes().length == 1){
            return valueType.getConstructors()[0].getParameterTypes()[0];
        } else if (valueType.getConstructors().length == 0 && valueType.getDeclaredFields().length == 1){
            return valueType.getDeclaredFields()[0].getType();
        } else {
            throw new IllegalArgumentException("Not a recognized value type: " + valueType);
        }
    }

    private String toSimpleExampleValue(Type propertyType, Optional<String> propertyName){
        Class<?> type = propertyType.getRawClass();
        if (type.isEnum()){
            return quote(((Enum<?>) type.getEnumConstants()[0]).name());
        } else if (INTEGER_CLASSES.contains(type)){
            return "18";
        } else if (DECIMAL_CLASSES.contains(type)){
            return "18.18";
        } else if (Boolean.class == type || Boolean.TYPE == type){
            return "true";
        } else if (CharSequence.class.isAssignableFrom(type)){
            return quote(propertyName.or("abcd"));
        } else if (java.util.Date.class.isAssignableFrom(type)){
            return quote("1981-12-14");
        } else if (isValueType(type)){
            return toSimpleExampleValue(AbstractType.of(getInnerValueType(type)), propertyName);
        } else {
            throw new IllegalArgumentException(propertyType + " " + propertyName.or("<anonymous>"));
        }
    }

    private static final String quote(String contents){
        return '\"' + contents + '\"';
    }

    private Iterable<String> toObjectExampleValue(String firstLinePrefix, String prefix, Type propertyType, String lastLinePostfix){
        Pojo pojo = extractor.getPojo(propertyType.getRawClass());
        return Iterables.concat(
                                   line(firstLinePrefix + "{"),
                                   propertiesToCode(pojo, prefix),
                                   line (prefix + "}" + lastLinePostfix)
        );
    }

    private Iterable<String> toCollectionExampleValue(String firstLinePrefix, String prefix, Type propertyType, String lastLinePostfix){

        return Iterables.concat(
                                   toExampleValue(firstLinePrefix + "[", prefix + " ", propertyType.getParameterType(0), ",", Optional.<String> absent()),
                                   toExampleValue(prefix + " ", prefix + " ", propertyType.getParameterType(0), "]" + lastLinePostfix, Optional.<String> absent())
        );

    }

    private Function<Property, Iterable<String>> toCode(final String prefix){
        return new Function<Property, Iterable<String>>() {
            @Override
            public Iterable<String> apply(Property input) {
                return toCode(input, prefix);
            }
        };
    }

    private Function<String, String> commaSeparated(){
        return new Function<String, String>() {
            boolean first = true;
            @Override
            public String apply(String input) {
                if (first){
                    first = false;
                    return input;
                }
                return null;
            }
        };
    }

    private Iterable<String> removeLastComma(final Iterable<String> iterable){
        return new Iterable<String>() {
            @Override
            public Iterator<String> iterator() {
                return new RemoveLastCommaIterator(iterable.iterator());
            }
        };
    }

    private static final class RemoveLastCommaIterator implements Iterator<String> {
        private final Iterator<String> delegate;

        public RemoveLastCommaIterator(Iterator<String> delegate) {
            this.delegate = delegate;
        }

        @Override
        public boolean hasNext() {
            return delegate.hasNext();
        }

        @Override
        public String next() {
            String next = delegate.next();
            if (delegate.hasNext()){
                return next;
            } else {
                return next.substring(0, next.length()-1);
            }

        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }
    }
}


text:
package com.tutorial.repository;

import java.util.Objects;
import java.util.Optional;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import com.tutorial.entity.Person;

public class PersonRepositoryImpl implements PersonRepository {
	private EntityManagerFactory emf = Persistence.createEntityManagerFactory("com.juliuskrah.tutorial");
	private EntityManager em;

	public PersonRepositoryImpl() {
		em = emf.createEntityManager();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Optional<Person> create(Person person) {
		Objects.requireNonNull(person, "Person must not be null");
		em.getTransaction().begin();
		em.persist(person);
		em.getTransaction().commit();
		return Optional.of(person);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Optional<Person> read(Long id) {
		em.getTransaction().begin();
		Person person = em.find(Person.class, id);
		em.getTransaction().commit();
		return Optional.ofNullable(person);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Optional<Person> update(Person person) {
		Objects.requireNonNull(person, "Person must not be null");
		em.getTransaction().begin();
		person = em.merge(person);
		em.getTransaction().commit();
		return Optional.of(person);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void delete(Person person) {
		em.getTransaction().begin();
		em.remove(person);
		em.getTransaction().commit();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public EntityManager getEntityManager() {
		return em;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void close() {
		emf.close();
	}

}


text:
'use strict'

const test = require('ava')

const circularDependency = require('../circular-dependency')
const { pluginMacro } = require('./helpers/macros')

test('circularDependency output', pluginMacro, circularDependency())


text:
<?php

namespace Vectorface\SnappyRouter\Request;

use Vectorface\SnappyRouter\Exception\InternalErrorException;

class HttpRequest extends AbstractRequest implements HttpRequestInterface
{
    /** Holds the HTTP verb used in the request */
    private $verb;

    /** Holds the contents of the various inputs ($_GET, $_POST, etc) */
    private $input;

    /** The input stream (stream or location string) */
    private $stream;

    /** Array key for query parameters */
    const INPUT_METHOD_QUERY = 'QUERY';
    /** Array key for post parameters */
    const INPUT_METHOD_POST = 'POST';
    /** Array key for input stream body */
    const INPUT_METHOD_BODY = 'BODY';

    // mappings between magic filter strings and the filter functions
    private static $filterCallbacks = [
        'int'     => 'intval',
        'float'   => 'floatval',
        'trim'    => 'trim',
        'lower'   => 'strtolower',
        'upper'   => 'strtoupper',
        'squeeze' => [self::class, 'squeeze'],
    ];

    /**
     * Constructor for a request.
     * @param string $controller The controller being requested.
     * @param string $action The action being invoked.
     * @param string $verb The HTTP verb used in the request.
     * @param mixed $stream A stream or a string describing a stream location.
     */
    public function __construct($controller, $action, $verb, $stream = 'php://input')
    {
        parent::__construct($controller, $action);
        $this->setVerb($verb);
        $this->setStream($stream);

        $this->input = [
            self::INPUT_METHOD_QUERY => [],
            self::INPUT_METHOD_POST  => [],
            self::INPUT_METHOD_BODY  => null,
        ];
    }

    /**
     * Returns the HTTP verb used in the request.
     * @return string The HTTP verb used in the request.
     */
    public function getVerb()
    {
        return $this->verb;
    }

    /**
     * Sets the HTTP verb used in the request.
     * @param string $verb The HTTP verb used in the request.
     * @return RequestInterface Returns $this.
     */
    public function setVerb($verb)
    {
        $this->verb = $verb;
        return $this;
    }

    /**
     * Sets the stream used in the request.
     * @param mixed $stream The stream used in the request.
     * @return RequestInterface Returns $this.
     */
    public function setStream($stream)
    {
        $this->stream = $stream;
        return $this;
    }

    /**
     * Returns true if the request is a GET request and false otherwise.
     * @return bool Returns true if the request is a GET request and false
     *         otherwise.
     */
    public function isGet()
    {
        return 'GET' === strtoupper($this->getVerb());
    }

    /**
     * Returns true if the request is a POST request and false otherwise.
     * @return bool Returns true if the request is a POST request and false
     *         otherwise.
     */
    public function isPost()
    {
        return 'POST' === strtoupper($this->getVerb());
    }

    /**
     * Returns the GET data parameter associated with the specified key.
     * @param string $param The GET data parameter.
     * @param mixed $defaultValue The default value to use when the key is not present.
     * @param mixed $filters The array of filters (or single filter) to apply to the data.
     * @return mixed Returns the data from the GET parameter after being filtered (or
     *         the default value if the parameter is not present)
     */
    public function getQuery($param, $defaultValue = null, $filters = [])
    {
        return $this->fetchInputValue(
            $this->input[self::INPUT_METHOD_QUERY],
            $param,
            $defaultValue,
            $filters
        );
    }

    /**
     * Sets all the QUERY data for the current request.
     * @param array $queryData The query data for the current request.
     * @return HttpRequestInterface Returns $this.
     */
    public function setQuery($queryData)
    {
        $this->input[self::INPUT_METHOD_QUERY] = (array)$queryData;
        return $this;
    }

    /**
     * Returns the POST data parameter associated with the specified key.
     * @param string $param The POST data parameter.
     * @param mixed $defaultValue The default value to use when the key is not present.
     * @param mixed $filters The array of filters (or single filter) to apply to the data.
     * @return mixed Returns the data from the POST parameter after being filtered (or
     *         the default value if the parameter is not present)
     */
    public function getPost($param, $defaultValue = null, $filters = [])
    {
        return $this->fetchInputValue(
            $this->input[self::INPUT_METHOD_POST],
            $param,
            $defaultValue,
            $filters
        );
    }

    /**
     * Sets all the POST data for the current request.
     * @param array $postData The post data for the current request.
     * @return HttpRequestInterface Returns $this.
     */
    public function setPost($postData)
    {
        $this->input[self::INPUT_METHOD_POST] = (array)$postData;
        return $this;
    }

    /**
     * Returns the input stream data for the current request
     *
     * @return string The input stream data
     * @throws InternalErrorException
     */
    public function getBody()
    {
        // If this value has been read from the stream, retrieve it from storage
        if (null !== $this->input[self::INPUT_METHOD_BODY]) {
            return $this->input[self::INPUT_METHOD_BODY];
        }

        if (is_resource($this->stream) && 'stream' === get_resource_type($this->stream)) {
            $streamData = stream_get_contents($this->stream);
        } elseif (is_string($this->stream)) {
            $stream = @fopen($this->stream, "r");

            if (false === $stream) {
                throw new InternalErrorException('Unable to open request input stream.');
            }

            $streamData = stream_get_contents($stream);

            fclose($stream);
        } else {
            $streamData = false;
        }

        if (false === $streamData) {
            throw new InternalErrorException('Unable to open request input stream.');
        }

        $this->input[self::INPUT_METHOD_BODY] = $streamData;

        return $this->input[self::INPUT_METHOD_BODY];
    }

    /**
     * Returns an array of all the input parameters from the query and post data.
     * @return array An array of all input.
     */
    public function getAllInput()
    {
        return array_merge(
            $this->input[self::INPUT_METHOD_QUERY],
            $this->input[self::INPUT_METHOD_POST]
        );
    }

    /**
     * Fetches the input value from the given array, or the default value. Also
     * applies any requested filters.
     * @param array $array The array ($_POST, $_GET, $params, etc).
     * @param string $param The array key to lookup.
     * @param mixed $defaultValue The default value to use if the key is not
     *        found in the array.
     * @param mixed $filters The array of input filters to apply (or single filter).
     * @return mixed Returns the value filtered (or the default value filtered).
     */
    private function fetchInputValue($array, $param, $defaultValue, $filters)
    {
        $value = $array[$param] ?? $defaultValue;
        return $this->applyInputFilters($value, is_array($filters) ? $filters : [$filters]);
    }

    /**
     * Applies the array of filters against the input value.
     * @param string $value The input value.
     * @param array $filters The array of filters.
     * @return string Returns the value after the filters have been applied.
     */
    private function applyInputFilters($value, $filters)
    {
        foreach ($filters as $filter) {
            if (is_string($filter) && isset(self::$filterCallbacks[$filter])) {
                $value = call_user_func(self::$filterCallbacks[$filter], $value);
            }
        }
        return $value;
    }

    /**
     * Takes a string and removes empty lines.
     * @param string $string The input string.
     * @return string Returns the string with empty lines removed.
     */
    private static function squeeze($string)
    {
        return implode(
            PHP_EOL,
            array_filter(
                array_map(
                    'trim',
                    explode(PHP_EOL, $string)
                ),
                'strlen'
            )
        );
    }
}


text:
<?php

declare(strict_types=1);

namespace Nugato\Bundle\NuCmsBundle\Entity;

use Nugato\Bundle\NuCmsBundle\Core\Entity\SeoMetatagsInterface;
use Sylius\Component\Resource\Model\CodeAwareInterface;
use Sylius\Component\Resource\Model\ResourceInterface;
use Sylius\Component\Resource\Model\SlugAwareInterface;
use Sylius\Component\Resource\Model\TranslatableInterface;

interface PageInterface extends SlugAwareInterface, ResourceInterface, TranslatableInterface, CodeAwareInterface, SeoMetatagsInterface
{
    /**
     * @param string $title
     */
    public function setTitle(string $title): void;

    /**
     * @return string
     */
    public function getTitle(): ?string;

    /**
     * @param string $content
     */
    public function setContent(string $content): void;

    /**
     * @return string
     */
    public function getContent(): ?string;

    /**
     * @return \DateTimeInterface|null
     */
    public function getCreatedAt(): ?\DateTimeInterface;

    /**
     * @return \DateTimeInterface|null
     */
    public function getUpdatedAt(): ?\DateTimeInterface;

    /**
     * @param string $template
     */
    public function setTemplate(string $template): void;

    /**
     * @return string
     */
    public function getTemplate(): ?string;

    /**
     * @return bool
     */
    public function hasTemplateSelected(): bool;
}


text:
package sk.scalagine.math

/**
 * Created with IntelliJ IDEA.
 * User: zladovan
 * Date: 25.5.2014
 * Time: 12:04
 */
class InverseMatrixNotExistsException(matrix: MatrixNxN[_])
  extends RuntimeException("Non invertible matrix: " + matrix)


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AsyncAwait.Models;

namespace AsyncAwait.Services
{
    public class MockDataStore : IDataStore<Item>
    {
        List<Item> items;

        public MockDataStore()
        {
            items = new List<Item>();
            var mockItems = new List<Item>
            {
                new Item { Id = Guid.NewGuid().ToString(), Text = "First item", Description="This is an item description." },
                new Item { Id = Guid.NewGuid().ToString(), Text = "Second item", Description="This is an item description." },
                new Item { Id = Guid.NewGuid().ToString(), Text = "Third item", Description="This is an item description." },
                new Item { Id = Guid.NewGuid().ToString(), Text = "Fourth item", Description="This is an item description." },
                new Item { Id = Guid.NewGuid().ToString(), Text = "Fifth item", Description="This is an item description." },
                new Item { Id = Guid.NewGuid().ToString(), Text = "Sixth item", Description="This is an item description." },
            };

            foreach (var item in mockItems)
            {
                items.Add(item);
            }
        }

        public async Task<bool> AddItemAsync(Item item)
        {
            items.Add(item);

            return await Task.FromResult(true);
        }

        public async Task<bool> UpdateItemAsync(Item item)
        {
            var oldItem = items.Where((Item arg) => arg.Id == item.Id).FirstOrDefault();
            items.Remove(oldItem);
            items.Add(item);

            return await Task.FromResult(true);
        }

        public async Task<bool> DeleteItemAsync(string id)
        {
            var oldItem = items.Where((Item arg) => arg.Id == id).FirstOrDefault();
            items.Remove(oldItem);

            return await Task.FromResult(true);
        }

        public async Task<Item> GetItemAsync(string id)
        {
            return await Task.FromResult(items.FirstOrDefault(s => s.Id == id));
        }

        public async Task<IEnumerable<Item>> GetItemsAsync(bool forceRefresh = false)
        {
            return await Task.FromResult(items);
        }
    }
}


text:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <title>Bismillah</title>
    <meta name="description" content="" />

    <meta name="HandheldFriendly" content="True" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <link rel="shortcut icon" href="https://ktekbiyikiletisim.github.io/favicon.ico">

    <link rel="stylesheet" type="text/css" href="//ktekbiyikiletisim.github.io/themes/casper/assets/css/screen.css?v=1485075357483" />
    <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Merriweather:300,700,700italic,300italic|Open+Sans:700,400" />

    <link rel="canonical" href="https://ktekbiyikiletisim.github.io/2017/01/22/Bismillah.html" />
    <meta name="referrer" content="origin" />

    <meta property="og:type" content="website" />
    <meta property="og:title" content="Bismillah" />
    <meta property="og:description" content="Bismillah, her hayrın başı&#8230;&#8203;" />
    <meta property="og:url" content="https://ktekbiyikiletisim.github.io/2017/01/22/Bismillah.html" />
    <meta name="twitter:card" content="summary" />
    <meta name="twitter:title" content="Bismillah" />
    <meta name="twitter:description" content="Bismillah, her hayrın başı&#8230;&#8203;" />
    <meta name="twitter:url" content="https://ktekbiyikiletisim.github.io/2017/01/22/Bismillah.html" />

    <meta name="generator" content="HubPress" />
    <link rel="alternate" type="application/rss+xml" title="" href="https://ktekbiyikiletisim.github.io/rss/" />

Bismillah

                <time class="post-date" datetime="2017-01-22">22 January 2017</time>

Bismillah, her hayrın başı…

                ktekbiyikiletisim's Picture

ktekbiyikiletisim

Read more posts by this author.

Share this post

                    Twitter

                    Facebook

                    Google+

 © 2017

Proudly published with HubPress


text:
'use strict';

import React from 'react';

export default React.createClass({
  displayName : 'PippoPage',
  render () {
    /* jshint ignore:start */
    return
Pippo page
;
    /* jshint ignore:end */
  }

});


text:
package com.b2international.snowowl.snomed.ql.ql;

/**
 *
 * A representation of the model object 'Sub Query'.
 *
 *
 *
 * @see com.b2international.snowowl.snomed.ql.ql.QlPackage#getSubQuery()
 * @model
 * @generated
 */
public interface SubQuery extends QueryConstraint
{
} // SubQuery


text:
use strict;
use warnings;
use FindBin qw($Bin);
use lib ("$Bin/../lib", "$Bin/../lib/perl5");
use RUM::Script;
RUM::Script->run_with_logging("RUM::Script::MergeGnuAndTnuAndCnu");

=head1 NAME

merge_GNU_and_TNU_and_CNU.pl

=head1 SYNOPSIS

merge_GNU_and_TNU_and_CNU.pl --gnu-in <gnu_in> --tnu-in <tnu_in> --cnu_in <cnu_in> --output <bowtie_nu_out>

=head1 OPTIONS

=over 4

=item B<--gnu-in> I<gnu_in>

The file of non-unique mappers from the script make_GU_and_GNU.pl.

=item B<--tnu-in> I<tnu_in>

The file of non-unique mappers from the script make_TU_and_TNU.pl.

=item B<--cnu-in> I<cnu_in>

The file of non-unique mappers from the script merge_GU_and_TU.pl.

=item B<-o>, B<--output>  I<bowtie_nu_out>

The file of non-unique mappers to be output.

=back

=head1 AUTHOR

Mike DeLaurentis (delaurentis@gmail.com)

=head1 COPYRIGHT

Copyright 2012 University of Pennsylvania

=cut


text:
using System;

namespace FluentNHibernate.MappingModel.ClassBased
{
    [Serializable]
    public class ComponentType
    {
        public static readonly ComponentType Component = new ComponentType("component");
        public static readonly ComponentType DynamicComponent = new ComponentType("dynamic-component");

        readonly string elementName;

        private ComponentType(string elementName)
        {
            this.elementName = elementName;
        }

        public string GetElementName()
        {
            return elementName;
        }

        public override bool Equals(object obj)
        {
            if (obj.GetType() != typeof(ComponentType))
                return false;

            return Equals(obj as ComponentType);
        }

        public override string ToString()
        {
            return string.Format("ElementName: {0}", elementName);
        }

        public bool Equals(ComponentType other)
        {
            return Equals(other.elementName, elementName);
        }

        public override int GetHashCode()
        {
            return (elementName != null ? elementName.GetHashCode() : 0);
        }

        public static bool operator ==(ComponentType left, ComponentType right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(ComponentType left, ComponentType right)
        {
            return !(left == right);
        }
    }
}


text:
/** Includes a brief description and movement of rook.
  * Implements TextToSpeech interface and initiates
  * listener, speaks out the text written in layout
  * content_rook.xml file.
  */

package com.example.admin.learnchess;

import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import java.util.Locale;

public class Rook extends AppCompatActivity implements TextToSpeech.OnInitListener  {

    private TextToSpeech tts;
    private ImageButton btnSpeak;
    private ImageButton btnHome;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rook);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        tts = new TextToSpeech(this, this);
        btnHome = (ImageButton) findViewById(R.id.imageButton13);
        btnSpeak = (ImageButton) findViewById(R.id.imageButton14);

        btnSpeak.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                speakOut();
            }
        });

        btnHome.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
            }
        });
    }

    @Override
    public void onDestroy() {
        if (tts != null) {
            tts.stop();
            tts.shutdown();
        }
        super.onDestroy();
    }

    @Override
    public void onInit(int status) {
        if (status == TextToSpeech.SUCCESS) {

            int result = tts.setLanguage(Locale.US);

            if (result == TextToSpeech.LANG_MISSING_DATA
                    || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                Log.e("TTS", "This Language is not supported");
            } else {
                btnSpeak.setEnabled(true);
            }

        } else {
            Log.e("TTS", "Initilization Failed!");
        }
    }

    private void speakOut() {
        String text = "";
        TextView textView;

        textView = (TextView) findViewById(R.id.textView19);
        text += textView.getText().toString() + ". ";

        textView = (TextView) findViewById(R.id.textView20);
        text += textView.getText().toString();

        textView = (TextView) findViewById(R.id.textView21);
        text += textView.getText().toString() + ". ";

        textView = (TextView) findViewById(R.id.textView22);
        text += textView.getText().toString();

        textView = (TextView) findViewById(R.id.textView23);
        text += textView.getText().toString() + ". ";

        textView = (TextView) findViewById(R.id.textView24);
        text += textView.getText().toString() + ". ";

        textView = (TextView) findViewById(R.id.textView25);
        text += textView.getText().toString();

        textView = (TextView) findViewById(R.id.textView26);
        text += textView.getText().toString() + ". ";

        textView = (TextView) findViewById(R.id.textView27);
        text += textView.getText().toString() + ". ";

        textView = (TextView) findViewById(R.id.textView28);
        text += textView.getText().toString() + ". ";

        textView = (TextView) findViewById(R.id.textView29);
        text += textView.getText().toString() + ". ";

        tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
    }
}


text:
def test_serialization_of_property_attr(todolist_with_users_tasks):
    with todolist_with_users_tasks.test_client() as client:
        resp = client.jget('/users?name~=Donald')
        assert resp['status'] == 'success'
        assert resp['result'][0]['name'] == "Donald Duck"
        assert resp['result'][0].get('first_name') == 'Donald'

def test_if_put_ignores_property_attr(todolist_with_users_tasks):
    with todolist_with_users_tasks.test_client() as client:
        resp = client.jget('/users/popeye@acme.com')
        first_name = resp['result']['first_name']
        modified_first_name = "Mr.{}".format(first_name)
        resp = client.jput(
            '/users/1', {
                "first_name": modified_first_name
            })
        print(resp)
        assert resp['status'] == 'success'
        assert resp['result']['first_name'] == first_name


text:
//
//  InvestorViewController.m
//  家长界
//
//  Created by taylor on 2016/12/15.
//  Copyright © 2016年 西部家联. All rights reserved.
//

#import "InvestorViewController.h"

#import "InvestorDescView.h"

@interface InvestorViewController ()<UITableViewDelegate,UITableViewDataSource>

/**tableview的headerview*/
@property (strong,nonatomic) UIView *headerView;

/**tableview*/
@property (strong,nonatomic) UITableView *tableView;

@property(nonatomic,strong) InvestorDescView *descView;

/*底部按钮视图*/
@property (strong,nonatomic) UIView *bottomView;

@end

@implementation InvestorViewController

id investCell = nil;

-(InvestorDescView *)descView
{
    if (!_descView) {
        InvestmentLayout *lay = [[InvestmentLayout alloc]initInvestmentPersonDescView];
        _descView = [[InvestorDescView alloc]initWithFrame:CGRectMake(0, self.headerView.botoom, SCREEN_WIDTH, lay.investorViewHeight)];

    }
    return _descView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self.view addSubview:self.tableView];
    [self.headerView addSubview:self.descView];
    [self.view addSubview:self.bottomView];
}

#pragma mark -----懒加载------
-(UIView *)headerView{
    if (!_headerView) {
        _headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH*0.46)];
        InvestorHeadView *vi = [InvestorHeadView new];
        vi.backImageView.image = [UIImage imageNamed:@"backImage.jpg"];
        vi.imgView.image = [UIImage imageNamed:@"icon"];
        vi.nameLabel.text = @"韩雪冬";
        vi.fundLabel.text = @"银江资本";
        vi.jobLabel.text = @"投资经理";
        vi.addressIcon.image = [UIImage imageNamed:@"qpt_map_image"];
        vi.addressLabel.text = @"西安";
        [_headerView addSubview:vi];
    }
    return _headerView;
}

-(UIView *)bottomView{
    if (!_bottomView) {
        _bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT-60, SCREEN_HEIGHT, 60)];
        _bottomView.backgroundColor = [UIColor whiteColor];
        NSArray *icon = @[@"关注",@"好友",@"咨询"];
        NSArray *title = @[@"加关注",@"加好友",@"立即咨询"];
        NSArray *color = @[@"blue",@"green",@"orange"];
        for (int i = 0; i < 3; i++) {
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.frame = CGRectMake(10+i*(SCREEN_WIDTH-40)/3+i*10, 15, (SCREEN_WIDTH-40)/3, 30);
            btn.layer.masksToBounds = YES;
            btn.layer.cornerRadius = 3;
            btn.titleLabel.font = [UIFont systemFontOfSize:15];
            btn.imageView.size = CGSizeMake(16, 16);
            [btn setTitle:title[i] forState:UIControlStateNormal];
            btn.imageEdgeInsets = UIEdgeInsetsMake(0, -3, 0, 3);
            btn.titleEdgeInsets = UIEdgeInsetsMake(0, 3, 0, -3);
            [btn setImage:[UIImage imageNamed:icon[i]] forState:UIControlStateNormal];
            [btn setBackgroundImage:[UIImage imageNamed:color[i]] forState:UIControlStateNormal];
            [btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];

            [_bottomView addSubview:btn];
        }

    }
    return _bottomView;
}

-(void)clickBtn:(UIButton *)sender{
    if (sender.tag == 0) {

    }
    else if (sender.tag == 1){

    }
    else{

    }
}

#pragma mark ------tableview及方法------
-(UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-60)];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableHeaderView = self.headerView;
        _tableView.tableHeaderView.height = self.descView.botoom;

        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

        _tableView.allowsSelection = NO;
    }

    return _tableView;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 1;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

        return SCREEN_WIDTH*0.3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"identifier";
        InvestorTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[InvestorTableViewCell alloc]initWithFrame:cell.bounds];
            investCell = cell;
            cell.nameLabel.text = @"投资机构";
            cell.imgView.image = [UIImage imageNamed:@"venture"];
            cell.titleLabel.text = @"中国银江投资集团";
            cell.vIcon.image = [UIImage imageNamed:@"vip"];
            cell.fieldLabel.text = @"领域 : 社交、电子商务、媒体分类";
            cell.numberLabel.text = @"5位投资人";

            [cell.arrowIcon setImage:[UIImage imageNamed:@"rightImage"] forState:UIControlStateNormal];
            [cell.arrowIcon addTarget:self action:@selector(clickArrowBtn) forControlEvents:UIControlEventTouchUpInside];
        }
    return investCell;
}

-(void)clickArrowBtn{

    InstiDetailViewController *vc = [InstiDetailViewController new];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end


text:
/*
 * @test
 * @bug 6630702
 * @summary Tests that scrolling after paint() is performed correctly.
 *          This is really only applicable to Vista
 * @author Dmitri.Trembovetski@sun.com: area=Graphics
 * @run main/othervm SwingOnScreenScrollingTest
 * run main/othervm -Dsun.java2d.opengl=True SwingOnScreenScrollingTest
 */

import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

public class SwingOnScreenScrollingTest extends JPanel {

    static JScrollPane pane;
    static SwingOnScreenScrollingTest test;

    public SwingOnScreenScrollingTest() {
    }

    public static void main(String[] args) {
        int size = GraphicsEnvironment.
            getLocalGraphicsEnvironment().
                getDefaultScreenDevice().
                    getDefaultConfiguration().getColorModel().getPixelSize();
        if (size < 16) {
            System.err.println("<16 bit display mode detected. Test PASSED");
            return;
        }

        final JFrame f = new JFrame("SwingOnScreenScrollingTest");
        try {
            EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    test = new SwingOnScreenScrollingTest();
                    pane = new JScrollPane(test);
                    f.add(pane);
                    f.pack();
                    f.setSize(100, 200);
                    f.setVisible(true);
                }
            });
        } catch (InvocationTargetException ex) {
            ex.printStackTrace();
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
        try {
            Thread.sleep(500);
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                BufferedImage bi;
                bi = new BufferedImage(100, 300,
                                       BufferedImage.TYPE_INT_RGB);
                Graphics gg = bi.getGraphics();
                test.paint(gg);
                for (int y = 80; y < 200; y +=10) {
                    test.scrollRectToVisible(new Rectangle(0, y, 100, 100));
                    try {
                        Thread.sleep(200);
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
                    }
                }
                Point p = pane.getViewport().getLocationOnScreen();
                Robot r = null;
                try {
                    r = new Robot();
                } catch (AWTException ex) {
                    throw new RuntimeException(ex);
                }
                bi = r.createScreenCapture(new Rectangle(p.x+5, p.y+5, 30, 30));
                for (int y = 0; y < bi.getHeight(); y++) {
                    for (int x = 0; x < bi.getHeight(); x++) {
                        int rgb = bi.getRGB(x, y);
                        if (bi.getRGB(x, y) != Color.red.getRGB()) {
                            System.err.printf("Test Failed at (%d,%d) c=0x%x\n",
                                              x, y, rgb);
                            try {
                                String name =
                                    "SwingOnScreenScrollingTest_out.png";
                                ImageIO.write(bi, "png", new File(name));
                                System.err.println("Wrote grabbed image to "+
                                                   name);
                            } catch (Throwable ex) {}
                            throw new RuntimeException("Test failed");
                        }
                    }
                }
                System.out.println("Test PASSED.");
                f.dispose();
            }
        });
    }

    protected void paintComponent(Graphics g) {
        g.setColor(Color.green);
        g.fillRect(0, 0, getWidth(), 100);
        g.setColor(Color.red);
        g.fillRect(0, 100, getWidth(), getHeight()-100);
    }

    public Dimension getPreferredSize() {
        return new Dimension(100, 300);
    }
}


text:
import Component from '../../common/Component';
import humanTime from '../../common/utils/humanTime';
import extractText from '../../common/utils/extractText';

/**
 * The `PostEdited` component displays information about when and by whom a post
 * was edited.
 *
 * ### Props
 *
 * - `post`
 */
export default class PostEdited extends Component {
  init() {
    this.shouldUpdateTooltip = false;
    this.oldEditedInfo = null;
  }

  view() {
    const post = this.props.post;
    const editedUser = post.editedUser();
    const editedInfo = extractText(app.translator.trans(
      'core.forum.post.edited_tooltip',
      {user: editedUser, ago: humanTime(post.editedAt())}
    ));
    if (editedInfo !== this.oldEditedInfo) {
      this.shouldUpdateTooltip = true;
      this.oldEditedInfo = editedInfo;
    }

    return (
      <span className="PostEdited" title={editedInfo}>
        {app.translator.trans('core.forum.post.edited_text')}
      </span>
    );
  }

  config(isInitialized) {
    if (this.shouldUpdateTooltip) {
      this.$().tooltip('destroy').tooltip();
      this.shouldUpdateTooltip = false;
    }
  }
}


text:
package com.rtg.util.io;

import com.rtg.util.StringUtils;

import junit.framework.TestCase;

/**
 * Test class
 */
public class MemoryPrintStreamTest extends TestCase {

  public void testWriting() {
    try (final MemoryPrintStream mps = new MemoryPrintStream()) {
      new Throwable().printStackTrace(mps.printStream());
      final String result = mps.toString();
      assertTrue(result.contains("MemoryPrintStreamTest"));
      assertTrue(StringUtils.split(mps.toString(), '\n').length > 3);
    }
  }
}


text:
package main

import "time"
import "fmt"

func main() {
	ticker := time.NewTicker(time.Millisecond * 500)
	go func() {
		for t := range ticker.C {
			fmt.Println("Tick at", t)
		}
	}()

	time.Sleep(time.Millisecond * 1500)
	ticker.Stop()
	fmt.Println("Ticker stopped")
}


text: The dotCODES source control maintenance mainframe.


text:
layout: post
title:  Delhi High-Court Junior Judicial Assistant Technical posts last date  6th Aug-2015
date: 2015-07-23 19:35
comments: true
tags: Assistant Delhi High Court IT(Computer) Judicial Online
archive: false
---
Applications are invited from the Indian Nationals for filling up the following posts on the establishment of this Court:

- Junior Judicial Assistant (Technical) : 60 posts (UR-32,SC-8,ST-4,OBC-16), Pay scale : Rs. 5200 - 20200 grade pay Rs. 2800/- , Age : 18-27 years as on 01/01/2015., Qualifications : BCA / B.Sc. Computer Science with minimum 50% marks in aggregate.

Application Fee : Application fee in the form of Demand Draft/ Pay Order/ Postal order of Rs. 300/- drawn in favour of Registrar General, Delhi High Court. No fee shall be payable by the SC/ ST/ PH / Ex.SM/ Women Candidates.

**How to Apply** : Apply Online at Delhi High Court website from 23/07/2015 to 06/08/2015 only.

For more information and online application form, kindly visit  <http://delhihighcourt.nic.in/open_position.asp>


text:
<?php

namespace Ekyna\Bundle\CommerceBundle\Event;

use Ekyna\Component\Commerce\Common\Model\SaleInterface;
use Ekyna\Component\Commerce\Payment\Model\PaymentInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\Form\FormInterface;

/**
 * Class CheckoutPaymentEvent
 * @package Ekyna\Bundle\CommerceBundle\Event
 * @author  Etienne Dauvergne <contact@ekyna.com>
 */
class CheckoutPaymentEvent extends Event
{
    const BUILD_FORM = 'ekyna_commerce.checkout.build_payment_form';

    /**
     * @var SaleInterface
     */
    private $sale;

    /**
     * @var PaymentInterface
     */
    private $payment;

    /**
     * @var array
     */
    private $formOptions;

    /**
     * @var FormInterface
     */
    private $form;

    /**
     * Constructor.
     *
     * @param SaleInterface    $sale
     * @param PaymentInterface $payment
     * @param array            $formOptions
     */
    public function __construct(SaleInterface $sale, PaymentInterface $payment, array $formOptions = [])
    {
        $this->sale = $sale;
        $this->payment = $payment;
        $this->formOptions = array_replace($formOptions, [
            'validation_groups' => ['Checkout'],
        ]);
    }

    /**
     * Returns the sale.
     *
     * @return SaleInterface
     */
    public function getSale()
    {
        return $this->sale;
    }

    /**
     * Returns the payment.
     *
     * @return PaymentInterface
     */
    public function getPayment()
    {
        return $this->payment;
    }

    /**
     * Returns the form options.
     *
     * @return array
     */
    public function getFormOptions()
    {
        return $this->formOptions;
    }

    /**
     * Returns the form.
     *
     * @return FormInterface
     */
    public function getForm()
    {
        return $this->form;
    }

    /**
     * Sets the form.
     *
     * @param FormInterface $form
     */
    public function setForm(FormInterface $form = null)
    {
        $this->form = $form;
    }
}