text:
namespace v8 {
namespace internal {
namespace compiler {

Int64Lowering::Int64Lowering(Graph* graph, MachineOperatorBuilder* machine,
                             CommonOperatorBuilder* common, Zone* zone,
                             Signature<MachineRepresentation>* signature)
    : zone_(zone),
      graph_(graph),
      machine_(machine),
      common_(common),
      state_(graph, 3),
      stack_(zone),
      replacements_(nullptr),
      signature_(signature),
      placeholder_(graph->NewNode(common->Parameter(-2, "placeholder"),
                                  graph->start())) {
  DCHECK_NOT_NULL(graph);
  DCHECK_NOT_NULL(graph->end());
  replacements_ = zone->NewArray<Replacement>(graph->NodeCount());
  memset(replacements_, 0, sizeof(Replacement) * graph->NodeCount());
}

void Int64Lowering::LowerGraph() {
  if (!machine()->Is32()) {
    return;
  }
  stack_.push_back({graph()->end(), 0});
  state_.Set(graph()->end(), State::kOnStack);

  while (!stack_.empty()) {
    NodeState& top = stack_.back();
    if (top.input_index == top.node->InputCount()) {
      // All inputs of top have already been lowered, now lower top.
      stack_.pop_back();
      state_.Set(top.node, State::kVisited);
      LowerNode(top.node);
    } else {
      // Push the next input onto the stack.
      Node* input = top.node->InputAt(top.input_index++);
      if (state_.Get(input) == State::kUnvisited) {
        if (input->opcode() == IrOpcode::kPhi) {
          // To break cycles with phi nodes we push phis on a separate stack so
          // that they are processed after all other nodes.
          PreparePhiReplacement(input);
          stack_.push_front({input, 0});
        } else if (input->opcode() == IrOpcode::kEffectPhi ||
                   input->opcode() == IrOpcode::kLoop) {
          stack_.push_front({input, 0});
        } else {
          stack_.push_back({input, 0});
        }
        state_.Set(input, State::kOnStack);
      }
    }
  }
}

namespace {

int GetReturnIndexAfterLowering(CallDescriptor* call_descriptor,
                                int old_index) {
  int result = old_index;
  for (int i = 0; i < old_index; i++) {
    if (call_descriptor->GetReturnType(i).representation() ==
        MachineRepresentation::kWord64) {
      result++;
    }
  }
  return result;
}

int GetReturnCountAfterLowering(CallDescriptor* call_descriptor) {
  return GetReturnIndexAfterLowering(
      call_descriptor, static_cast<int>(call_descriptor->ReturnCount()));
}

int GetParameterIndexAfterLowering(
    Signature<MachineRepresentation>* signature, int old_index) {
  int result = old_index;
  for (int i = 0; i < old_index; i++) {
    if (signature->GetParam(i) == MachineRepresentation::kWord64) {
      result++;
    }
  }
  return result;
}

int GetReturnCountAfterLowering(Signature<MachineRepresentation>* signature) {
  int result = static_cast<int>(signature->return_count());
  for (int i = 0; i < static_cast<int>(signature->return_count()); i++) {
    if (signature->GetReturn(i) == MachineRepresentation::kWord64) {
      result++;
    }
  }
  return result;
}

}  // namespace

// static
int Int64Lowering::GetParameterCountAfterLowering(
    Signature<MachineRepresentation>* signature) {
  // GetParameterIndexAfterLowering(parameter_count) returns the parameter count
  // after lowering.
  return GetParameterIndexAfterLowering(
      signature, static_cast<int>(signature->parameter_count()));
}

// static
bool Int64Lowering::IsI64AsTwoParameters(MachineOperatorBuilder* machine,
                                         MachineRepresentation type) {
  return machine->Is32() && type == MachineRepresentation::kWord64;
}

void Int64Lowering::GetIndexNodes(Node* index, Node*& index_low,
                                  Node*& index_high) {
  if (HasReplacementLow(index)) {
    index = GetReplacementLow(index);
  }
#if defined(V8_TARGET_LITTLE_ENDIAN)
  index_low = index;
  index_high = graph()->NewNode(machine()->Int32Add(), index,
                                graph()->NewNode(common()->Int32Constant(4)));
#elif defined(V8_TARGET_BIG_ENDIAN)
  index_low = graph()->NewNode(machine()->Int32Add(), index,
                               graph()->NewNode(common()->Int32Constant(4)));
  index_high = index;
#endif
}

void Int64Lowering::LowerNode(Node* node) {
  switch (node->opcode()) {
    case IrOpcode::kInt64Constant: {
      int64_t value = OpParameter<int64_t>(node->op());
      Node* low_node = graph()->NewNode(
          common()->Int32Constant(static_cast<int32_t>(value & 0xFFFFFFFF)));
      Node* high_node = graph()->NewNode(
          common()->Int32Constant(static_cast<int32_t>(value >> 32)));
      ReplaceNode(node, low_node, high_node);
      break;
    }
    case IrOpcode::kLoad:
    case IrOpcode::kUnalignedLoad: {
      MachineRepresentation rep;
      if (node->opcode() == IrOpcode::kLoad) {
        rep = LoadRepresentationOf(node->op()).representation();
      } else {
        DCHECK_EQ(IrOpcode::kUnalignedLoad, node->opcode());
        rep = LoadRepresentationOf(node->op()).representation();
      }

      if (rep == MachineRepresentation::kWord64) {
        Node* base = node->InputAt(0);
        Node* index = node->InputAt(1);
        Node* index_low;
        Node* index_high;
        GetIndexNodes(index, index_low, index_high);
        const Operator* load_op;

        if (node->opcode() == IrOpcode::kLoad) {
          load_op = machine()->Load(MachineType::Int32());
        } else {
          DCHECK_EQ(IrOpcode::kUnalignedLoad, node->opcode());
          load_op = machine()->UnalignedLoad(MachineType::Int32());
        }

        Node* high_node;
        if (node->InputCount() > 2) {
          Node* effect_high = node->InputAt(2);
          Node* control_high = node->InputAt(3);
          high_node = graph()->NewNode(load_op, base, index_high, effect_high,
                                       control_high);
          // change the effect change from old_node --> old_effect to
          // old_node --> high_node --> old_effect.
          node->ReplaceInput(2, high_node);
        } else {
          high_node = graph()->NewNode(load_op, base, index_high);
        }
        node->ReplaceInput(1, index_low);
        NodeProperties::ChangeOp(node, load_op);
        ReplaceNode(node, node, high_node);
      } else {
        DefaultLowering(node);
      }
      break;
    }
    case IrOpcode::kStore:
    case IrOpcode::kUnalignedStore: {
      MachineRepresentation rep;
      if (node->opcode() == IrOpcode::kStore) {
        rep = StoreRepresentationOf(node->op()).representation();
      } else {
        DCHECK_EQ(IrOpcode::kUnalignedStore, node->opcode());
        rep = UnalignedStoreRepresentationOf(node->op());
      }

      if (rep == MachineRepresentation::kWord64) {
        // We change the original store node to store the low word, and create
        // a new store node to store the high word. The effect and control edges
        // are copied from the original store to the new store node, the effect
        // edge of the original store is redirected to the new store.
        Node* base = node->InputAt(0);
        Node* index = node->InputAt(1);
        Node* index_low;
        Node* index_high;
        GetIndexNodes(index, index_low, index_high);
        Node* value = node->InputAt(2);
        DCHECK(HasReplacementLow(value));
        DCHECK(HasReplacementHigh(value));

        const Operator* store_op;
        if (node->opcode() == IrOpcode::kStore) {
          WriteBarrierKind write_barrier_kind =
              StoreRepresentationOf(node->op()).write_barrier_kind();
          store_op = machine()->Store(StoreRepresentation(
              MachineRepresentation::kWord32, write_barrier_kind));
        } else {
          DCHECK_EQ(IrOpcode::kUnalignedStore, node->opcode());
          store_op = machine()->UnalignedStore(MachineRepresentation::kWord32);
        }

        Node* high_node;
        if (node->InputCount() > 3) {
          Node* effect_high = node->InputAt(3);
          Node* control_high = node->InputAt(4);
          high_node = graph()->NewNode(store_op, base, index_high,
                                       GetReplacementHigh(value), effect_high,
                                       control_high);
          node->ReplaceInput(3, high_node);

        } else {
          high_node = graph()->NewNode(store_op, base, index_high,
                                       GetReplacementHigh(value));
        }

        node->ReplaceInput(1, index_low);
        node->ReplaceInput(2, GetReplacementLow(value));
        NodeProperties::ChangeOp(node, store_op);
        ReplaceNode(node, node, high_node);
      } else {
        DefaultLowering(node, true);
      }
      break;
    }
    case IrOpcode::kStart: {
      int parameter_count = GetParameterCountAfterLowering(signature());
      // Only exchange the node if the parameter count actually changed.
      if (parameter_count != static_cast<int>(signature()->parameter_count())) {
        int delta =
            parameter_count - static_cast<int>(signature()->parameter_count());
        int new_output_count = node->op()->ValueOutputCount() + delta;
        NodeProperties::ChangeOp(node, common()->Start(new_output_count));
      }
      break;
    }
    case IrOpcode::kParameter: {
      DCHECK_EQ(1, node->InputCount());
      // Only exchange the node if the parameter count actually changed. We do
      // not even have to do the default lowering because the the start node,
      // the only input of a parameter node, only changes if the parameter count
      // changes.
      if (GetParameterCountAfterLowering(signature()) !=
          static_cast<int>(signature()->parameter_count())) {
        int old_index = ParameterIndexOf(node->op());
        // TODO(wasm): Make this part not wasm specific.
        // Prevent special lowering of the instance parameter.
        if (old_index == kWasmInstanceParameterIndex) {
          DefaultLowering(node);
          break;
        }
        // Adjust old_index to be compliant with the signature.
        --old_index;
        int new_index = GetParameterIndexAfterLowering(signature(), old_index);
        // Adjust new_index to consider the instance parameter.
        ++new_index;
        NodeProperties::ChangeOp(node, common()->Parameter(new_index));

        if (signature()->GetParam(old_index) ==
            MachineRepresentation::kWord64) {
          Node* high_node = graph()->NewNode(common()->Parameter(new_index + 1),
                                             graph()->start());
          ReplaceNode(node, node, high_node);
        }
      }
      break;
    }
    case IrOpcode::kReturn: {
      int input_count = node->InputCount();
      DefaultLowering(node);
      if (input_count != node->InputCount()) {
        int new_return_count = GetReturnCountAfterLowering(signature());
        if (static_cast<int>(signature()->return_count()) != new_return_count) {
          NodeProperties::ChangeOp(node, common()->Return(new_return_count));
        }
      }
      break;
    }
    case IrOpcode::kTailCall: {
      auto call_descriptor =
          const_cast<CallDescriptor*>(CallDescriptorOf(node->op()));
      bool returns_require_lowering =
          GetReturnCountAfterLowering(call_descriptor) !=
          static_cast<int>(call_descriptor->ReturnCount());
      if (DefaultLowering(node) || returns_require_lowering) {
        // Tail calls do not have return values, so adjusting the call
        // descriptor is enough.
        auto new_descriptor = GetI32WasmCallDescriptor(zone(), call_descriptor);
        NodeProperties::ChangeOp(node, common()->TailCall(new_descriptor));
      }
      break;
    }
    case IrOpcode::kCall: {
      auto call_descriptor =
          const_cast<CallDescriptor*>(CallDescriptorOf(node->op()));
      bool returns_require_lowering =
          GetReturnCountAfterLowering(call_descriptor) !=
          static_cast<int>(call_descriptor->ReturnCount());
      if (DefaultLowering(node) || returns_require_lowering) {
        // We have to adjust the call descriptor.
        NodeProperties::ChangeOp(node, common()->Call(GetI32WasmCallDescriptor(
                                           zone(), call_descriptor)));
      }
      if (returns_require_lowering) {
        size_t return_arity = call_descriptor->ReturnCount();
        if (return_arity == 1) {
          // We access the additional return values through projections.
          Node* low_node =
              graph()->NewNode(common()->Projection(0), node, graph()->start());
          Node* high_node =
              graph()->NewNode(common()->Projection(1), node, graph()->start());
          ReplaceNode(node, low_node, high_node);
        } else {
          ZoneVector<Node*> projections(return_arity, zone());
          NodeProperties::CollectValueProjections(node, projections.data(),
                                                  return_arity);
          for (size_t old_index = 0, new_index = 0; old_index < return_arity;
               ++old_index, ++new_index) {
            Node* use_node = projections[old_index];
            DCHECK_EQ(ProjectionIndexOf(use_node->op()), old_index);
            DCHECK_EQ(GetReturnIndexAfterLowering(call_descriptor,
                                                  static_cast<int>(old_index)),
                      static_cast<int>(new_index));
            if (new_index != old_index) {
              NodeProperties::ChangeOp(
                  use_node, common()->Projection(new_index));
            }
            if (call_descriptor->GetReturnType(old_index).representation() ==
                MachineRepresentation::kWord64) {
              Node* high_node = graph()->NewNode(
                  common()->Projection(new_index + 1), node,
                  graph()->start());
              ReplaceNode(use_node, use_node, high_node);
              ++new_index;
            }
          }
        }
      }
      break;
    }
    case IrOpcode::kWord64And: {
      DCHECK_EQ(2, node->InputCount());
      Node* left = node->InputAt(0);
      Node* right = node->InputAt(1);

      Node* low_node =
          graph()->NewNode(machine()->Word32And(), GetReplacementLow(left),
                           GetReplacementLow(right));
      Node* high_node =
          graph()->NewNode(machine()->Word32And(), GetReplacementHigh(left),
                           GetReplacementHigh(right));
      ReplaceNode(node, low_node, high_node);
      break;
    }
    case IrOpcode::kTruncateInt64ToInt32: {
      DCHECK_EQ(1, node->InputCount());
      Node* input = node->InputAt(0);
      ReplaceNode(node, GetReplacementLow(input), nullptr);
      node->NullAllInputs();
      break;
    }
    case IrOpcode::kInt64Add: {
      DCHECK_EQ(2, node->InputCount());

      Node* right = node->InputAt(1);
      node->ReplaceInput(1, GetReplacementLow(right));
      node->AppendInput(zone(), GetReplacementHigh(right));

      Node* left = node->InputAt(0);
      node->ReplaceInput(0, GetReplacementLow(left));
      node->InsertInput(zone(), 1, GetReplacementHigh(left));

      NodeProperties::ChangeOp(node, machine()->Int32PairAdd());
      // We access the additional return values through projections.
      Node* low_node =
          graph()->NewNode(common()->Projection(0), node, graph()->start());
      Node* high_node =
          graph()->NewNode(common()->Projection(1), node, graph()->start());
      ReplaceNode(node, low_node, high_node);
      break;
    }
    case IrOpcode::kInt64Sub: {
      DCHECK_EQ(2, node->InputCount());

      Node* right = node->InputAt(1);
      node->ReplaceInput(1, GetReplacementLow(right));
      node->AppendInput(zone(), GetReplacementHigh(right));

      Node* left = node->InputAt(0);
      node->ReplaceInput(0, GetReplacementLow(left));
      node->InsertInput(zone(), 1, GetReplacementHigh(left));

      NodeProperties::ChangeOp(node, machine()->Int32PairSub());
      // We access the additional return values through projections.
      Node* low_node =
          graph()->NewNode(common()->Projection(0), node, graph()->start());
      Node* high_node =
          graph()->NewNode(common()->Projection(1), node, graph()->start());
      ReplaceNode(node, low_node, high_node);
      break;
    }
    case IrOpcode::kInt64Mul: {
      DCHECK_EQ(2, node->InputCount());

      Node* right = node->InputAt(1);
      node->ReplaceInput(1, GetReplacementLow(right));
      node->AppendInput(zone(), GetReplacementHigh(right));

      Node* left = node->InputAt(0);
      node->ReplaceInput(0, GetReplacementLow(left));
      node->InsertInput(zone(), 1, GetReplacementHigh(left));

      NodeProperties::ChangeOp(node, machine()->Int32PairMul());
      // We access the additional return values through projections.
      Node* low_node =
          graph()->NewNode(common()->Projection(0), node, graph()->start());
      Node* high_node =
          graph()->NewNode(common()->Projection(1), node, graph()->start());
      ReplaceNode(node, low_node, high_node);
      break;
    }
    case IrOpcode::kWord64Or: {
      DCHECK_EQ(2, node->InputCount());
      Node* left = node->InputAt(0);
      Node* right = node->InputAt(1);

      Node* low_node =
          graph()->NewNode(machine()->Word32Or(), GetReplacementLow(left),
                           GetReplacementLow(right));
      Node* high_node =
          graph()->NewNode(machine()->Word32Or(), GetReplacementHigh(left),
                           GetReplacementHigh(right));
      ReplaceNode(node, low_node, high_node);
      break;
    }
    case IrOpcode::kWord64Xor: {
      DCHECK_EQ(2, node->InputCount());
      Node* left = node->InputAt(0);
      Node* right = node->InputAt(1);

      Node* low_node =
          graph()->NewNode(machine()->Word32Xor(), GetReplacementLow(left),
                           GetReplacementLow(right));
      Node* high_node =
          graph()->NewNode(machine()->Word32Xor(), GetReplacementHigh(left),
                           GetReplacementHigh(right));
      ReplaceNode(node, low_node, high_node);
      break;
    }
    case IrOpcode::kWord64Shl: {
      // TODO(turbofan): if the shift count >= 32, then we can set the low word
      // of the output to 0 and just calculate the high word.
      DCHECK_EQ(2, node->InputCount());
      Node* shift = node->InputAt(1);
      if (HasReplacementLow(shift)) {
        // We do not have to care about the high word replacement, because
        // the shift can only be between 0 and 63 anyways.
        node->ReplaceInput(1, GetReplacementLow(shift));
      }

      Node* value = node->InputAt(0);
      node->ReplaceInput(0, GetReplacementLow(value));
      node->InsertInput(zone(), 1, GetReplacementHigh(value));

      NodeProperties::ChangeOp(node, machine()->Word32PairShl());
      // We access the additional return values through projections.
      Node* low_node =
          graph()->NewNode(common()->Projection(0), node, graph()->start());
      Node* high_node =
          graph()->NewNode(common()->Projection(1), node, graph()->start());
      ReplaceNode(node, low_node, high_node);
      break;
    }
    case IrOpcode::kWord64Shr: {
      // TODO(turbofan): if the shift count >= 32, then we can set the low word
      // of the output to 0 and just calculate the high word.
      DCHECK_EQ(2, node->InputCount());
      Node* shift = node->InputAt(1);
      if (HasReplacementLow(shift)) {
        // We do not have to care about the high word replacement, because
        // the shift can only be between 0 and 63 anyways.
        node->ReplaceInput(1, GetReplacementLow(shift));
      }

      Node* value = node->InputAt(0);
      node->ReplaceInput(0, GetReplacementLow(value));
      node->InsertInput(zone(), 1, GetReplacementHigh(value));

      NodeProperties::ChangeOp(node, machine()->Word32PairShr());
      // We access the additional return values through projections.
      Node* low_node =
          graph()->NewNode(common()->Projection(0), node, graph()->start());
      Node* high_node =
          graph()->NewNode(common()->Projection(1), node, graph()->start());
      ReplaceNode(node, low_node, high_node);
      break;
    }
    case IrOpcode::kWord64Sar: {
      // TODO(turbofan): if the shift count >= 32, then we can set the low word
      // of the output to 0 and just calculate the high word.
      DCHECK_EQ(2, node->InputCount());
      Node* shift = node->InputAt(1);
      if (HasReplacementLow(shift)) {
        // We do not have to care about the high word replacement, because
        // the shift can only be between 0 and 63 anyways.
        node->ReplaceInput(1, GetReplacementLow(shift));
      }

      Node* value = node->InputAt(0);
      node->ReplaceInput(0, GetReplacementLow(value));
      node->InsertInput(zone(), 1, GetReplacementHigh(value));

      NodeProperties::ChangeOp(node, machine()->Word32PairSar());
      // We access the additional return values through projections.
      Node* low_node =
          graph()->NewNode(common()->Projection(0), node, graph()->start());
      Node* high_node =
          graph()->NewNode(common()->Projection(1), node, graph()->start());
      ReplaceNode(node, low_node, high_node);
      break;
    }
    case IrOpcode::kWord64Equal: {
      DCHECK_EQ(2, node->InputCount());
      Node* left = node->InputAt(0);
      Node* right = node->InputAt(1);

      // TODO(wasm): Use explicit comparisons and && here?
      Node* replacement = graph()->NewNode(
          machine()->Word32Equal(),
          graph()->NewNode(
              machine()->Word32Or(),
              graph()->NewNode(machine()->Word32Xor(), GetReplacementLow(left),
                               GetReplacementLow(right)),
              graph()->NewNode(machine()->Word32Xor(), GetReplacementHigh(left),
                               GetReplacementHigh(right))),
          graph()->NewNode(common()->Int32Constant(0)));

      ReplaceNode(node, replacement, nullptr);
      break;
    }
    case IrOpcode::kInt64LessThan: {
      LowerComparison(node, machine()->Int32LessThan(),
                      machine()->Uint32LessThan());
      break;
    }
    case IrOpcode::kInt64LessThanOrEqual: {
      LowerComparison(node, machine()->Int32LessThan(),
                      machine()->Uint32LessThanOrEqual());
      break;
    }
    case IrOpcode::kUint64LessThan: {
      LowerComparison(node, machine()->Uint32LessThan(),
                      machine()->Uint32LessThan());
      break;
    }
    case IrOpcode::kUint64LessThanOrEqual: {
      LowerComparison(node, machine()->Uint32LessThan(),
                      machine()->Uint32LessThanOrEqual());
      break;
    }
    case IrOpcode::kChangeInt32ToInt64: {
      DCHECK_EQ(1, node->InputCount());
      Node* input = node->InputAt(0);
      if (HasReplacementLow(input)) {
        input = GetReplacementLow(input);
      }
      // We use SAR to preserve the sign in the high word.
      ReplaceNode(
          node, input,
          graph()->NewNode(machine()->Word32Sar(), input,
                           graph()->NewNode(common()->Int32Constant(31))));
      node->NullAllInputs();
      break;
    }
    case IrOpcode::kChangeUint32ToUint64: {
      DCHECK_EQ(1, node->InputCount());
      Node* input = node->InputAt(0);
      if (HasReplacementLow(input)) {
        input = GetReplacementLow(input);
      }
      ReplaceNode(node, input, graph()->NewNode(common()->Int32Constant(0)));
      node->NullAllInputs();
      break;
    }
    case IrOpcode::kBitcastInt64ToFloat64: {
      DCHECK_EQ(1, node->InputCount());
      Node* input = node->InputAt(0);
      Node* stack_slot = graph()->NewNode(
          machine()->StackSlot(MachineRepresentation::kWord64));

      Node* store_high_word = graph()->NewNode(
          machine()->Store(
              StoreRepresentation(MachineRepresentation::kWord32,
                                  WriteBarrierKind::kNoWriteBarrier)),
          stack_slot,
          graph()->NewNode(
              common()->Int32Constant(kInt64UpperHalfMemoryOffset)),
          GetReplacementHigh(input), graph()->start(), graph()->start());

      Node* store_low_word = graph()->NewNode(
          machine()->Store(
              StoreRepresentation(MachineRepresentation::kWord32,
                                  WriteBarrierKind::kNoWriteBarrier)),
          stack_slot,
          graph()->NewNode(
              common()->Int32Constant(kInt64LowerHalfMemoryOffset)),
          GetReplacementLow(input), store_high_word, graph()->start());

      Node* load =
          graph()->NewNode(machine()->Load(MachineType::Float64()), stack_slot,
                           graph()->NewNode(common()->Int32Constant(0)),
                           store_low_word, graph()->start());

      ReplaceNode(node, load, nullptr);
      break;
    }
    case IrOpcode::kBitcastFloat64ToInt64: {
      DCHECK_EQ(1, node->InputCount());
      Node* input = node->InputAt(0);
      if (HasReplacementLow(input)) {
        input = GetReplacementLow(input);
      }
      Node* stack_slot = graph()->NewNode(
          machine()->StackSlot(MachineRepresentation::kWord64));
      Node* store = graph()->NewNode(
          machine()->Store(
              StoreRepresentation(MachineRepresentation::kFloat64,
                                  WriteBarrierKind::kNoWriteBarrier)),
          stack_slot, graph()->NewNode(common()->Int32Constant(0)), input,
          graph()->start(), graph()->start());

      Node* high_node = graph()->NewNode(
          machine()->Load(MachineType::Int32()), stack_slot,
          graph()->NewNode(
              common()->Int32Constant(kInt64UpperHalfMemoryOffset)),
          store, graph()->start());

      Node* low_node = graph()->NewNode(
          machine()->Load(MachineType::Int32()), stack_slot,
          graph()->NewNode(
              common()->Int32Constant(kInt64LowerHalfMemoryOffset)),
          store, graph()->start());
      ReplaceNode(node, low_node, high_node);
      break;
    }
    case IrOpcode::kWord64Ror: {
      DCHECK_EQ(2, node->InputCount());
      Node* input = node->InputAt(0);
      Node* shift = HasReplacementLow(node->InputAt(1))
                        ? GetReplacementLow(node->InputAt(1))
                        : node->InputAt(1);
      Int32Matcher m(shift);
      if (m.HasValue()) {
        // Precondition: 0 <= shift < 64.
        int32_t shift_value = m.Value() & 0x3F;
        if (shift_value == 0) {
          ReplaceNode(node, GetReplacementLow(input),
                      GetReplacementHigh(input));
        } else if (shift_value == 32) {
          ReplaceNode(node, GetReplacementHigh(input),
                      GetReplacementLow(input));
        } else {
          Node* low_input;
          Node* high_input;
          if (shift_value < 32) {
            low_input = GetReplacementLow(input);
            high_input = GetReplacementHigh(input);
          } else {
            low_input = GetReplacementHigh(input);
            high_input = GetReplacementLow(input);
          }
          int32_t masked_shift_value = shift_value & 0x1F;
          Node* masked_shift =
              graph()->NewNode(common()->Int32Constant(masked_shift_value));
          Node* inv_shift = graph()->NewNode(
              common()->Int32Constant(32 - masked_shift_value));

          Node* low_node = graph()->NewNode(
              machine()->Word32Or(),
              graph()->NewNode(machine()->Word32Shr(), low_input, masked_shift),
              graph()->NewNode(machine()->Word32Shl(), high_input, inv_shift));
          Node* high_node = graph()->NewNode(
              machine()->Word32Or(), graph()->NewNode(machine()->Word32Shr(),
                                                      high_input, masked_shift),
              graph()->NewNode(machine()->Word32Shl(), low_input, inv_shift));
          ReplaceNode(node, low_node, high_node);
        }
      } else {
        Node* safe_shift = shift;
        if (!machine()->Word32ShiftIsSafe()) {
          safe_shift =
              graph()->NewNode(machine()->Word32And(), shift,
                               graph()->NewNode(common()->Int32Constant(0x1F)));
        }

        // By creating this bit-mask with SAR and SHL we do not have to deal
        // with shift == 0 as a special case.
        Node* inv_mask = graph()->NewNode(
            machine()->Word32Shl(),
            graph()->NewNode(machine()->Word32Sar(),
                             graph()->NewNode(common()->Int32Constant(
                                 std::numeric_limits<int32_t>::min())),
                             safe_shift),
            graph()->NewNode(common()->Int32Constant(1)));

        Node* bit_mask =
            graph()->NewNode(machine()->Word32Xor(), inv_mask,
                             graph()->NewNode(common()->Int32Constant(-1)));

        // We have to mask the shift value for this comparison. If
        // !machine()->Word32ShiftIsSafe() then the masking should already be
        // part of the graph.
        Node* masked_shift6 = shift;
        if (machine()->Word32ShiftIsSafe()) {
          masked_shift6 =
              graph()->NewNode(machine()->Word32And(), shift,
                               graph()->NewNode(common()->Int32Constant(0x3F)));
        }

        Diamond lt32(
            graph(), common(),
            graph()->NewNode(machine()->Int32LessThan(), masked_shift6,
                             graph()->NewNode(common()->Int32Constant(32))));

        // The low word and the high word can be swapped either at the input or
        // at the output. We swap the inputs so that shift does not have to be
        // kept for so long in a register.
        Node* input_low =
            lt32.Phi(MachineRepresentation::kWord32, GetReplacementLow(input),
                     GetReplacementHigh(input));
        Node* input_high =
            lt32.Phi(MachineRepresentation::kWord32, GetReplacementHigh(input),
                     GetReplacementLow(input));

        Node* rotate_low =
            graph()->NewNode(machine()->Word32Ror(), input_low, safe_shift);
        Node* rotate_high =
            graph()->NewNode(machine()->Word32Ror(), input_high, safe_shift);

        Node* low_node = graph()->NewNode(
            machine()->Word32Or(),
            graph()->NewNode(machine()->Word32And(), rotate_low, bit_mask),
            graph()->NewNode(machine()->Word32And(), rotate_high, inv_mask));

        Node* high_node = graph()->NewNode(
            machine()->Word32Or(),
            graph()->NewNode(machine()->Word32And(), rotate_high, bit_mask),
            graph()->NewNode(machine()->Word32And(), rotate_low, inv_mask));

        ReplaceNode(node, low_node, high_node);
      }
      break;
    }
    case IrOpcode::kWord64Clz: {
      DCHECK_EQ(1, node->InputCount());
      Node* input = node->InputAt(0);
      Diamond d(
          graph(), common(),
          graph()->NewNode(machine()->Word32Equal(), GetReplacementHigh(input),
                           graph()->NewNode(common()->Int32Constant(0))));

      Node* low_node = d.Phi(
          MachineRepresentation::kWord32,
          graph()->NewNode(machine()->Int32Add(),
                           graph()->NewNode(machine()->Word32Clz(),
                                            GetReplacementLow(input)),
                           graph()->NewNode(common()->Int32Constant(32))),
          graph()->NewNode(machine()->Word32Clz(), GetReplacementHigh(input)));
      ReplaceNode(node, low_node, graph()->NewNode(common()->Int32Constant(0)));
      break;
    }
    case IrOpcode::kWord64Ctz: {
      DCHECK_EQ(1, node->InputCount());
      DCHECK(machine()->Word32Ctz().IsSupported());
      Node* input = node->InputAt(0);
      Diamond d(
          graph(), common(),
          graph()->NewNode(machine()->Word32Equal(), GetReplacementLow(input),
                           graph()->NewNode(common()->Int32Constant(0))));
      Node* low_node =
          d.Phi(MachineRepresentation::kWord32,
                graph()->NewNode(machine()->Int32Add(),
                                 graph()->NewNode(machine()->Word32Ctz().op(),
                                                  GetReplacementHigh(input)),
                                 graph()->NewNode(common()->Int32Constant(32))),
                graph()->NewNode(machine()->Word32Ctz().op(),
                                 GetReplacementLow(input)));
      ReplaceNode(node, low_node, graph()->NewNode(common()->Int32Constant(0)));
      break;
    }
    case IrOpcode::kWord64Popcnt: {
      DCHECK_EQ(1, node->InputCount());
      Node* input = node->InputAt(0);
      // We assume that a Word64Popcnt node only has been created if
      // Word32Popcnt is actually supported.
      DCHECK(machine()->Word32Popcnt().IsSupported());
      ReplaceNode(node, graph()->NewNode(
                            machine()->Int32Add(),
                            graph()->NewNode(machine()->Word32Popcnt().op(),
                                             GetReplacementLow(input)),
                            graph()->NewNode(machine()->Word32Popcnt().op(),
                                             GetReplacementHigh(input))),
                  graph()->NewNode(common()->Int32Constant(0)));
      break;
    }
    case IrOpcode::kPhi: {
      MachineRepresentation rep = PhiRepresentationOf(node->op());
      if (rep == MachineRepresentation::kWord64) {
        // The replacement nodes have already been created, we only have to
        // replace placeholder nodes.
        Node* low_node = GetReplacementLow(node);
        Node* high_node = GetReplacementHigh(node);
        for (int i = 0; i < node->op()->ValueInputCount(); i++) {
          low_node->ReplaceInput(i, GetReplacementLow(node->InputAt(i)));
          high_node->ReplaceInput(i, GetReplacementHigh(node->InputAt(i)));
        }
      } else {
        DefaultLowering(node);
      }
      break;
    }
    case IrOpcode::kWord64ReverseBytes: {
      Node* input = node->InputAt(0);
      ReplaceNode(node, graph()->NewNode(machine()->Word32ReverseBytes().op(),
                                         GetReplacementHigh(input)),
                  graph()->NewNode(machine()->Word32ReverseBytes().op(),
                                   GetReplacementLow(input)));
      break;
    }

    default: { DefaultLowering(node); }
  }
}  // NOLINT(readability/fn_size)

void Int64Lowering::LowerComparison(Node* node, const Operator* high_word_op,
                                    const Operator* low_word_op) {
  DCHECK_EQ(2, node->InputCount());
  Node* left = node->InputAt(0);
  Node* right = node->InputAt(1);
  Node* replacement = graph()->NewNode(
      machine()->Word32Or(),
      graph()->NewNode(high_word_op, GetReplacementHigh(left),
                       GetReplacementHigh(right)),
      graph()->NewNode(
          machine()->Word32And(),
          graph()->NewNode(machine()->Word32Equal(), GetReplacementHigh(left),
                           GetReplacementHigh(right)),
          graph()->NewNode(low_word_op, GetReplacementLow(left),
                           GetReplacementLow(right))));

  ReplaceNode(node, replacement, nullptr);
}

bool Int64Lowering::DefaultLowering(Node* node, bool low_word_only) {
  bool something_changed = false;
  for (int i = NodeProperties::PastValueIndex(node) - 1; i >= 0; i--) {
    Node* input = node->InputAt(i);
    if (HasReplacementLow(input)) {
      something_changed = true;
      node->ReplaceInput(i, GetReplacementLow(input));
    }
    if (!low_word_only && HasReplacementHigh(input)) {
      something_changed = true;
      node->InsertInput(zone(), i + 1, GetReplacementHigh(input));
    }
  }
  return something_changed;
}

void Int64Lowering::ReplaceNode(Node* old, Node* new_low, Node* new_high) {
  // if new_low == nullptr, then also new_high == nullptr.
  DCHECK(new_low != nullptr || new_high == nullptr);
  replacements_[old->id()].low = new_low;
  replacements_[old->id()].high = new_high;
}

bool Int64Lowering::HasReplacementLow(Node* node) {
  return replacements_[node->id()].low != nullptr;
}

Node* Int64Lowering::GetReplacementLow(Node* node) {
  Node* result = replacements_[node->id()].low;
  DCHECK(result);
  return result;
}

bool Int64Lowering::HasReplacementHigh(Node* node) {
  return replacements_[node->id()].high != nullptr;
}

Node* Int64Lowering::GetReplacementHigh(Node* node) {
  Node* result = replacements_[node->id()].high;
  DCHECK(result);
  return result;
}

void Int64Lowering::PreparePhiReplacement(Node* phi) {
  MachineRepresentation rep = PhiRepresentationOf(phi->op());
  if (rep == MachineRepresentation::kWord64) {
    // We have to create the replacements for a phi node before we actually
    // lower the phi to break potential cycles in the graph. The replacements of
    // input nodes do not exist yet, so we use a placeholder node to pass the
    // graph verifier.
    int value_count = phi->op()->ValueInputCount();
    Node** inputs_low = zone()->NewArray<Node*>(value_count + 1);
    Node** inputs_high = zone()->NewArray<Node*>(value_count + 1);
    for (int i = 0; i < value_count; i++) {
      inputs_low[i] = placeholder_;
      inputs_high[i] = placeholder_;
    }
    inputs_low[value_count] = NodeProperties::GetControlInput(phi, 0);
    inputs_high[value_count] = NodeProperties::GetControlInput(phi, 0);
    ReplaceNode(phi,
                graph()->NewNode(
                    common()->Phi(MachineRepresentation::kWord32, value_count),
                    value_count + 1, inputs_low, false),
                graph()->NewNode(
                    common()->Phi(MachineRepresentation::kWord32, value_count),
                    value_count + 1, inputs_high, false));
  }
}
}  // namespace compiler
}  // namespace internal
}  // namespace v8


