Esempio n. 1
0
css_error css__cascade_color(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	bool inherit = isInherit(opv);
	uint16_t value = CSS_COLOR_INHERIT;
	css_color color = 0;

	if (inherit == false) {
		switch (getValue(opv)) {
		case COLOR_TRANSPARENT:
			value = CSS_COLOR_COLOR;
			break;
		case COLOR_CURRENT_COLOR:
			/* color: currentColor always computes to inherit */
			value = CSS_COLOR_INHERIT;
			inherit = true;
			break;
		case COLOR_SET:
			value = CSS_COLOR_COLOR;
			color = *((css_color *) style->bytecode);
			advance_bytecode(style, sizeof(color));
			break;
		}
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, 
			inherit)) {
		return set_color(state->computed, value, color);
	}

	return CSS_OK;
}
/* Print the instructions to be performed to the output file */
void printInstructions(FILE *ofp, instruction* instructions)
{
    int currLine = 0;
    char* codeString = malloc(MAX_CODE_LENGTH);

    sprintf(codeString, "%s", "Line\tOP\tL\tM\n");

    bool halt = false;
    while(halt == false)
    {
        // Check for halt instruction (SIO 0, 3), if found break out of the loop
        if(instructions[currLine].OP == 11 && instructions[currLine].M == 3)
            halt = true;

        sprintf(codeString + strlen(codeString), "%d\t%s\t%d\t%d\n",
                currLine,
                getOpcode(instructions[currLine].OP),
                instructions[currLine].L,
                instructions[currLine].M)
            ;
        currLine++;
    }

    fprintf(ofp, "%s", codeString);
}
Esempio n. 3
0
css_error css__cascade_pitch(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	css_fixed freq = 0;
	uint32_t unit = UNIT_HZ;

	if (isInherit(opv) == false) {
		switch (getValue(opv)) {
		case PITCH_FREQUENCY:
			freq = *((css_fixed *) style->bytecode);
			advance_bytecode(style, sizeof(freq));
			unit = *((uint32_t *) style->bytecode);
			advance_bytecode(style, sizeof(unit));
			break;
		case PITCH_X_LOW:
		case PITCH_LOW:
		case PITCH_MEDIUM:
		case PITCH_HIGH:
		case PITCH_X_HIGH:
			/** \todo convert to public values */
			break;
		}
	}

	unit = css__to_css_unit(unit);

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		/** \todo pitch */
	}

	return CSS_OK;
}
Esempio n. 4
0
css_error css__cascade_visibility(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	uint16_t value = CSS_VISIBILITY_INHERIT;

	UNUSED(style);

	if (isInherit(opv) == false) {
		switch (getValue(opv)) {
		case VISIBILITY_VISIBLE:
			value = CSS_VISIBILITY_VISIBLE;
			break;
		case VISIBILITY_HIDDEN:
			value = CSS_VISIBILITY_HIDDEN;
			break;
		case VISIBILITY_COLLAPSE:
			value = CSS_VISIBILITY_COLLAPSE;
			break;
		}
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		return set_visibility(state->computed, value);
	}

	return CSS_OK;
}
css_error css__cascade_background_attachment(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	uint16_t value = CSS_BACKGROUND_ATTACHMENT_INHERIT;

	UNUSED(style);

	if (isInherit(opv) == false) {
		switch (getValue(opv)) {
		case BACKGROUND_ATTACHMENT_FIXED:
			value = CSS_BACKGROUND_ATTACHMENT_FIXED;
			break;
		case BACKGROUND_ATTACHMENT_SCROLL:
			value = CSS_BACKGROUND_ATTACHMENT_SCROLL;
			break;
		}
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		return set_background_attachment(state->computed, value);
	}

	return CSS_OK;
}
Esempio n. 6
0
void interpOne(IRGS& env,
               folly::Optional<Type> outType,
               int popped,
               int pushed,
               InterpOneData& idata) {
  auto const unit = curUnit(env);
  spillStack(env);
  env.irb->exceptionStackBoundary();
  auto const op = unit->getOpcode(bcOff(env));

  auto& iInfo = getInstrInfo(op);
  if (iInfo.type == jit::InstrFlags::OutFDesc) {
    env.fpiStack.push(FPIInfo { sp(env), env.irb->spOffset(), nullptr });
  } else if (isFCallStar(op) && !env.fpiStack.empty()) {
    env.fpiStack.pop();
  }

  idata.bcOff = bcOff(env);
  idata.cellsPopped = popped;
  idata.cellsPushed = pushed;
  idata.opcode = op;

  gen(
    env,
    opcodeChangesPC(idata.opcode) ? InterpOneCF : InterpOne,
    outType,
    idata,
    sp(env),
    fp(env)
  );
  assertx(env.irb->stackDeficit() == 0);
}
Esempio n. 7
0
css_error css__cascade_text_transform(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	uint16_t value = CSS_TEXT_TRANSFORM_INHERIT;
	
	UNUSED(style);

	if (isInherit(opv) == false) {
		switch (getValue(opv)) {
		case TEXT_TRANSFORM_CAPITALIZE:
			value = CSS_TEXT_TRANSFORM_CAPITALIZE;
			break;
		case TEXT_TRANSFORM_UPPERCASE:
			value = CSS_TEXT_TRANSFORM_UPPERCASE;
			break;
		case TEXT_TRANSFORM_LOWERCASE:
			value = CSS_TEXT_TRANSFORM_LOWERCASE;
			break;
		case TEXT_TRANSFORM_NONE:
			value = CSS_TEXT_TRANSFORM_NONE;
			break;
		}
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		return set_text_transform(state->computed, value);
	}

	return CSS_OK;
}
Esempio n. 8
0
css_error css__cascade_table_layout(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	uint16_t value = CSS_TABLE_LAYOUT_INHERIT;

	UNUSED(style);

	if (isInherit(opv) == false) {
		switch (getValue(opv)) {
		case TABLE_LAYOUT_AUTO:
			value = CSS_TABLE_LAYOUT_AUTO;
			break;
		case TABLE_LAYOUT_FIXED:
			value = CSS_TABLE_LAYOUT_FIXED;
			break;
		}
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		return set_table_layout(state->computed, value);
	}

	return CSS_OK;
}
Esempio n. 9
0
void SoftwareBreakpointManager::enableLocation(Site const &site) {
  std::string opcode;
  std::string old;
  ErrorCode error;

  getOpcode(site.size, opcode);
  old.resize(opcode.size());
  error = _process->readMemory(site.address, &old[0], old.size());
  if (error != kSuccess) {
    DS2LOG(Error, "cannot enable breakpoint at %#lx",
           (unsigned long)site.address.value());
    return;
  }

  error = _process->writeMemory(site.address, &opcode[0], opcode.size());
  if (error != kSuccess) {
    DS2LOG(Error, "cannot enable breakpoint at %#lx",
           (unsigned long)site.address.value());
    return;
  }

  DS2LOG(Info, "set breakpoint instruction %#lx at %#lx (saved insn %#lx)",
         (unsigned long)(site.size == 2 ? *(uint16_t *)&opcode[0]
                                        : *(uint32_t *)&opcode[0]),
         (unsigned long)site.address.value(),
         (unsigned long)(site.size == 2 ? *(uint16_t *)&old[0]
                                        : *(uint32_t *)&old[0]));

  _insns[site.address] = old;
}
Esempio n. 10
0
css_error css__cascade_border_spacing(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	uint16_t value = CSS_BORDER_SPACING_INHERIT;
	css_fixed hlength = 0;
	css_fixed vlength = 0;
	uint32_t hunit = UNIT_PX;
	uint32_t vunit = UNIT_PX;

	if (isInherit(opv) == false) {
		value = CSS_BORDER_SPACING_SET;
		hlength = *((css_fixed *) style->bytecode);
		advance_bytecode(style, sizeof(hlength));
		hunit = *((uint32_t *) style->bytecode);
		advance_bytecode(style, sizeof(hunit));

		vlength = *((css_fixed *) style->bytecode);
		advance_bytecode(style, sizeof(vlength));
		vunit = *((uint32_t *) style->bytecode);
		advance_bytecode(style, sizeof(vunit));
	}

	hunit = css__to_css_unit(hunit);
	vunit = css__to_css_unit(vunit);

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		return set_border_spacing(state->computed, value,
				hlength, hunit, vlength, vunit);
	}

	return CSS_OK;
}
Esempio n. 11
0
css_error css__cascade_writing_mode(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	bool inherit = isInherit(opv);
	uint16_t writing_mode = CSS_WRITING_MODE_INHERIT;
	UNUSED(style);

	if (inherit == false) {
		switch (getValue(opv)) {
		case WRITING_MODE_HORIZONTAL_TB:
			writing_mode = CSS_WRITING_MODE_HORIZONTAL_TB;
			break;
		case WRITING_MODE_VERTICAL_RL:
			writing_mode = CSS_WRITING_MODE_VERTICAL_RL;
			break;
		case WRITING_MODE_VERTICAL_LR:
			writing_mode = CSS_WRITING_MODE_VERTICAL_LR;
			break;
		}
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, 
			inherit)) {
		return set_writing_mode(state->computed, writing_mode);
	}

	return CSS_OK;
}
Esempio n. 12
0
//@cindex processUnexpectedMessage
void
processUnexpectedMessage(rtsPacket packet) {
    OpCode opCode = getOpcode(packet);

    IF_PAR_DEBUG(verbose,
		 GlobalTaskId sender = senderTask(packet); 
		 fprintf(stderr,"~~ [%x] processUnexpected: Received %x (%s), sender %x\n",
		       mytid, opCode, getOpName(opCode), sender)); 

    switch (opCode) {
    case PP_FINISH:
        stg_exit(EXIT_SUCCESS);
	break;

      /* Anything we're not prepared to deal with.  Note that ALL OpCodes
	 are discarded during termination -- this helps prevent bizarre
	 race conditions.  */
      default:
	// if (!GlobalStopPending) 
        {
	  GlobalTaskId errorTask;
	  OpCode opCode;

	  getOpcodeAndSender(packet, &opCode, &errorTask);
	  fprintf(stderr,"== Task %x: Unexpected OpCode %x from %x in processUnexpected",
		mytid, opCode, errorTask );
            
	  stg_exit(EXIT_FAILURE);
	}
    }
}
Esempio n. 13
0
bool ParseFunctionCall(FunctionEvent *FnEvent, CallExpr *Call,
                       vector<ValueDecl*>& References,
                       ASTContext& Ctx) {
#ifndef NDEBUG
  auto Predicate = Call->getDirectCallee();
  assert(Predicate != NULL);
  assert(Predicate->getName() == "__tesla_call");
#endif

  if (Call->getNumArgs() != 1) {
    Report("TESLA predicate should have one (boolean) argument",
        Call->getLocStart(), Ctx)
      << Call->getSourceRange();
    return false;
  }

  auto Bop = dyn_cast<BinaryOperator>(Call->getArg(0)->IgnoreImplicit());
  if (!Bop || (Bop->getOpcode() != BO_EQ)) {
    Report("A TESLA predicate should be of the form foo(x) == y",
        Call->getLocStart(), Ctx)
      << Call->getSourceRange();
    return false;
  }

  return ParseFunctionCall(FnEvent, Bop, References, Ctx);
}
Esempio n. 14
0
css_error css__cascade_overflow_y(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	uint16_t value = CSS_OVERFLOW_INHERIT;

	UNUSED(style);

	if (isInherit(opv) == false) {
		switch (getValue(opv)) {
		case OVERFLOW_VISIBLE:
			value = CSS_OVERFLOW_VISIBLE;
			break;
		case OVERFLOW_HIDDEN:
			value = CSS_OVERFLOW_HIDDEN;
			break;
		case OVERFLOW_SCROLL:
			value = CSS_OVERFLOW_SCROLL;
			break;
		case OVERFLOW_AUTO:
			value = CSS_OVERFLOW_AUTO;
			break;
		}
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		return set_overflow_y(state->computed, value);
	}

	return CSS_OK;
}
Esempio n. 15
0
css_error css__cascade_column_rule_style(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	UNUSED(style);

	if (isInherit(opv) == false) {
		switch (getValue(opv)) {
		case COLUMN_RULE_STYLE_NONE:
		case COLUMN_RULE_STYLE_HIDDEN:
		case COLUMN_RULE_STYLE_DOTTED:
		case COLUMN_RULE_STYLE_DASHED:
		case COLUMN_RULE_STYLE_SOLID:
		case COLUMN_RULE_STYLE_DOUBLE:
		case COLUMN_RULE_STYLE_GROOVE:
		case COLUMN_RULE_STYLE_RIDGE:
		case COLUMN_RULE_STYLE_INSET:
		case COLUMN_RULE_STYLE_OUTSET:
			/** \todo convert to public values */
			break;
		}
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		/** \todo set computed elevation */
	}

	return CSS_OK;
}
Esempio n. 16
0
// Uses value in IR to determine course of action
// Returns false if errors
bool interpreter() {
  bool success = true;
  //While no error flag and no timer interrupt
  while (success && timer_interrupt < QUANTUM) {
    machine.IR = main_memory[MMU(machine.PC)];
    machine.PC++; // Increment Program Counter
    unsigned short int op = getOpcode(machine.IR);
    switch (op) {
      case 0:  success = LOD(); break;
      case 1:  success = STO(); break;
      case 2:  success = ADD(); break;
      case 3:  success = SUB(); break;
      case 4:  success = ADR(); break;
      case 5:  success = SUR(); break;
      case 6:  success = AND(); break;
      case 7:  success = IOR(); break;
      case 8:  success = NOT(); break;
      case 9:  success = JMP(); break;
      case 10: success = JEQ(); break;
      case 11: success = JGT(); break;
      case 12: success = JLT(); break;
      case 13: success = CMP(); break;
      case 14: success = CLR(); break;
      case 15:    return HLT(); break; //Quit early on HLT
      default: success = false; break;
    }
    usleep(1000000); // Sleep 1 second to allow easier instruction tracing
    (*sysclock)++;
    timer_interrupt++;
  }
  timer_interrupt = 0;
  return success;
}
Esempio n. 17
0
css_error css__cascade_caption_side(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	uint16_t value = CSS_CAPTION_SIDE_INHERIT;

	UNUSED(style);

	if (isInherit(opv) == false) {
		switch (getValue(opv)) {
		case CAPTION_SIDE_TOP:
			value = CSS_CAPTION_SIDE_TOP;
			break;
		case CAPTION_SIDE_BOTTOM:
			value = CSS_CAPTION_SIDE_BOTTOM;
			break;
		}
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		return set_caption_side(state->computed, value);
	}

	return CSS_OK;
}
Esempio n. 18
0
int currentOpcode(struct pbrain_pcb *pcb)
{
    int base = pcbBaseAddress(pcb);
    char temp[6];
    memcpy(temp, pcb->memory[0][base + pcb->PC], 6);

    return getOpcode(temp);
}
Esempio n. 19
0
char* AlivePacket::toData() {
    char* data = new char[getSize()];

    int* opcode = (int*) data;
    *opcode = htonl(getOpcode());

    return data;
}
Esempio n. 20
0
/// Replace pseudo store instructions that pass arguments through the stack with
/// real instructions. If insertPushes is true then all instructions are
/// replaced with push instructions, otherwise regular std instructions are
/// inserted.
static void fixStackStores(MachineBasicBlock &MBB,
                           MachineBasicBlock::iterator MI,
                           const TargetInstrInfo &TII, bool insertPushes) {
  const AVRSubtarget &STI = MBB.getParent()->getSubtarget<AVRSubtarget>();
  const TargetRegisterInfo &TRI = *STI.getRegisterInfo();

  // Iterate through the BB until we hit a call instruction or we reach the end.
  for (auto I = MI, E = MBB.end(); I != E && !I->isCall();) {
    MachineBasicBlock::iterator NextMI = std::next(I);
    MachineInstr &MI = *I;
    unsigned Opcode = I->getOpcode();

    // Only care of pseudo store instructions where SP is the base pointer.
    if (Opcode != AVR::STDSPQRr && Opcode != AVR::STDWSPQRr) {
      I = NextMI;
      continue;
    }

    assert(MI.getOperand(0).getReg() == AVR::SP &&
           "Invalid register, should be SP!");
    if (insertPushes) {
      // Replace this instruction with a push.
      unsigned SrcReg = MI.getOperand(2).getReg();
      bool SrcIsKill = MI.getOperand(2).isKill();

      // We can't use PUSHWRr here because when expanded the order of the new
      // instructions are reversed from what we need. Perform the expansion now.
      if (Opcode == AVR::STDWSPQRr) {
        BuildMI(MBB, I, MI.getDebugLoc(), TII.get(AVR::PUSHRr))
            .addReg(TRI.getSubReg(SrcReg, AVR::sub_hi),
                    getKillRegState(SrcIsKill));
        BuildMI(MBB, I, MI.getDebugLoc(), TII.get(AVR::PUSHRr))
            .addReg(TRI.getSubReg(SrcReg, AVR::sub_lo),
                    getKillRegState(SrcIsKill));
      } else {
        BuildMI(MBB, I, MI.getDebugLoc(), TII.get(AVR::PUSHRr))
            .addReg(SrcReg, getKillRegState(SrcIsKill));
      }

      MI.eraseFromParent();
      I = NextMI;
      continue;
    }

    // Replace this instruction with a regular store. Use Y as the base
    // pointer since it is guaranteed to contain a copy of SP.
    unsigned STOpc =
        (Opcode == AVR::STDWSPQRr) ? AVR::STDWPtrQRr : AVR::STDPtrQRr;

    MI.setDesc(TII.get(STOpc));
    MI.getOperand(0).setReg(AVR::R29R28);

    I = NextMI;
  }
}
Esempio n. 21
0
void				Client::processPacketReception()
{
  std::vector<char>		*data = getMsg(0);
  ServerOpcodes		        opcode = getOpcode(data);

  data->erase(data->begin(), data->begin() + sizeof(ServerOpcodes));
  for (int i = 0; i < NB_OPCODES; i++)
    if (protocols[i].opcode == opcode)
      (this->*(protocols[i]).protocolFunction)(data);
  delete (data);
}
/* Print the stacktrace to the outputfile */
void printStacktrace(FILE *ofp, int prevPC, instruction *IR, int PC, int BP, int SP, int *stack)
{
    int i;
    char *stacktraceLine = malloc(MAX_CODE_LENGTH);

    sprintf(stacktraceLine + strlen(stacktraceLine), "%d\t%s\t%d\t%d\t%d\t%d\t%d\t",
            prevPC, getOpcode(IR->OP), IR->L, IR->M, PC, BP, SP);

    for(i = 1; i <= SP; i++)
    {
        if(i == BP && BP != 1)
            sprintf(stacktraceLine + strlen(stacktraceLine), "| ");

        sprintf(stacktraceLine + strlen(stacktraceLine), "%d ", stack[i]);
    }

    sprintf(stacktraceLine + strlen(stacktraceLine), "\n");

    fprintf(ofp, "%s", stacktraceLine);
}
Esempio n. 23
0
css_error css__cascade_opacity(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	uint16_t value = CSS_OPACITY_INHERIT;
	css_fixed opacity = 0;

	if (isInherit(opv) == false) {
		value = CSS_Z_INDEX_SET;

		opacity = *((css_fixed *) style->bytecode);
		advance_bytecode(style, sizeof(opacity));
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		return set_opacity(state->computed, value, opacity);
	}

	return CSS_OK;
}
Esempio n. 24
0
// If main trace starts with guards, have them generate a patchable jump
// to the anchor trace
static void hoistGuardJumps(Trace* trace, IRFactory* irFactory) {
  Block* guardLabel = nullptr;
  // Check the beginning of the trace for guards
  for (Block* block : trace->getBlocks()) {
    for (IRInstruction& instr : *block) {
      IRInstruction* inst = &instr;
      Opcode opc = inst->getOpcode();
      if (inst->getTaken() &&
          (opc == LdLoc    || opc == LdStack ||
           opc == GuardLoc || opc == GuardStk)) {
        Block* exitLabel = inst->getTaken();
        // Find the GuardFailure's label and confirm this branches there
        if (!guardLabel && exitLabel->getTrace() != trace) {
          auto instIter = exitLabel->skipLabel();
          // Confirm this is a GuardExit
          for (auto it = instIter, end = exitLabel->end(); it != end; ++it) {
            Opcode op = it->getOpcode();
            if (op == Marker) {
              continue;
            }
            if (op == ExitGuardFailure) {
              guardLabel = exitLabel;
            }
            // Do not optimize if other instructions are on exit trace
            break;
          }
        }
        if (exitLabel == guardLabel) {
          inst->setTCA(kIRDirectGuardActive);
          continue;
        }
        return; // terminate search
      }
      if (opc == Marker || opc == DefLabel || opc == DefSP || opc == DefFP ||
          opc == LdStack) {
        continue;
      }
      return; // terminate search
    }
  }
}
Esempio n. 25
0
css_error css__cascade_azimuth(uint32_t opv, css_style *style,
		 css_select_state *state)
{
	css_fixed val = 0;
	uint32_t unit = UNIT_DEG;

	if (isInherit(opv) == false) {
		switch (getValue(opv) & ~AZIMUTH_BEHIND) {
		case AZIMUTH_ANGLE:
			val = *((css_fixed *) style->bytecode);
			advance_bytecode(style, sizeof(val));
			unit = *((uint32_t *) style->bytecode);
			advance_bytecode(style, sizeof(unit));
			break;
		case AZIMUTH_LEFTWARDS:
		case AZIMUTH_RIGHTWARDS:
		case AZIMUTH_LEFT_SIDE:
		case AZIMUTH_FAR_LEFT:
		case AZIMUTH_LEFT:
		case AZIMUTH_CENTER_LEFT:
		case AZIMUTH_CENTER:
		case AZIMUTH_CENTER_RIGHT:
		case AZIMUTH_RIGHT:
		case AZIMUTH_FAR_RIGHT:
		case AZIMUTH_RIGHT_SIDE:
			/** \todo azimuth values */
			break;
		}

		/** \todo azimuth behind */
	}

	unit = css__to_css_unit(unit);

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, 
			isInherit(opv))) {
		/** \todo set computed azimuth */
	}

	return CSS_OK;
}
Esempio n. 26
0
css_error css__cascade_text_align(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	uint16_t value = CSS_TEXT_ALIGN_INHERIT;

	UNUSED(style);

	if (isInherit(opv) == false) {
		switch (getValue(opv)) {
		case TEXT_ALIGN_LEFT:
			value = CSS_TEXT_ALIGN_LEFT;
			break;
		case TEXT_ALIGN_RIGHT:
			value = CSS_TEXT_ALIGN_RIGHT;
			break;
		case TEXT_ALIGN_CENTER:
			value = CSS_TEXT_ALIGN_CENTER;
			break;
		case TEXT_ALIGN_JUSTIFY:
			value = CSS_TEXT_ALIGN_JUSTIFY;
			break;
		case TEXT_ALIGN_LIBCSS_LEFT:
			value = CSS_TEXT_ALIGN_LIBCSS_LEFT;
			break;
		case TEXT_ALIGN_LIBCSS_CENTER:
			value = CSS_TEXT_ALIGN_LIBCSS_CENTER;
			break;
		case TEXT_ALIGN_LIBCSS_RIGHT:
			value = CSS_TEXT_ALIGN_LIBCSS_RIGHT;
			break;
		}
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		return set_text_align(state->computed, value);
	}

	return CSS_OK;
}
Esempio n. 27
0
int checkIfInstructionIsValid(struct Processor *processor) {
  uint32_t instruction = getInstructionAtPC(processor);
  uint8_t opcode = getOpcode(instruction);
  if (opcode<0 || opcode>NUMBER_OF_INSTRUCTIONS) {
    printf("The opcode for the current instruction is invalid. This would cause SEGMENTATION FAULT\n");
    programExitValue =1;
    return 0;    
  };
  switch (opcode)  {
    case HALT : return 1;
    case ADD  : return checkRtypeInstructionIsValid(instruction)!=0;
    case ADDI :return checkItypeInstructionIsValid(instruction)!=0;
    case SUB  : return checkRtypeInstructionIsValid(instruction)!=0;
    case SUBI : return checkItypeInstructionIsValid(instruction)!=0;
    case MUL  : return checkRtypeInstructionIsValid(instruction)!=0;
    case MULI : return checkItypeInstructionIsValid(instruction)!=0;
    case LW   : return checkIfLoadAndStoreAreValid(instruction)!=0; 
    case SW   : return checkIfLoadAndStoreAreValid(instruction)!=0;
    case BEQ  : return checkBrachInstructionIsValid(instruction,processor)!=0;
    case BNE  : return checkBrachInstructionIsValid(instruction,processor)!=0; 
    case BLT  : return checkBrachInstructionIsValid(instruction,processor)!=0;
    case BGT  : return checkBrachInstructionIsValid(instruction,processor)!=0;
    case BLE  : return checkBrachInstructionIsValid(instruction,processor)!=0;
    case BGE  : return checkBrachInstructionIsValid(instruction,processor)!=0;
    case JMP  : return checkJtypeIsValid(instruction)!=0;
    case JR   : return checkRtypeInstructionIsValid(instruction)!=0;
    case JAL  : return checkJtypeIsValid(instruction)!=0;
    case OUT  : return checkRtypeInstructionIsValid(instruction)!=0;
    case DIV  : return checkRtypeInstructionIsValid(instruction)!=0;
    case DIVI : return checkItypeInstructionIsValid(instruction)!=0;
    case MOD  : return checkRtypeInstructionIsValid(instruction)!=0;
    case MODI : return checkItypeInstructionIsValid(instruction)!=0;
    case FACT : return checkRtypeInstructionIsValid(instruction)!=0;
    case FACTI: return checkItypeInstructionIsValid(instruction)!=0;
    case SWAP : return checkRtypeInstructionIsValid(instruction)!=0;
    default   : return 0;
  }
}
Esempio n. 28
0
css_error css__cascade_volume(uint32_t opv, css_style *style,
                              css_select_state *state)
{
    css_fixed val = 0;
    uint32_t unit = UNIT_PCT;

    if (isInherit(opv) == false) {
        switch (getValue(opv)) {
        case VOLUME_NUMBER:
            val = *((css_fixed *) style->bytecode);
            advance_bytecode(style, sizeof(val));
            break;
        case VOLUME_DIMENSION:
            val = *((css_fixed *) style->bytecode);
            advance_bytecode(style, sizeof(val));
            unit = *((uint32_t *) style->bytecode);
            advance_bytecode(style, sizeof(unit));
            break;
        case VOLUME_SILENT:
        case VOLUME_X_SOFT:
        case VOLUME_SOFT:
        case VOLUME_MEDIUM:
        case VOLUME_LOUD:
        case VOLUME_X_LOUD:
            /** \todo convert to public values */
            break;
        }
    }

    unit = css__to_css_unit(unit);

    if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
                               isInherit(opv))) {
        /** \todo volume */
    }

    return CSS_OK;
}
Esempio n. 29
0
/* Direct addressing is allowed, provided the value in the memory location
is actually only using 8 bits. If the 8 highest-order bits contain anything,
that would be a reference to a memory location that does not exist (PC: 8bits)
and thus the JMP would return an error (essentially OutOfBounds) */
bool JMP() {
  unsigned short int addr = getAddrMode(machine.IR);
  unsigned short int jmpTo;
  if (addr == DIRECT) {
    jmpTo = main_memory[MMU(getOperand(machine.IR))];
    // Check high-order bits
    if ((jmpTo & 65280) != 0)
    return false;
  } else if (addr == IMMEDIATE) {
    jmpTo = getOperand(machine.IR);
  } else {
    return false;
  }

  // Set program counter to new address
  machine.PC = jmpTo;

  #ifdef DEBUG
  if (getOpcode(machine.IR) == 9)
  printDebug("JMP");
  #endif
  return true;
}
Esempio n. 30
0
/*
 * parseInstr will analyze the opcode and pass instruction
 * to next level to parse and action.
 * It will parse the instruction first and then execute it.
 */
instruction parseInstr(WORD_32bit instr) {
    instruction tmpInstr;
    switch(getOpcode(instr)) {
        case op_funct:
            tmpInstr = parseOpRType(instr);
            break;
        case op_addi:
        case op_lw:
        case op_lh:
        case op_lhu:
        case op_lb:
        case op_lbu:
        case op_sw:
        case op_sh:
        case op_sb:
        case op_lui:
        case op_andi:
        case op_ori:
        case op_nori:
        case op_slti:
        case op_beq:
        case op_bne:
            tmpInstr = parseOpIType(instr);
            break;
        case op_j:
        case op_jal:
            tmpInstr = parseOpJType(instr);
            break;
        case op_halt:
            tmpInstr = parseOpSType(instr);
            break;
        default:
            break;
    }
    return tmpInstr;
}