Ejemplo n.º 1
0
void Relay::switchOnFor(unsigned long const delay) {
#ifdef DEBUG
	Serial.print("Switch on for ");
	Serial.println(delay);
#endif
	switch_(true);
	m_timeOfNextSwitch = m_timeOfLastSwitchOn + delay;
}
Ejemplo n.º 2
0
/* Returns index if a sentence matches, 0 otherwise */
int contents(int index)
{
  if(index = ifladder(index))
    {
      index = contents(index);
    }
  else if(index= switch_(index))
    {
      index = contents(index);
    }
  /*
  else if(index = termloop(index))
    {
      index = contents(index);
    }
  */
  return index;
 }
Ejemplo n.º 3
0
Relay::Relay(int const relayId) :
		m_relayId(relayId) {
	m_timeOfNextSwitch = 0;
	pinMode(m_relayId, OUTPUT);
	switch_(false);
}
Ejemplo n.º 4
0
void Relay::cancel() {
	switch_(false);
}
Ejemplo n.º 5
0
void Relay::update() {
	if (m_timeOfNextSwitch > 0 && millis() > m_timeOfNextSwitch) {
		switch_(false);
	}
}
 std::string operator()(Int&& value)const{
         return apply_visitor(detail::eval_(),switch_(),std::forward<Int>(value));
 }