text:
namespace password_manager {

struct FieldInfo;
class PasswordStoreConsumer;

// Interface for storing stats related to the web forms fields.
class FieldInfoStore {
 public:
  // Adds information about field. If the record for given form_signature and
  // field_signature already exists, the new one will be ignored.
  virtual void AddFieldInfo(const FieldInfo& field_info) = 0;

  // Retrieves all field info and notifies |consumer| on completion. The request
  // will be cancelled if the consumer is destroyed.
  virtual void GetAllFieldInfo(
      base::WeakPtr<PasswordStoreConsumer> consumer) = 0;

  // Removes all leaked credentials in the given date range. If |completion| is
  // not null, it will be posted to the |main_task_runner_| after deletions have
  // been completed. Should be called on the UI thread.
  virtual void RemoveFieldInfoByTime(base::Time remove_begin,
                                     base::Time remove_end,
                                     base::OnceClosure completion) = 0;

 protected:
  virtual ~FieldInfoStore() = default;
};

}  // namespace password_manager

#endif  // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FIELD_INFO_STORE_H_

redpajama_set_name: RedPajamaGithub


text:
package com.jojo.lab.sort;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

import com.jojo.common.entity.Color;
import com.jojo.common.entity.Dress;
import com.jojo.common.entity.Size;
import com.jojo.common.entity.Type;

