Beispiel #1
0
//
//  MT_Bitset: C
//
REBOOL MT_Bitset(REBVAL *out, REBVAL *data, enum Reb_Kind type)
{
    REBOOL is_not = FALSE;

    if (IS_BLOCK(data)) {
        REBINT len = Find_Max_Bit(data);
        REBSER *ser;
        if (len < 0 || len > 0xFFFFFF) fail (Error_Invalid_Arg(data));
        ser = Make_Bitset(len);
        Set_Bits(ser, data, TRUE);
        Val_Init_Bitset(out, ser);
        return TRUE;
    }

    if (!IS_BINARY(data)) return FALSE;
    Val_Init_Bitset(out, Copy_Sequence_At_Position(data));
    BITS_NOT(VAL_SERIES(out)) = FALSE;
    return TRUE;
}
Beispiel #2
0
*/	REBFLG MT_Bitset(REBVAL *out, REBVAL *data, REBCNT type)
/*
***********************************************************************/
{
	REBFLG is_not = 0;

	if (IS_BLOCK(data)) {
		REBINT len = Find_Max_Bit(data);
		REBSER *ser;
		if (len < 0 || len > 0xFFFFFF) raise Error_Invalid_Arg(data);
		ser = Make_Bitset(len);
		Set_Bits(ser, data, TRUE);
		Val_Init_Bitset(out, ser);
		return TRUE;
	}

	if (!IS_BINARY(data)) return FALSE;
	Val_Init_Bitset(out, Copy_Sequence_At_Position(data));
	BITS_NOT(VAL_SERIES(out)) = 0;
	return TRUE;
}
Beispiel #3
0
/**
 * Receives information about the number of segments and the value
 *  which should be display on those.
 * @param size      number of segments (7-segment)
 * @param evaluate  Value that should be displayed as pointer on array
 */
void Evaluate_Display(unsigned char size, unsigned char *evaluate) {
    for(display_counter = size; display_counter > 0;
            display_counter--) {
        NOP();
        switch (evaluate[(display_counter - 1)]) {
            case '0':
                Set_Bits("ABCDEF");
                break;
            case '1':
                Set_Bits("BC");
                break;
            case '2':
                Set_Bits("ABDEG");
                break;
            case '3':
                Set_Bits("ABCDG");
                break;
            case '4':
                Set_Bits("BCFG");
                break;
            case '5':
                Set_Bits("ACDFG");
                break;
            case '6':
                Set_Bits("ACDEFG");
                break;
            case '7':
                Set_Bits("ABC");
                break;
            case '8':
                Set_Bits("ABCDEFG");
                break;
            case '9':
                Set_Bits("ABCDFG");
                break;
            case 'A':
                Set_Bits("ABCEFG");
                break;
            case 'D':
                Set_Bits("ABCDEF");
                break;
            case 'E':
                Set_Bits("ADEFG");
                break;
            case 'L':
                Set_Bits("DEF");
                break;
            case 'O':
                Set_Bits("ABCDEF");
                break;
            case 'P':
                Set_Bits("ABEFG");
                break;
            case '-':
                Set_Bits("G");
                break;
            case 'T':
                Set_Bits("BCDEF");
                break;
            default:
                Set_Bits("0");
        }
    }
}
Beispiel #4
0
*/	REBSER *Parse_String(REBSER *series, REBCNT index, REBVAL *rules, REBCNT flags)
/*
***********************************************************************/
{
	REBCNT tail = series->tail;
	REBSER *blk;
	REBSER *set;
	REBCNT begin;
	REBCNT end;
	REBOOL skip_spaces = !(flags & PF_ALL);
	REBUNI uc;

	blk = BUF_EMIT;	// shared series
	RESET_SERIES(blk);

	// String of delimiters or single character:
	if (IS_STRING(rules) || IS_CHAR(rules)) {
		begin = Find_Max_Bit(rules);
		if (begin <= ' ') begin = ' ' + 1;
		set = Make_Bitset(begin);
		Set_Bits(set, rules, TRUE);
	}
	// None, so use defaults ",;":
	else {
		set = Make_Bitset(1+MAX(',',';'));
		Set_Bit(set, ',', TRUE);
		Set_Bit(set, ';', TRUE);
	}
	SAVE_SERIES(set);

	// If required, make space delimiters too:
	if (skip_spaces) {
		for (uc = 1; uc <= ' '; uc++) Set_Bit(set, uc, TRUE);
	}

	while (index < tail) {

		if (--Eval_Count <= 0 || Eval_Signals) Do_Signals();

		// Skip whitespace if not /all refinement: 
		if (skip_spaces) {
			uc = 0;
			for (; index < tail; index++) {
				uc = GET_ANY_CHAR(series, index);
				if (!IS_WHITE(uc)) break;
			}
		}
		else
			uc = GET_ANY_CHAR(series, index); // prefetch

		if (index < tail) {

			// Handle quoted strings (in a simple way):
			if (uc == '"') {
				begin = ++index; // eat quote
				for (; index < tail; index++) {
					uc = GET_ANY_CHAR(series, index);
					if (uc == '"') break;
				}
				end = index;
				if (index < tail) index++;
			}
			// All other tokens:
			else {
				begin = index;
				for (; index < tail; index++) {
					if (Check_Bit(set, GET_ANY_CHAR(series, index), !(flags & PF_CASE))) break;
				}
				end = index;
			}

			// Skip trailing spaces:
			if (skip_spaces)
				for (; index < tail; index++) {
					uc = GET_ANY_CHAR(series, index);
					if (!IS_WHITE(uc)) break;
				}

			// Check for and remove separator:
			if (Check_Bit(set, GET_ANY_CHAR(series, index), !(flags & PF_CASE))) index++;

			// Append new string:
			Set_String(Append_Value(blk), Copy_String(series, begin, end - begin)); 
		}
	}
	UNSAVE_SERIES(set);

	return Copy_Block(blk, 0);
}