Ejemplo n.º 7
0
CompileOutput *Compiler::Compile(AMXRef amx) {
  Prepare(amx);

  Disassembler disasm(amx);
  Instruction instr;
  bool error = false;

  while (!error && disasm.Decode(instr, error)) {
    if (!Process(instr)) {
      error = true;
      break;
    }

    switch (instr.opcode().GetId()) {
      case OP_LOAD_PRI:
        load_pri(instr.operand());
        break;
      case OP_LOAD_ALT:
        load_alt(instr.operand());
        break;
      case OP_LOAD_S_PRI:
        load_s_pri(instr.operand());
        break;
      case OP_LOAD_S_ALT:
        load_s_alt(instr.operand());
        break;
      case OP_LREF_PRI:
        lref_pri(instr.operand());
        break;
      case OP_LREF_ALT:
        lref_alt(instr.operand());
        break;
      case OP_LREF_S_PRI:
        lref_s_pri(instr.operand());
        break;
      case OP_LREF_S_ALT:
        lref_s_alt(instr.operand());
        break;
      case OP_LOAD_I:
        load_i();
        break;
      case OP_LODB_I:
        lodb_i(instr.operand());
        break;
      case OP_CONST_PRI:
        const_pri(instr.operand());
        break;
      case OP_CONST_ALT:
        const_alt(instr.operand());
        break;
      case OP_ADDR_PRI:
        addr_pri(instr.operand());
        break;
      case OP_ADDR_ALT:
        addr_alt(instr.operand());
        break;
      case OP_STOR_PRI:
        stor_pri(instr.operand());
        break;
      case OP_STOR_ALT:
        stor_alt(instr.operand());
        break;
      case OP_STOR_S_PRI:
        stor_s_pri(instr.operand());
        break;
      case OP_STOR_S_ALT:
        stor_s_alt(instr.operand());
        break;
      case OP_SREF_PRI:
        sref_pri(instr.operand());
        break;
      case OP_SREF_ALT:
        sref_alt(instr.operand());
        break;
      case OP_SREF_S_PRI:
        sref_s_pri(instr.operand());
        break;
      case OP_SREF_S_ALT:
        sref_s_alt(instr.operand());
        break;
      case OP_STOR_I:
        stor_i();
        break;
      case OP_STRB_I:
        strb_i(instr.operand());
        break;
      case OP_LIDX:
        lidx();
        break;
      case OP_LIDX_B:
        lidx_b(instr.operand());
        break;
      case OP_IDXADDR:
        idxaddr();
        break;
      case OP_IDXADDR_B:
        idxaddr_b(instr.operand());
        break;
      case OP_ALIGN_PRI:
        align_pri(instr.operand());
        break;
      case OP_ALIGN_ALT:
        align_alt(instr.operand());
        break;
      case OP_LCTRL:
        lctrl(instr.operand(), instr.address() + instr.size());
        break;
      case OP_SCTRL:
        sctrl(instr.operand());
        break;
      case OP_MOVE_PRI:
        move_pri();
        break;
      case OP_MOVE_ALT:
        move_alt();
        break;
      case OP_XCHG:
        xchg();
        break;
      case OP_PUSH_PRI:
        push_pri();
        break;
      case OP_PUSH_ALT:
        push_alt();
        break;
      case OP_PUSH_C:
        push_c(instr.operand());
        break;
      case OP_PUSH:
        push(instr.operand());
        break;
      case OP_PUSH_S:
        push_s(instr.operand());
        break;
      case OP_POP_PRI:
        pop_pri();
        break;
      case OP_POP_ALT:
        pop_alt();
        break;
      case OP_STACK: // value
        stack(instr.operand());
        break;
      case OP_HEAP:
        heap(instr.operand());
        break;
      case OP_PROC:
        proc();
        break;
      case OP_RET:
        ret();
        break;
      case OP_RETN:
        retn();
        break;
      case OP_JUMP_PRI:
        jump_pri();
        break;
      case OP_CALL:
      case OP_JUMP:
      case OP_JZER:
      case OP_JNZ:
      case OP_JEQ:
      case OP_JNEQ:
      case OP_JLESS:
      case OP_JLEQ:
      case OP_JGRTR:
      case OP_JGEQ:
      case OP_JSLESS:
      case OP_JSLEQ:
      case OP_JSGRTR:
      case OP_JSGEQ: {
        cell dest = instr.operand() - reinterpret_cast<cell>(amx.code());
        switch (instr.opcode().GetId()) {
          case OP_CALL:
            call(dest);
            break;
          case OP_JUMP:
            jump(dest);
            break;
          case OP_JZER:
            jzer(dest);
            break;
          case OP_JNZ:
            jnz(dest);
            break;
          case OP_JEQ:
            jeq(dest);
            break;
          case OP_JNEQ:
            jneq(dest);
            break;
          case OP_JLESS:
            jless(dest);
            break;
          case OP_JLEQ:
            jleq(dest);
            break;
          case OP_JGRTR:
            jgrtr(dest);
            break;
          case OP_JGEQ:
            jgeq(dest);
            break;
          case OP_JSLESS:
            jsless(dest);
            break;
          case OP_JSLEQ:
            jsleq(dest);
            break;
          case OP_JSGRTR:
            jsgrtr(dest);
            break;
          case OP_JSGEQ:
            jsgeq(dest);
            break;
        }
        break;
      }
      case OP_SHL:
        shl();
        break;
      case OP_SHR:
        shr();
        break;
      case OP_SSHR:
        sshr();
        break;
      case OP_SHL_C_PRI:
        shl_c_pri(instr.operand());
        break;
      case OP_SHL_C_ALT:
        shl_c_alt(instr.operand());
        break;
      case OP_SHR_C_PRI:
        shr_c_pri(instr.operand());
        break;
      case OP_SHR_C_ALT:
        shr_c_alt(instr.operand());
        break;
      case OP_SMUL:
        smul();
        break;
      case OP_SDIV:
        sdiv();
        break;
      case OP_SDIV_ALT:
        sdiv_alt();
        break;
      case OP_UMUL:
        umul();
        break;
      case OP_UDIV:
        udiv();
        break;
      case OP_UDIV_ALT:
        udiv_alt();
        break;
      case OP_ADD:
        add();
        break;
      case OP_SUB:
        sub();
        break;
      case OP_SUB_ALT:
        sub_alt();
        break;
      case OP_AND:
        and_();
        break;
      case OP_OR:
        or_();
        break;
      case OP_XOR:
        xor_();
        break;
      case OP_NOT:
        not_();
        break;
      case OP_NEG:
        neg();
        break;
      case OP_INVERT:
        invert();
        break;
      case OP_ADD_C:
        add_c(instr.operand());
        break;
      case OP_SMUL_C:
        smul_c(instr.operand());
        break;
      case OP_ZERO_PRI:
        zero_pri();
        break;
      case OP_ZERO_ALT:
        zero_alt();
        break;
      case OP_ZERO:
        zero(instr.operand());
        break;
      case OP_ZERO_S:
        zero_s(instr.operand());
        break;
      case OP_SIGN_PRI:
        sign_pri();
        break;
      case OP_SIGN_ALT:
        sign_alt();
        break;
      case OP_EQ:
        eq();
        break;
      case OP_NEQ:
        neq();
        break;
      case OP_LESS:
        less();
        break;
      case OP_LEQ:
        leq();
        break;
      case OP_GRTR:
        grtr();
        break;
      case OP_GEQ:
        geq();
        break;
      case OP_SLESS:
        sless();
        break;
      case OP_SLEQ:
        sleq();
        break;
      case OP_SGRTR:
        sgrtr();
        break;
      case OP_SGEQ:
        sgeq();
        break;
      case OP_EQ_C_PRI:
        eq_c_pri(instr.operand());
        break;
      case OP_EQ_C_ALT:
        eq_c_alt(instr.operand());
        break;
      case OP_INC_PRI:
        inc_pri();
        break;
      case OP_INC_ALT:
        inc_alt();
        break;
      case OP_INC:
        inc(instr.operand());
        break;
      case OP_INC_S:
        inc_s(instr.operand());
        break;
      case OP_INC_I:
        inc_i();
        break;
      case OP_DEC_PRI:
        dec_pri();
        break;
      case OP_DEC_ALT:
        dec_alt();
        break;
      case OP_DEC:
        dec(instr.operand());
        break;
      case OP_DEC_S:
        dec_s(instr.operand());
        break;
      case OP_DEC_I:
        dec_i();
        break;
      case OP_MOVS:
        movs(instr.operand());
        break;
      case OP_CMPS:
        cmps(instr.operand());
        break;
      case OP_FILL:
        fill(instr.operand());
        break;
      case OP_HALT:
        halt(instr.operand());
        break;
      case OP_BOUNDS:
        bounds(instr.operand());
        break;
      case OP_SYSREQ_PRI:
        sysreq_pri();
        break;
      case OP_SYSREQ_C: {
        const char *name = amx.GetNativeName(instr.operand());
        if (name == 0) {
          error = true;
        } else {
          sysreq_c(instr.operand(), name);
        }
        break;
      }
      case OP_SYSREQ_D: {
        const char *name = amx.GetNativeName(amx.FindNative(instr.operand()));
        if (name == 0) {
          error = true;
        } else {
          sysreq_d(instr.operand(), name);
        }
        break;
      }
      case OP_SWITCH:
        switch_(CaseTable(amx, instr.operand()));
        break;
      case OP_CASETBL:
        casetbl();
        break;
      case OP_SWAP_PRI:
        swap_pri();
        break;
      case OP_SWAP_ALT:
        swap_alt();
        break;
      case OP_PUSH_ADR:
        push_adr(instr.operand());
        break;
      case OP_NOP:
        nop();
        break;
      case OP_BREAK:
        break_();
        break;
    default:
      error = true;
    }
  }

  if (error && error_handler_ != 0) {
    error_handler_->Execute(instr);
  }

  return Finish(error);
}
Ejemplo n.º 8
0
void SvgElementVisitor::visit(clan::DomElement &e)
{
	if (e.get_namespace_uri() != Svg::svg_ns) return;

	// To do: do a more efficient search for the correct handler

	auto local_name = e.get_local_name();
	if (local_name == "a") a(e);
	else if (local_name == "altGlyph") altGlyph(e);
	else if (local_name == "altGlyphDef") altGlyphDef(e);
	else if (local_name == "altGlyphItem") altGlyphItem(e);
	else if (local_name == "animate") animate(e);
	else if (local_name == "animateColor") animateColor(e);
	else if (local_name == "animateMotion") animateMotion(e);
	else if (local_name == "animateTransform") animateTransform(e);
	else if (local_name == "circle") circle(e);
	else if (local_name == "clipPath") clipPath(e);
	else if (local_name == "color-profile") color_profile(e);
	else if (local_name == "cursor") cursor(e);
	else if (local_name == "defs") defs(e);
	else if (local_name == "desc") desc(e);
	else if (local_name == "ellipse") ellipse(e);
	else if (local_name == "feBlend") feBlend(e);
	else if (local_name == "feColorMatrix") feColorMatrix(e);
	else if (local_name == "feComponentTransfer") feComponentTransfer(e);
	else if (local_name == "feComposite") feComposite(e);
	else if (local_name == "feConvolveMatrix") feConvolveMatrix(e);
	else if (local_name == "feDiffuseLighting") feDiffuseLighting(e);
	else if (local_name == "feDisplacementMap") feDisplacementMap(e);
	else if (local_name == "feDistantLight") feDistantLight(e);
	else if (local_name == "feFlood") feFlood(e);
	else if (local_name == "feFuncA") feFuncA(e);
	else if (local_name == "feFuncB") feFuncB(e);
	else if (local_name == "feFuncG") feFuncG(e);
	else if (local_name == "feFuncR") feFuncR(e);
	else if (local_name == "feGaussianBlur") feGaussianBlur(e);
	else if (local_name == "feImage") feImage(e);
	else if (local_name == "feMerge") feMerge(e);
	else if (local_name == "feMergeNode") feMergeNode(e);
	else if (local_name == "feMorphology") feMorphology(e);
	else if (local_name == "feOffset") feOffset(e);
	else if (local_name == "fePointLight") fePointLight(e);
	else if (local_name == "feSpecularLighting") feSpecularLighting(e);
	else if (local_name == "feSpotLight") feSpotLight(e);
	else if (local_name == "feTile") feTile(e);
	else if (local_name == "feTurbulence") feTurbulence(e);
	else if (local_name == "filter") filter(e);
	else if (local_name == "font") font(e);
	else if (local_name == "font-face") font_face(e);
	else if (local_name == "font-face-format") font_face_format(e);
	else if (local_name == "font-face-name") font_face_name(e);
	else if (local_name == "font-face-src") font_face_src(e);
	else if (local_name == "font-face-uri") font_face_uri(e);
	else if (local_name == "foreignObject") foreignObject(e);
	else if (local_name == "g") g(e);
	else if (local_name == "glyph") glyph(e);
	else if (local_name == "glyphRef") glyphRef(e);
	else if (local_name == "hkern") hkern(e);
	else if (local_name == "image") image(e);
	else if (local_name == "line") line(e);
	else if (local_name == "linearGradient") linearGradient(e);
	else if (local_name == "marker") marker(e);
	else if (local_name == "mask") mask(e);
	else if (local_name == "metadata") metadata(e);
	else if (local_name == "missing-glyph") missing_glyph(e);
	else if (local_name == "mpath") mpath(e);
	else if (local_name == "path") path(e);
	else if (local_name == "pattern") pattern(e);
	else if (local_name == "polygon") polygon(e);
	else if (local_name == "polyline") polyline(e);
	else if (local_name == "radialGradient") radialGradient(e);
	else if (local_name == "rect") rect(e);
	else if (local_name == "script") script(e);
	else if (local_name == "set") set(e);
	else if (local_name == "stop") stop(e);
	else if (local_name == "style") style(e);
	else if (local_name == "svg") svg(e);
	else if (local_name == "switch") switch_(e);
	else if (local_name == "symbol") symbol(e);
	else if (local_name == "text") text(e);
	else if (local_name == "textPath") textPath(e);
	else if (local_name == "title") title(e);
	else if (local_name == "tref") tref(e);
	else if (local_name == "tspan") tspan(e);
	else if (local_name == "use") use(e);
	else if (local_name == "view") view(e);
	else if (local_name == "vkern") vkern(e);
}