// apply for java 7
public class Sorter7<T> {

    private List<Comparator<T>> comparetors;

    private List<T> data;

    public Sorter7(List<Comparator<T>> comparetors, List<T> data) {
        super();
        this.comparetors = comparetors;
        this.data = data;
    }

    public List<List<T>> sort() {
        List<List<T>> result = new LinkedList<>();
        result.add(data);
        for (Comparator<T> comparetor : comparetors) {
            List<List<T>> accumulate = new LinkedList<>();
            for (List<T> list : result) {
                accumulate.addAll(sort(list, comparetor));
            }
            result = accumulate;
        }
        return result;
    }

    private List<T> reorder() {
        int size = comparetors.size();
        if (size == 1) {
            Collections.sort(data, comparetors.get(0));
        } else {
            for (int i = 0; i <= size - 2; i++) {
                Collections.sort(data, comparetors.get(i));
            }
        }
        return data;
    }

    private List<List<T>> sort(List<T> data, Comparator<T> comparetor) {
        Collections.sort(data, comparetor);
        LinkedList<List<T>> result = new LinkedList<>();
        ListIterator<T> iterator = data.listIterator();
        T p = iterator.next();
        List<T> list = new LinkedList<>();
        list.add(p);
        result.add(list);
        for (; iterator.hasNext();) {
            T t = iterator.next();
            if (comparetor.compare(t, p) != 0) {
                List<T> subList = new LinkedList<T>();
                subList.add(t);
                result.add(subList);
            } else {
                result.getLast().add(t);
            }
            p = t;
        }
        return result;
    }

    public List<T> deduplicate() {
        reorder();
        List<T> result = new ArrayList<>();
        result.add(data.get(0));
        for (int i = 1; i < data.size(); i++) {
            if (!equals(data.get(i), data.get(i - 1))) {
                result.add(data.get(i));
            }
        }
        return result;
    }

    private boolean equals(T t1, T t2) {
        for (int i = 0; i < comparetors.size(); i++) {
            if (comparetors.get(i).compare(t1, t2) != 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {

        Dress dress0 = new Dress(Color.Red, Type.A, Size.Small);
        Dress dress1 = new Dress(Color.Red, Type.A, Size.Small);
        Dress dress2 = new Dress(Color.Green, Type.B, Size.Large);
        Dress dress3 = new Dress(Color.Green, Type.B, Size.Large);
        Dress dress4 = new Dress(Color.Blue, Type.B, Size.Small);
        Dress dress5 = new Dress(Color.Red, Type.A, Size.Small);
        Dress dress6 = new Dress(Color.Blue, Type.C, Size.Large);

        List<Dress> dersses = new ArrayList<>(6);
        dersses.add(dress5);
        dersses.add(dress3);
        dersses.add(dress0);
        dersses.add(dress4);
        dersses.add(dress2);
        dersses.add(dress1);
        dersses.add(dress6);

        List<Comparator<Dress>> comparetors = new ArrayList<>();
        comparetors.add(new DressColorComparetor());
        comparetors.add(new DressTypeComparetor());
        comparetors.add(new DressSizeComparetor());
        Sorter7<Dress> sorter = new Sorter7<>(comparetors, dersses);
        sorter.reorder();
        List<List<Dress>> r1 = sorter.sort();
        System.out.println(r1);
        List<Dress> r2 = sorter.deduplicate();
        System.out.println(r2);
    }

    static class DressColorComparetor implements Comparator<Dress> {
        @Override
        public int compare(Dress o1, Dress o2) {
            return o1.getColor().compareTo(o2.getColor());
        }
    }

    static class DressTypeComparetor implements Comparator<Dress> {
        @Override
        public int compare(Dress o1, Dress o2) {
            return o1.getType().compareTo(o2.getType());
        }
    }

    static class DressSizeComparetor implements Comparator<Dress> {
        @Override
        public int compare(Dress o1, Dress o2) {
            return o1.getSize().compareTo(o2.getSize());
        }
    }

}


text:
<?php

namespace Proxies\__CG__\Site\SavalizeBundle\Entity;

/**
 * THIS CLASS WAS GENERATED BY THE DOCTRINE ORM. DO NOT EDIT THIS FILE.
 */
class Company extends \Site\SavalizeBundle\Entity\Company implements \Doctrine\ORM\Proxy\Proxy
{
    private $_entityPersister;
    private $_identifier;
    public $__isInitialized__ = false;
    public function __construct($entityPersister, $identifier)
    {
        $this->_entityPersister = $entityPersister;
        $this->_identifier = $identifier;
    }
    /** @private */
    public function __load()
    {
        if (!$this->__isInitialized__ && $this->_entityPersister) {
            $this->__isInitialized__ = true;

            if (method_exists($this, "__wakeup")) {
                // call this after __isInitialized__to avoid infinite recursion
                // but before loading to emulate what ClassMetadata::newInstance()
                // provides.
                $this->__wakeup();
            }

            if ($this->_entityPersister->load($this->_identifier, $this) === null) {
                throw new \Doctrine\ORM\EntityNotFoundException();
            }
            unset($this->_entityPersister, $this->_identifier);
        }
    }

    /** @private */
    public function __isInitialized()
    {
        return $this->__isInitialized__;
    }

    public function getId()
    {
        if ($this->__isInitialized__ === false) {
            return (int) $this->_identifier["id"];
        }
        $this->__load();
        return parent::getId();
    }

    public function setName($name)
    {
        $this->__load();
        return parent::setName($name);
    }

    public function getName()
    {
        $this->__load();
        return parent::getName();
    }

    public function setUsername($username)
    {
        $this->__load();
        return parent::setUsername($username);
    }

    public function getUsername()
    {
        $this->__load();
        return parent::getUsername();
    }

    public function setPassword($password)
    {
        $this->__load();
        return parent::setPassword($password);
    }

    public function getPassword()
    {
        $this->__load();
        return parent::getPassword();
    }

    public function setEmail($email)
    {
        $this->__load();
        return parent::setEmail($email);
    }

    public function getEmail()
    {
        $this->__load();
        return parent::getEmail();
    }

    public function setTelphone($telphone)
    {
        $this->__load();
        return parent::setTelphone($telphone);
    }

    public function getTelphone()
    {
        $this->__load();
        return parent::getTelphone();
    }

    public function setCountry($country)
    {
        $this->__load();
        return parent::setCountry($country);
    }

    public function getCountry()
    {
        $this->__load();
        return parent::getCountry();
    }

    public function setCity($city)
    {
        $this->__load();
        return parent::setCity($city);
    }

    public function getCity()
    {
        $this->__load();
        return parent::getCity();
    }

    public function setRegion($region)
    {
        $this->__load();
        return parent::setRegion($region);
    }

    public function getRegion()
    {
        $this->__load();
        return parent::getRegion();
    }

    public function addHistory(\Site\SavalizeBundle\Entity\History $history)
    {
        $this->__load();
        return parent::addHistory($history);
    }

    public function removeHistory(\Site\SavalizeBundle\Entity\History $history)
    {
        $this->__load();
        return parent::removeHistory($history);
    }

    public function getHistory()
    {
        $this->__load();
        return parent::getHistory();
    }

    public function __sleep()
    {
        return array('__isInitialized__', 'id', 'name', 'username', 'password', 'email', 'telphone', 'country', 'city', 'region', 'history');
    }

    public function __clone()
    {
        if (!$this->__isInitialized__ && $this->_entityPersister) {
            $this->__isInitialized__ = true;
            $class = $this->_entityPersister->getClassMetadata();
            $original = $this->_entityPersister->load($this->_identifier);
            if ($original === null) {
                throw new \Doctrine\ORM\EntityNotFoundException();
            }
            foreach ($class->reflFields as $field => $reflProperty) {
                $reflProperty->setValue($this, $reflProperty->getValue($original));
            }
            unset($this->_entityPersister, $this->_identifier);
        }

    }
}


text:
html, body {
    margin:0;
    height:100%;
}
#webperf-wrapper {
    position:fixed;
    display:flex;
    display: -webkit-flex;
    width:100%;
    background:black;
    bottom:0;
    left:0;
    text-align:center;
    padding: 6px 0px;
}
#webperf-client, #webperf-server, #webperf-resources, #webperf-webpagetest, #webperf-wpt-images {
    display:inline-block;
    width:100%;
    position:relative;
}
.webperf-label {
    font-size:14px;
    font-weight:500;
    color:white;
}
.webperf-value {
    font-size:14px;
    color:white;
}
.webperf-green {
    color:#32CD32;
}
.webperf-red {
    color:#f00;
}
#webperf-resourceInfo, #webperf-webpagetestInfo, #webperf-wpt-images-content, #webperf-countries {
	position:absolute;
	top:-256px;
	left:0;
	width:100%;
	height:250px;
	overflow:auto;
	overflow-x:hidden;
	background:white;
	border-top: 1px solid black;
	border-left: 1px solid black;
	border-right: 1px solid black;
	padding:0;
}

#webperf-countries {
	height:300px;
	top:-306px;
}

#webperf-countries > li {
	height:auto;
	width:100%;
	display:flex;
	display: -webkit-flex;
}

#webperf-countries > li > span {
	width:50%;
	border:1px solid black;
	padding:5px 0px;
}

#webperf-countries > li > span:nth-child(odd) {
    background-color: lightgray;
}

#webperf-webpagetestInfo {
	height: 225px;
	top: -231px;
}
#webperf-resourceInfo > li, #webperf-webpagetestInfo > li {
	display:flex;
	display: -webkit-flex;
	width:100%;
}
#webperf-resourceInfo > li > span, #webperf-webpagetestInfo > li > span {
	display:inline-block;
	width:100%;
	border:1px solid black;
	overflow:hidden;
}
#webperf-webpagetestInfo > li > span {
	border:0;
}
#webperf-webpagetestInfo > li > span > div{
	border:1px solid black;
	padding:5px 0px;
}

#webperf-wpt-images-content {
	height: 300px;
	top: -306px;
	overflow-x: scroll;
	overflow-y: hidden;
	white-space: nowrap;
}

#webperf-wpt-images-content > li {
	display:inline-block;
	height:100%;
	width:85%;
	border:1px solid black;
}

#webperf-wpt-images-content > li > div{
	height:auto;
	text-align: center;
	padding:5px 0px;
}

#webperf-wpt-images-content > li > div img{
	max-width: 100%;
}

.webperf-hide {
	display:none;
}


text:
package org.codehaus.xfire.fault;

import java.util.HashMap;
import java.util.Map;

import javax.xml.namespace.QName;

import org.codehaus.xfire.XFireException;
import org.codehaus.xfire.soap.Soap11;
import org.codehaus.xfire.soap.Soap12;
import org.jdom.Element;

/**
 * In XFire, applications throw their own declared exceptions which are then turned into faults.  The
 * XFireFault class wraps these exceptions extracting out the details for the fault message.
 *

 * If the developer wishes to generate their own custom fault messages, they can either override XFireFault to provide
 * the FaultHandlers with the necessary information or write a new FaultHandler.

 *

 * TODO Add i18n support
 *
 * @author Dan Diephouse
 * @since Feb 14, 2004
 */
public class XFireFault
        extends XFireException
{
    /**
	 * Serialization ID.
	 */
	private static final long serialVersionUID = 2L;

	/**
     * Fault codes.
     */
    private final static String ns12 = Soap12.getInstance().getNamespace();
    private final static String ns11 = Soap11.getInstance().getNamespace();

    public final static QName VERSION_MISMATCH = new QName(ns12, "VersionMismatch");
    public final static QName MUST_UNDERSTAND = new QName(ns12, "MustUnderstand");
    public final static QName DATA_ENCODING_UNKNOWN = new QName(ns12, "DataEncodingUnknown");

    /**
     * "The message was incorrectly formed or did not contain the appropriate information in order to succeed." -- SOAP
     * 1.2 Spec
     */
    public final static QName SENDER = new QName(ns12, "Sender");

    /**
     * A SOAP 1.2 only fault code.
     *

     * "The message could not be processed for reasons attributable to the processing of the message rather than to the
     * contents of the message itself." -- SOAP 1.2 Spec
     *

     * If this message is used in a SOAP 1.1 Fault it will most likely (depending on the FaultHandler) be mapped to
     * "Sender" instead.
     */
    public final static QName RECEIVER = new QName(ns12, "Receiver");

    public final static QName SOAP11_SERVER = new QName(ns11, "Server");
    public final static QName SOAP11_CLIENT = new QName(ns11, "Client");
    public final static QName SOAP11_MUST_UNDERSTAND = new QName(ns11, "MustUnderstand");
    public final static QName SOAP11_VERSION_MISMATCH = new QName(ns11, "VersionMismatch");

    private QName faultCode;
    private QName subCode;
    private String message;
    private String role;
    private Element detail;
    private Map namespaces;

    /**
     * Creates a XFireFault from the given throwable. If the throwable is a XFireFault, it is
     * not wrapped.
     *
     * @param throwable the throwable
     * @return the fault
     */
    public static XFireFault createFault(Throwable throwable)
    {
        XFireFault fault = null;

        if (throwable instanceof XFireFault)
        {
            fault = (XFireFault) throwable;
        }
        else
        {
            fault = new XFireFault(throwable);
        }

        return fault;
    }

    protected XFireFault()
    {
    }

    /**
     * Create a fault for the specified exception. The faultCode is set to RECEIVER.
     *
     * @param throwable
     */
    public XFireFault(Throwable throwable)
    {
        this(throwable.getMessage(), throwable, RECEIVER);
    }

    /**
     * Create a fault with the specified faultCode. The exception message is used for the fault message.
     *
     * @param throwable The exception that caused this fault.
     * @param code      The fault code. See XFireFault's static fields.
     */
    public XFireFault(Throwable throwable, QName code)
    {
        this(throwable.getMessage(), throwable, code);
    }

    /**
     * Create an exception wih the specified fault message and faultCode.
     *
     * @param message The fault message.
     * @param code    The fault code. See XFireFault's static fields.
     */
    public XFireFault(String message, QName code)
    {
        this(message, null, code);
    }

    /**
     * Create a fault.
     *
     * @param cause The exception which caused this fault.
     * @param code  The fault code. See XFireFault's static fields.
     */
    public XFireFault(String message,
                      Throwable cause,
                      QName code)
    {
        super(message, cause);

        this.message = message != null ? message : "Fault: " + cause.getClass().getName();
        this.faultCode = code;
        this.namespaces = new HashMap();
    }

    /**
     * Adds a namespace with prefix to this fault.
     *
     * @param prefix the prefix
     * @param ns     the namespace.
     */
    public void addNamespace(String prefix, String ns)
    {
        namespaces.put(prefix, ns);
    }

    /**
     * Returns the detail node. If no detail node has been set, an empty <detail> is created.
     *
     * @return the detail node.
     */
    public Element getDetail()
    {
        if (detail == null)
        {
            detail = new Element("detail");
        }
        return detail;
    }

    /**
     * Sets a details Node on this fault.
     *
     * @param details the detail node.
     */
    public void setDetail(Element details)
    {
        detail = details;
    }

    /**
     * Returns the fault code of this fault.
     *
     * @return the fault code.
     */
    public QName getFaultCode()
    {
        return faultCode;
    }

    /**
     * Sets the fault code of this fault.
     *
     * @param faultCode the fault code.
     */
    public void setFaultCode(QName faultCode)
    {
        this.faultCode = faultCode;
    }

    /**
     * Returns the detail message string of this fault.
     *
     * @return the detail message string of this XfireFault (which may be null)
     */
    public String getMessage()
    {
        return message;
    }

    /**
     * @param message The message to set.
     */
    public void setMessage(String message)
    {
        this.message = message;
    }

    /**
     * User defined namespaces which will be written out on the resultant SOAP Fault (for use easy with SubCodes and
     * Detail) elements.
     *
     * @return
     */
    public Map getNamespaces()
    {
        return namespaces;
    }

    public String getReason()
    {
        return getMessage();
    }

    /**
     * Returns the fault actor.
     *
     * @return the fault actor.
     */
    public String getRole()
    {
        return role;
    }

    /**
     * Sets the fault actor.
     *
     * @param actor the actor.
     */
    public void setRole(String actor)
    {
        this.role = actor;
    }

    /**
     * Returns the SubCode for the Fault Code.
     *
     * @return The SubCode element as detailed by the SOAP 1.2 spec.
     */
    public QName getSubCode()
    {
        return subCode;
    }

    /**
     * Sets the SubCode for the Fault Code.
     *
     * @param subCode The SubCode element as detailed by the SOAP 1.2 spec.
     */
    public void setSubCode(QName subCode)
    {
        this.subCode = subCode;
    }

    /**
     * Indicates whether this fault has a detail message.
     *
     * @return true if this fault has a detail message; false otherwise.
     */
    public boolean hasDetails()
    {
        return detail == null ? false : true;
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/home_background" >

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:divider="@null"
        android:dividerHeight="10dp"
        android:padding="10dp" >

    </ListView>

    <ViewStub
        android:id="@android:id/empty"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout="@layout/fragment_notes_null" />

</FrameLayout>


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:orientation="vertical" >

   	<LinearLayout
   	    android:id="@+id/line1"
   	    android:layout_width="fill_parent"
   	    android:layout_height="match_parent"
   	    android:orientation="vertical" >

   	    <TextView
   	        android:id="@+id/text1"
   	    android:layout_width="fill_parent"
   	    android:layout_height="wrap_content"
   	    android:text="Phan Nhom"
   	    android:textSize="30sp"
   	    android:textStyle="bold"
   	        ></TextView>

   	    <ListView
   	        android:id="@+id/lisst1"
   	        android:layout_width="fill_parent"
   	        android:layout_height="261dp" >
</ListView>
   	    <LinearLayout
   	    android:id="@+id/line2"
   	    android:layout_width="fill_parent"
   	    android:layout_height="wrap_content"
   	    android:orientation="horizontal"
   	    >
   	    <Spinner
   	         android:id="@+id/spin3"
   	    android:layout_width="fill_parent"
   	    android:layout_height="wrap_content"
   	    android:layout_weight="1"
   	    android:text="Thêm Loại Giao Dịch"
   	        ></Spinner>
   	    <Button
   	    android:id="@+id/nguyenbutton1"
   	    android:layout_width="fill_parent"
   	    android:layout_height="60dp"
   	    android:layout_weight="4"
   	    android:background="@drawable/cong"
   	        ></Button>
   	</LinearLayout>
   	</LinearLayout>
</LinearLayout>


text:
<?php

namespace PhalconTest\Http\Response;

use Phalcon\Http\Response\Headers as PhHeaders;

class Headers extends PhHeaders
{
    public function set($name, $value)
    {
        parent::set($name, $value);
    }

    public function get($name)
    {
        parent::get($name);
    }

    public function setRaw($header)
    {
        parent::setRaw($header);
    }

    public function remove($header)
    {
        parent::remove($header);
    }

    public function send()
    {
        parent::send();
    }

    public function reset()
    {
        parent::reset();
    }

    public function toArray()
    {
        return parent::toArray();
    }

    public static function __set_state($data)
    {
        return parent::__set_state($data);
    }
}


text:
const {isISBN} = require('validator');

module.exports = (str, {version}={}) => {
  if (typeof str === 'string') {
    return isISBN(str, version);
  } else {
    return false;
  }
};


text:
import anyTest, { TestInterface } from 'ava';
import { testReflectedProperty } from '../reflectPropertiesHelper';
import { HTMLButtonElement } from '../../worker-thread/dom/HTMLButtonElement';
import { createTestingDocument } from '../DocumentCreation';

const test = anyTest as TestInterface<{
  element: HTMLButtonElement;
}>;

test.beforeEach((t) => {
  const document = createTestingDocument();

  t.context = {
    element: document.createElement('button') as HTMLButtonElement,
  };
});

testReflectedProperty({ disabled: [false] });
testReflectedProperty({ formAction: [''] }, 'hello');
testReflectedProperty({ formEnctype: [''] });
testReflectedProperty({ formMethod: [''] });
testReflectedProperty({ formTarget: [''] });
testReflectedProperty({ name: [''] });
testReflectedProperty({ type: ['submit'] });
testReflectedProperty({ value: [''] });
testReflectedProperty({ autofocus: [false] });


text:
import { helpers } from 'utils';
import list from 'list';

/**
 * @name BaseReferenceEditorController
 * @memberof module:core.form.editors.reference.controllers
 * @class Base data provider class for {@link module:core.form.editors.ReferenceEditorView ReferenceEditorView}.
 * Data request is performed by fetching Backbone.Collection passed via options.collection option.
 * Various scenarios are covered and server request is made only if it is required.
 * @param {Object} options Options object.
 * @param {Backbone.Collection} options.collection Backbone.Collection of objects. The objects must have id and text attributes.
 * The collection must implement fetch() method that supports text filtration.
 * For example, the call collection.fetch({ data: { filter: 'myFilterText' } }) must
 * fetch the objects which contains 'myFilterText' in it's text attribute.
 * Besides that, the collection.totalCount attribute must be updated during the fetch and contain
 * the total count of object with the applied filter on server.
 * */

export default Marionette.MnObject.extend(
    /** @lends module:core.form.editors.reference.controllers.BaseReferenceEditorController.prototype */ {
        initialize(options) {
            helpers.ensureOption(options, 'collection');

            this.collection = list.factory.createWrappedCollection(options);
        },

        /**
         * Requests data with a text filter applied.
         * @param {Object} options Options object.
         * @param {Object} options.text Text filter filter to apply or null.
         * @return {Promise} Promise object that resolves when the data is ready.
         * */
        fetch({ text = '' }) {
            return this.collection.fetch({ data: { filter: text } }).then(() => {
                this.collection.rebuild();
                this.totalCount = this.collection.parentCollection ? this.collection.parentCollection.totalCount : this.collection.totalCount;

                return {
                    collection: this.collection.toJSON(),
                    totalCount: this.totalCount
                };
            });
        },

        /*
    * Backbone.Collection that should be used to read data. The data should not be fetched from this object directly.
    * Use the controller's fetch() method instead.
    * */
        collection: null,

        createValueUrl() {
            return false;
        },

        /**
         * Handles the edit request to the editor.
         * @param {Object} value Value object that describes the object to edit.
         * */
        edit() {
            return false;
        }
    }
);


text:
/**
 * Created by shuding on 5/23/15.
 * <ds303077135@gmail.com>
 */

;
(function () {
    var sortMethod = 'created_at';
    var $container = $('#story-container');
    var prefix = '/Anniversary110yr/Chitoge';
    var articles = [];
    var templateStr = '
' + '
' + '
{{name}}
{{parseInt(year)}} 届毕业生' + '
' + '

{{content}}{{image?"
":""}}

' + '
' + '{{moment(created_at).locale("zh-CN").fromNow();}}' + '赞 {{starCount}}' + '
' + '
';

    $.ajaxSetup({
        beforeSend: function (xhr) {
            function getCookie(name) {
                var cookieValue = null;
                if (document.cookie && document.cookie != '') {
                    var cookies = document.cookie.split(';');
                    for (var i = 0; i < cookies.length; i++) {
                        var cookie = jQuery.trim(cookies[i]);
                        if (cookie.substring(0, name.length + 1) == (name + '=')) {
                            cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                            break;
                        }
                    }
                }
                return cookieValue;
            }

            xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
        }
    });

    var preventXSS = function (str) {
        return (str + '').replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"');
    };

    var compileTemplate = function (data) {
        return templateStr.replace(/{{(.+?)}}/g, function (match, js) {
            with (data) {
                var res = eval(js);
                if (['name', 'year', 'content'].indexOf(js) !== -1) {
                    return preventXSS(res);
                }
                return res;
            }
        });
    };

    var openPhotoSwipe = function (src) {
        var pswpElement = $('.pswp')[0];
        var items = [], options = {
            index:        0,
            shareButtons: [{
                id:       'download',
                label:    '下载图片',
                url:      '{{raw_image_url}}',
                download: true
            }, {
                id:    'facebook',
                label: '分享到 Facebook',
                url:   'https://www.facebook.com/sharer/sharer.php?u={{url}}'
            }, {
                id:    'twitter',
                label: '分享到 Tweet',
                url:   'https://twitter.com/intent/tweet?text={{text}}&url={{raw_image_url}}'
            }]
        };
        $('.figure').each(function (index, el) {
            var title = $(el).parent('p').text();
            items.push({
                src:   this.src,
                h:     this.naturalHeight,
                w:     this.naturalWidth,
                title: title
            });
            if (this.src == src) {
                options.index = index;
            }
        });
        var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
        gallery.init();
    };

    var fetchArticles = function () {
        if (fetchArticles.lock) {
            return false;
        }
        fetchArticles.lock = 1;
        setTimeout(function () {
            if (fetchArticles.lock == 2) {
                fetchArticles.lock = false;
            } else {
                fetchArticles.lock = 2;
            }
        }, 1000); // Request of 1000ms idle
        var offset = articles.length;
        $.get(prefix + '/article/list?field=' + sortMethod + '&offset=' + offset).success(function (data) {
            if (fetchArticles.lock == 2) {
                fetchArticles.lock = false;
            } else {
                fetchArticles.lock = 2;
            }
            articles = articles.concat(data);
            data.forEach(function (obj) {
                var $newArticle = $(compileTemplate(obj));
                $container.append($newArticle);
                $newArticle.find('img').each(function () {
                    this.onclick = function () {
                        openPhotoSwipe(this.src);
                    };
                });
                $newArticle.find('.button.up').click(function () {
                    if (!$newArticle.find('.up-number').hasClass('liked')) {
                        $.post(prefix + '/star/' + obj.id + '/').success(function (data) {
                            $newArticle.find('.up-number').addClass('liked').html('赞 ' + data.starCount);
                        }).error(function (data) {
                            $newArticle.find('.up-number').addClass('liked');
                        });
                    } else {
                        $.post(prefix + '/unstar/' + obj.id + '/').success(function (data) {
                            $newArticle.find('.up-number').removeClass('liked').html('赞 ' + data.starCount);
                        }).error(function (data) {
                            $newArticle.find('.up-number').removeClass('liked')
                        });
                    }
                });
            });
        });
    };

    $(document).ready(function () {

        fetchArticles();

        $(window).scroll(function () {
            if ($(window).scrollTop() > $(document).height() - $(window).height() - 100) {
                fetchArticles();
            }
        });

        $('#sort-btn').click(function () {
            if (sortMethod == 'created_at') {
                sortMethod = 'starCount';
                $(this).text('按发布时间排序');
            } else {
                sortMethod = 'created_at';
                $(this).text('按点赞数排序');
            }
            articles = [];
            $container.html('');
            fetchArticles();
        });
    });
})();


text:
/*
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.orientechnologies.orient.server.handler.distributed;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.command.OCommandOutputListener;
import com.orientechnologies.orient.core.config.OContextConfiguration;
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.record.ODatabaseRecord;
import com.orientechnologies.orient.core.db.tool.ODatabaseExport;
import com.orientechnologies.orient.core.record.ORecordInternal;
import com.orientechnologies.orient.core.tx.OTransactionEntry;
import com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryClient;
import com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryOutputStream;
import com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryProtocol;
import com.orientechnologies.orient.enterprise.channel.distributed.OChannelDistributedProtocol;

/**
 * Contains all the information about a cluster node.
 *
 * @author Luca Garulli (l.garulli--at--orientechnologies.com)
 *
 */
public class ODistributedServerNodeRemote implements OCommandOutputListener {
	public enum STATUS {
		DISCONNECTED, CONNECTING, CONNECTED, UNREACHABLE, SYNCHRONIZING
	}

	public enum SYNCH_TYPE {
		SYNCHRONOUS, ASYNCHRONOUS
	}

	private String																			id;
	public String																				networkAddress;
	public int																					networkPort;
	public Date																					joinedOn;
	private ODistributedServerManager										manager;
	private OChannelBinaryClient												channel;
	private OContextConfiguration												configuration;
	private volatile STATUS															status					= STATUS.DISCONNECTED;
	private List<OTransactionEntry<ORecordInternal<?>>>	bufferedChanges	= new ArrayList<OTransactionEntry<ORecordInternal<?>>>();
	private int																					clientTxId			= 0;
	private long																				lastHeartBeat		= 0;
	private volatile long																dbVersion;
	private String																			database;
	private final ExecutorService												asynchExecutor;

	public ODistributedServerNodeRemote(final ODistributedServerManager iNode, final String iServerAddress, final int iServerPort) {
		manager = iNode;
		networkAddress = iServerAddress;
		networkPort = iServerPort;
		joinedOn = new Date();
		configuration = new OContextConfiguration();
		id = networkAddress + ":" + networkPort;
		status = STATUS.CONNECTING;

		asynchExecutor = Executors.newSingleThreadExecutor();
	}

	public void connect(final int iTimeout) throws IOException {
		configuration.setValue(OGlobalConfiguration.NETWORK_SOCKET_TIMEOUT, iTimeout);
		channel = new OChannelBinaryClient(networkAddress, networkPort, configuration);

		OChannelBinaryProtocol.checkProtocolVersion(channel);

		OLogManager.instance().warn(this, "Joining the server node %s:%d to the cluster...", networkAddress, networkPort);

		channel.writeByte(OChannelDistributedProtocol.REQUEST_DISTRIBUTED_CONNECT);
		channel.writeInt(clientTxId);

		// PACKET DB INFO TO SEND
		channel.writeString(database);
		if (database != null) {
			channel.writeString(manager.getClusterDbSecurity(database)[0]);
			channel.writeString(manager.getClusterDbSecurity(database)[1]);
		}

		channel.flush();

		channel.readStatus();
		dbVersion = channel.readLong();

		if (status == STATUS.CONNECTING)
			OLogManager.instance().info(this, "Server node %s:%d has joined the cluster", networkAddress, networkPort);
		else
			OLogManager.instance().info(this, "Server node %s:%d has re-joined the cluster after %d secs", networkAddress, networkPort,
					(System.currentTimeMillis() - lastHeartBeat) / 1000);

		lastHeartBeat = System.currentTimeMillis();
	}

	public void sendRequest(final OTransactionEntry<ORecordInternal<?>> iRequest, final SYNCH_TYPE iRequestType) throws IOException {
		if (status == STATUS.UNREACHABLE)
			bufferChange(iRequest);
		else {
			OLogManager.instance().info(this, "-> Sending request to remote server %s in %s mode...", this, iRequestType);

			final ORecordInternal<?> record = iRequest.getRecord();

			status = STATUS.SYNCHRONIZING;

			try {
				switch (iRequest.status) {
				case OTransactionEntry.CREATED:
					channel.acquireExclusiveLock();
					try {
						channel.writeByte(OChannelDistributedProtocol.REQUEST_RECORD_CREATE);
						channel.writeInt(clientTxId);
						channel.writeShort((short) record.getIdentity().getClusterId());
						channel.writeBytes(record.toStream());
						channel.writeByte(record.getRecordType());
						channel.flush();

						final Callable<Object> response = new Callable<Object>() {
							@Override
							public Object call() throws Exception {
								try {
									beginResponse();
									dbVersion++;
									channel.readLong();

								} finally {
									endResponse();
								}
								return null;
							}
						};

						if (iRequestType == SYNCH_TYPE.ASYNCHRONOUS)
							asynchExecutor.submit(new FutureTask<Object>(response));
						else
							try {
								response.call();
							} catch (Exception e) {
							}

					} finally {
						channel.releaseExclusiveLock();
					}
					break;

				case OTransactionEntry.UPDATED:
					channel.acquireExclusiveLock();
					try {
						channel.writeByte(OChannelDistributedProtocol.REQUEST_RECORD_UPDATE);
						channel.writeInt(clientTxId);
						channel.writeShort((short) record.getIdentity().getClusterId());
						channel.writeLong(record.getIdentity().getClusterPosition());
						channel.writeBytes(record.toStream());
						channel.writeInt(record.getVersion());
						channel.writeByte(record.getRecordType());
						channel.flush();

						final Callable<Object> response = new Callable<Object>() {
							@Override
							public Object call() throws Exception {
								try {
									beginResponse();
									dbVersion++;
									channel.readInt();

								} finally {
									endResponse();
								}
								return null;
							}
						};

						if (iRequestType == SYNCH_TYPE.ASYNCHRONOUS)
							asynchExecutor.submit(new FutureTask<Object>(response));
						else
							try {
								response.call();
							} catch (Exception e) {
							}

					} finally {
						channel.releaseExclusiveLock();
					}
					break;

				case OTransactionEntry.DELETED:
					channel.acquireExclusiveLock();
					try {
						channel.writeByte(OChannelDistributedProtocol.REQUEST_RECORD_DELETE);
						channel.writeInt(clientTxId);
						channel.writeShort((short) record.getIdentity().getClusterId());
						channel.writeLong(record.getIdentity().getClusterPosition());
						channel.writeInt(record.getVersion());
						channel.flush();

						final Callable<Object> response = new Callable<Object>() {
							@Override
							public Object call() throws Exception {
								try {
									beginResponse();
									dbVersion++;
									channel.readByte();

								} finally {
									endResponse();
								}
								return null;
							}
						};

						if (iRequestType == SYNCH_TYPE.ASYNCHRONOUS)
							asynchExecutor.submit(new FutureTask<Object>(response));
						else
							try {
								response.call();
							} catch (Exception e) {
							}

					} finally {
						channel.releaseExclusiveLock();
					}
					break;
				}

				status = STATUS.CONNECTED;

			} catch (IOException e) {
				manager.handleNodeFailure(this);

				if (iRequestType == SYNCH_TYPE.SYNCHRONOUS) {
					// SYNCHRONOUS CASE: RE-THROW THE EXCEPTION NOW TO BEING PROPAGATED UP TO THE CLIENT
					throw e;
				} else
					// BUFFER THE REQUEST TO BE RE-EXECUTED WHEN RECONNECTED
					bufferChange(iRequest);
			}
		}
	}

	protected void bufferChange(final OTransactionEntry<ORecordInternal<?>> iRequest) {
		synchronized (bufferedChanges) {
			if (bufferedChanges.size() > manager.serverOutSynchMaxBuffers) {
				// BUFFER EXCEEDS THE CONFIGURED LIMIT: REMOVE MYSELF AS NODE
				manager.removeNode(this);
				bufferedChanges.clear();
			} else {
				try {
					// CHECK IF ANOTHER REQUEST FOR THE SAME RECORD ID HAS BEEN ALREADY BUFFERED
					OTransactionEntry<ORecordInternal<?>> entry;
					for (int i = 0; i < bufferedChanges.size(); ++i) {
						entry = bufferedChanges.get(i);

						if (entry.getRecord().getIdentity().equals(iRequest.getRecord().getIdentity())) {
							// FOUND: REPLACE IT
							bufferedChanges.set(i, iRequest);
							return;
						}
					}

					// BUFFERIZE THE REQUEST
					bufferedChanges.add(iRequest);
				} finally {
					OLogManager.instance().info(this, "Can't reach the remote node '%s', buffering change %d/%d for the record %s", id,
							bufferedChanges.size(), manager.serverOutSynchMaxBuffers, iRequest.getRecord().getIdentity());
				}
			}
		}
	}

	public void sendConfiguration(final String iDatabaseName) {
		OLogManager.instance().info(this, "Sending configuration to distributed server node %s:%d...", networkAddress, networkPort);

		channel.acquireExclusiveLock();

		try {
			channel.writeByte(OChannelDistributedProtocol.REQUEST_DISTRIBUTED_DB_CONFIG);
			channel.writeInt(clientTxId);
			channel.writeBytes(manager.getClusterConfiguration(iDatabaseName).toStream());
			channel.flush();

			try {
				beginResponse();
			} finally {
				endResponse();
			}

		} catch (Exception e) {
			e.printStackTrace();

		} finally {
			channel.releaseExclusiveLock();
		}
	}

	public boolean sendHeartBeat(final int iNetworkTimeout) {
		configuration.setValue(OGlobalConfiguration.NETWORK_SOCKET_TIMEOUT, iNetworkTimeout);
		OLogManager.instance()
				.debug(this, "Sending keepalive message to distributed server node %s:%d...", networkAddress, networkPort);

		channel.acquireExclusiveLock();

		try {
			channel.writeByte(OChannelDistributedProtocol.REQUEST_DISTRIBUTED_HEARTBEAT);
			channel.writeInt(-1);
			channel.flush();

			long remoteVersion = -1;

			try {
				channel.beginResponse(-1);
				remoteVersion = channel.readLong();

			} finally {
				channel.endResponse();
			}

			// RESET LAST HEARTBEAT
			lastHeartBeat = System.currentTimeMillis();

			// CHECK DATABASE VERSION
			if (remoteVersion != dbVersion) {
				OLogManager.instance().warn(this,
						"Database version doesn't match between current node (" + dbVersion + ") and remote (" + remoteVersion + ")");

				throw new ODistributedException("Database version doesn't match between current node (" + dbVersion + ") and remote ("
						+ remoteVersion + ")");
			}

		} catch (Exception e) {
			return false;

		} finally {
			channel.releaseExclusiveLock();
		}

		return true;
	}

	/**
	 * Sets the node as DISCONNECTED and begin to collect changes up to iServerOutSynchMaxBuffers entries.
	 *
	 * @param iServerOutSynchMaxBuffers
	 *          max number of entries to collect before to remove it completely from the server node list
	 */
	public void setAsTemporaryDisconnected(final int iServerOutSynchMaxBuffers) {
		if (status != STATUS.UNREACHABLE) {
			status = STATUS.UNREACHABLE;
		}
	}

	public void startSynchronization() {
		channel.acquireExclusiveLock();
		try {
			if (status != STATUS.CONNECTED) {
				// SEND THE LAST CONFIGURATION TO THE NODE
				// sendConfiguration(iDatabaseName);

				synchronizeDelta();

				status = STATUS.CONNECTED;
			}

		} catch (Exception e) {
			e.printStackTrace();

		} finally {
			channel.releaseExclusiveLock();
		}
	}

	public void shareDatabase(final ODatabaseRecord<?> iDatabase, final String iRemoteServerName, final String iDbUser,
			final String iDbPasswd, final String iEngineName, final boolean iSynchronousMode) throws IOException {
		if (status != STATUS.CONNECTED)
			throw new ODistributedSynchronizationException("Can't share database '" + iDatabase.getName() + "' on remote server node '"
					+ iRemoteServerName + "' because is disconnected");

		final String dbName = iDatabase.getName();

		channel.acquireExclusiveLock();

		try {
			status = STATUS.SYNCHRONIZING;

			OLogManager.instance().info(this, "Sharing database '" + dbName + "' to remote server " + iRemoteServerName + "...");

			// EXECUTE THE REQUEST ON THE REMOTE SERVER NODE
			channel.writeByte(OChannelDistributedProtocol.REQUEST_DISTRIBUTED_DB_SHARE_RECEIVER);
			channel.writeInt(0);
			channel.writeString(dbName);
			channel.writeString(iDbUser);
			channel.writeString(iDbPasswd);
			channel.writeString(iEngineName);

			OLogManager.instance().info(this, "Exporting database '%s' via streaming to remote server node: %s...", iDatabase.getName(),
					iRemoteServerName);

			// START THE EXPORT GIVING AS OUTPUTSTREAM THE CHANNEL TO STREAM THE EXPORT
			new ODatabaseExport(iDatabase, new OChannelBinaryOutputStream(channel), this).exportDatabase();

			OLogManager.instance().info(this, "Database exported correctly");

			try {
				clientTxId = channel.beginResponse(0);
				dbVersion = channel.readLong();
			} finally {
				channel.endResponse();
			}

		} finally {
			channel.releaseExclusiveLock();
		}

		status = STATUS.CONNECTED;

		database = dbName;
		manager.setClusterDbSecurity(dbName, iDbUser, iDbPasswd);
	}

	public void onMessage(String iText) {
	}

	@Override
	public String toString() {
		return id;
	}

	public STATUS getStatus() {
		return status;
	}

	private void synchronizeDelta() throws IOException {
		synchronized (bufferedChanges) {
			if (bufferedChanges.isEmpty())
				return;

			OLogManager.instance().info(this, "Started realignment of remote node '%s' after a reconnection. Found %d updates", id,
					bufferedChanges.size());

			status = STATUS.SYNCHRONIZING;

			final long time = System.currentTimeMillis();

			for (OTransactionEntry<ORecordInternal<?>> entry : bufferedChanges) {
				sendRequest(entry, SYNCH_TYPE.SYNCHRONOUS);
			}
			bufferedChanges.clear();

			OLogManager.instance()
					.info(this, "Realignment of remote node '%s' completed in %d ms", id, System.currentTimeMillis() - time);

			status = STATUS.CONNECTED;
		}
	}

	public void beginResponse() throws IOException {
		channel.beginResponse(clientTxId);
	}

	public void endResponse() {
		channel.endResponse();
	}
}


text:
var qs = require('querystring')
var vtgeojson = require('../')

// parse query string
var query = qs.parse(window.location.search.substring(1))
var token = query.access_token
var mapid = query.mapid
var tile = query.tile.split('/').map(Number)
var layers = query.layers

// grab vector tiles and make 'em into geojson
var featurecollection = { type: 'FeatureCollection', features: [] }
var tiles = 'tilejson+http://api.mapbox.com/v4/' + mapid + '.json?access_token=' + token
vtgeojson(tiles, {
  tiles: [tile],
  layers: layers ? layers.split(',') : undefined
})
.on('data', function (data) {
  featurecollection.features.push(data)
})
.on('end', function () {
  document.write('<pre>' + JSON.stringify(featurecollection, null, 2) + '</pre>')
})


text:
using System.Collections.Generic;
using UnityEngine;
using Physics = UnityEngine.Physics;

namespace Oxide.Plugins
{
    [Info("ExternalWallProtect", "redBDGR", "1.0.1", ResourceId = 2576)]
    [Description("Prevent ladders from being able to be placed on external walls")]

    class ExternalWallProtect : RustPlugin
    {
        private const string permissionName = "externalwallprotect.exempt";

        private void Init()
        {
            permission.RegisterPermission(permissionName, this);
            lang.RegisterMessages(new Dictionary<string, string>
            {
                //chat
                ["Deny Crusher"] = "You are not allowed to place a ladder there",
            }, this);
        }

        private object CanBuild(Planner plan, Construction prefab)
        {
            if (prefab.prefabID != 2205372577) return null;
            RaycastHit hit;
            BasePlayer player = plan.GetOwnerPlayer();
            if (permission.UserHasPermission(player.UserIDString, permissionName)) return null;
            if (!Physics.Raycast(player.eyes.HeadRay(), out hit, 5f)) return null;
            BaseEntity ent = hit.GetEntity();
            if (!ent) return null;
            if (!ent.ShortPrefabName.Contains("external")) return null;
            player.ChatMessage(msg("Deny Crusher", player.UserIDString));
            return false;
        }

        private string msg(string key, string id = null) => lang.GetMessage(key, this, id);
    }
}


text:
package com.nowellpoint.client.model;

public abstract class AbstractAuthenticatedRequest {
	public abstract Token getToken();
}