Esempio n. 1
0
void PagePopupClient::addProperty(const char* name, unsigned value, SharedBuffer* data)
{
    data->append(name, strlen(name));
    addLiteral(": ", data);
    addString(String::number(value), data);
    addLiteral(",\n", data);
}
Esempio n. 2
0
void PagePopupClient::addJavaScriptString(const String& str, SharedBuffer* data)
{
    addLiteral("\"", data);
    StringBuilder builder;
    builder.reserveCapacity(str.length());
    for (unsigned i = 0; i < str.length(); ++i) {
        if (str[i] == '\r') {
            builder.append("\\r");
        } else if (str[i] == '\n') {
            builder.append("\\n");
        } else if (str[i] == '\\' || str[i] == '"') {
            builder.append('\\');
            builder.append(str[i]);
        } else if (str[i] == '<') {
            // Need to avoid to add "</script>" because the resultant string is
            // typically embedded in <script>.
            builder.append("\\x3C");
        } else if (str[i] < 0x20 || str[i] == lineSeparator || str[i] == paragraphSeparator) {
            builder.append(String::format("\\u%04X", str[i]));
        } else {
            builder.append(str[i]);
        }
    }
    addString(builder.toString(), data);
    addLiteral("\"", data);
}
Esempio n. 3
0
void PagePopupClient::addProperty(const char* name, const String& value, SharedBuffer* data)
{
    data->append(name, strlen(name));
    addLiteral(": ", data);
    addJavaScriptString(value, data);
    addLiteral(",\n", data);
}
Esempio n. 4
0
void PagePopupClient::addProperty(const char* name, bool value, SharedBuffer* data)
{
    data->append(name, strlen(name));
    addLiteral(": ", data);
    if (value)
        addLiteral("true", data);
    else
        addLiteral("false", data);
    addLiteral(",\n", data);
}
Esempio n. 5
0
void PagePopupClient::addProperty(const char* name, const IntRect& rect, SharedBuffer* data)
{
    data->append(name, strlen(name));
    addLiteral(": {", data);
    addProperty("x", rect.x(), data);
    addProperty("y", rect.y(), data);
    addProperty("width", rect.width(), data);
    addProperty("height", rect.height(), data);
    addLiteral("},\n", data);
}
Esempio n. 6
0
void PagePopupClient::addProperty(const char* name, const Vector<String>& values, SharedBuffer* data)
{
    data->append(name, strlen(name));
    addLiteral(": [", data);
    for (unsigned i = 0; i < values.size(); ++i) {
        if (i)
            addLiteral(",", data);
        addJavaScriptString(values[i], data);
    }
    addLiteral("],\n", data);
}
Esempio n. 7
0
void PagePopupClient::addJavaScriptString(const String& str, SharedBuffer* data)
{
    addLiteral("\"", data);
    StringBuilder builder;
    builder.reserveCapacity(str.length());
    for (unsigned i = 0; i < str.length(); ++i) {
        if (str[i] == '\\' || str[i] == '"')
            builder.append('\\');
        builder.append(str[i]);
    }
    addString(builder.toString(), data);
    addLiteral("\"", data);
}
Esempio n. 8
0
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRL(RDF_Query q, RDF_Variable arg1, RDF_Resource s, RDF_Term arg2, RDF_ValueType type, uint8 count) {
	RDF_Literal literal = (RDF_Literal)getMem(sizeof(LiteralStruc));
	if (literal == NULL) return RDF_NO_MEMORY;
	literal->u.value = (void*)arg1;
	literal->u.type = RDF_VARIABLE_TERM_TYPE;
	((RDF_Variable)literal->u.value)->type = type;
	literal->s = s;
	literal->valueCount = count;
	literal->v = (void*)arg2;
	/* value and type of each term already assigned */
	literal->valueType = type;
	literal->tv = true;
	addLiteral(q, literal);	
	q->conjunctsOrdered = false;		
	return noRDFErr;
}
Esempio n. 9
0
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctRRV(RDF_Query q, RDF_Resource arg1, RDF_Resource s, RDF_Variable arg2, RDF_ValueType type) {
	RDF_Literal literal = (RDF_Literal)getMem(sizeof(LiteralStruc));
	if (literal == NULL) return RDF_NO_MEMORY;
	literal->u.value = arg1;
	literal->u.type = RDF_RESOURCE_TERM_TYPE;
	literal->s = s;
	literal->valueCount = 1;
	literal->v = (TermStruc*)getMem(sizeof(TermStruc));
	literal->v->value = (void*)arg2;
	literal->v->type = RDF_VARIABLE_TERM_TYPE;
	((RDF_Variable)literal->v->value)->type = literal->valueType = type;
	literal->tv = true;
	addLiteral(q, literal);	
	q->conjunctsOrdered = false;
	return noRDFErr;
}
Esempio n. 10
0
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctRRO(RDF_Query q, RDF_Resource arg1, RDF_Resource s, void* arg2, RDF_ValueType type) {
	RDF_Literal literal = (RDF_Literal)getMem(sizeof(LiteralStruc));
	if (literal == NULL) return RDF_NO_MEMORY;
	literal->u.value = (void*)arg1;
	literal->u.type = RDF_RESOURCE_TERM_TYPE;
	literal->s = s;
	literal->valueCount = 1;
	literal->v = (TermStruc*)getMem(sizeof(TermStruc));
	literal->v->value = (type == RDF_STRING_TYPE) ? (void*)copyString((char*)arg2) : (void*)arg2;
	literal->v->type = RDF_CONSTANT_TERM_TYPE;
	literal->valueType = type;
	literal->tv = true;
	addLiteral(q, literal);	
	q->conjunctsOrdered = false;		
	return noRDFErr;
}
Esempio n. 11
0
AffixPattern &
AffixPattern::append(const AffixPattern &other) {
    AffixPatternIterator iter;
    other.iterator(iter);
    UnicodeString literal;
    while (iter.nextToken()) {
        switch (iter.getTokenType()) {
        case kLiteral:
            iter.getLiteral(literal);
            addLiteral(literal.getBuffer(), 0, literal.length());
            break;
        case kCurrency:
            addCurrency(iter.getTokenLength());
            break;
        default:
            add(iter.getTokenType());
            break;
        }
    }
    return *this;
}
Esempio n. 12
0
/*
 * Function Called to Begin Running Dynamic compiled code.
 */
code_seg_t* Generate_CodeStart(code_segment_data_t* seg_data)
{
	code_seg_t* 	code_seg 		= newSegment();
	Instruction_t* 	newInstruction;
	Instruction_t* 	ins 			= NULL;

	seg_data->dbgCurrentSegment = code_seg;

	code_seg->Type = SEG_START;

	newInstruction 		= newInstrPUSH(AL, REG_HOST_STM_EABI2 );
	code_seg->Intermcode = ins = newInstruction;

	regID_t base;
	int32_t offset;

#if defined(TEST_BRANCHING_FORWARD)
	newInstruction 		= newInstrI(ARM_MOV, AL, REG_HOST_R0, REG_NOT_USED, REG_NOT_USED, 0);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_B, AL, REG_NOT_USED, REG_NOT_USED, REG_NOT_USED, 3);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x1);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x2);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x4);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x8);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x10);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x20);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x40);
	ADD_LL_NEXT(newInstruction, ins);

	// return back to debugger
	newInstruction 		= newInstr(ARM_MOV, AL, REG_HOST_PC, REG_NOT_USED, REG_HOST_LR);
	ADD_LL_NEXT(newInstruction, ins);

#elif defined(TEST_BRANCHING_BACKWARD)

// Jump forwards to the Landing Pad
	newInstruction 		= newInstrI(ARM_MOV, AL, REG_HOST_R0, REG_NOT_USED, REG_NOT_USED, 0);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_B, AL, REG_NOT_USED, REG_NOT_USED, REG_NOT_USED, 10);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x1);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x2);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x4);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x8);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x10);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x20);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0x40);
	ADD_LL_NEXT(newInstruction, ins);

// return back to debugger
	newInstruction 		= newInstr(ARM_MOV, AL, REG_HOST_PC, REG_NOT_USED, REG_HOST_LR);
	ADD_LL_NEXT(newInstruction, ins);

// Landing pad
	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrI(ARM_ADD, AL, REG_HOST_R0, REG_HOST_R0, REG_NOT_USED,0);
	ADD_LL_NEXT(newInstruction, ins);

// Now jump backwards
	newInstruction 		= newInstrI(ARM_B, AL, REG_NOT_USED, REG_NOT_USED, REG_NOT_USED, -10);
	ADD_LL_NEXT(newInstruction, ins);

#elif defined(TEST_BRANCH_TO_C)

	newInstruction 		= newInstrI(ARM_MOV, AL, REG_HOST_R0, REG_NOT_USED, REG_NOT_USED, 0);
	ADD_LL_NEXT(newInstruction, ins);

	addLiteral(code_seg, &base, &offset,(uint32_t)&test_callCode);
	assert(base == REG_HOST_PC);

	newInstruction 		= newInstrI(ARM_LDR_LIT, AL, REG_HOST_R1, REG_NOT_USED, base, offset);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstr(ARM_MOV, AL, REG_HOST_LR, REG_NOT_USED, REG_HOST_PC);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstr(ARM_MOV, AL, REG_HOST_PC, REG_NOT_USED, REG_HOST_R1);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstrPOP(AL, REG_HOST_STM_EABI2 );
	ADD_LL_NEXT(newInstruction, ins);

	// Return back to Debugger
	newInstruction 		= newInstr(ARM_MOV, AL, REG_HOST_PC, REG_NOT_USED, REG_HOST_LR);
	ADD_LL_NEXT(newInstruction, ins);

#elif defined(TEST_LITERAL)	// Test Literal loading

	addLiteral(code_seg, &base, &offset,(uint32_t)MMAP_FP_BASE);
	assert(base == REG_HOST_PC);

	newInstruction 		= newInstrI(ARM_LDR_LIT, AL, REG_HOST_R0, REG_NOT_USED, base, offset);
	ADD_LL_NEXT(newInstruction, ins);

	// return back to debugger
	newInstruction 		= newInstr(ARM_MOV, AL, REG_HOST_PC, REG_NOT_USED, REG_HOST_LR);
	ADD_LL_NEXT(newInstruction, ins);

#elif defined(TEST_ROR)

	newInstruction 		= newInstrI(ARM_MOV, AL, REG_HOST_R0, REG_NOT_USED, REG_NOT_USED, 0x00138000);
	ADD_LL_NEXT(newInstruction, ins);

	newInstruction 		= newInstr(ARM_MOV, AL, REG_HOST_PC, REG_NOT_USED, REG_HOST_LR);
	ADD_LL_NEXT(newInstruction, ins);

#else
	addLiteral(code_seg, &base, &offset,(uint32_t)MMAP_FP_BASE);
	assert(base == REG_HOST_PC);

	// setup the HOST_FP
	newInstruction 		= newInstrI(ARM_LDR_LIT, AL, REG_EMU_FP, REG_NOT_USED, base, offset);
	ADD_LL_NEXT(newInstruction, ins);

	// start executing recompiled code
	newInstruction 		= newInstrI(ARM_LDR, AL, REG_HOST_PC, REG_NOT_USED, REG_EMU_FP, RECOMPILED_CODE_START);
	ADD_LL_NEXT(newInstruction, ins);
#endif

	Translate_Registers(code_seg);
	Translate_Literals(code_seg);

	return code_seg;
}
Esempio n. 13
0
void Translate_Debug(code_seg_t* codeSegment)
{
	Instruction_t*ins;
	Instruction_t*new_ins;
	ins = codeSegment->Intermcode;

#if USE_BREAKPOINTS || USE_TRANSLATE_DEBUG_SET_CURRENT_SEG
#if USE_INSTRUCTION_COMMENTS
	currentTranslation = "Debug - Get CodeSegment";
#endif
	regID_t base;
	int32_t offset;

	//TODO Nasty global segmentData!

	//load current segment Address
	addLiteral(codeSegment, &base, &offset, (uint32_t)codeSegment);
	codeSegment->Intermcode = new_ins = newInstrI(ARM_LDR_LIT, AL, REG_TEMP_SCRATCH0, REG_NOT_USED, base, offset);
	new_ins->nextInstruction = ins;
	ins = new_ins;
#endif

#if USE_BREAKPOINTS
#if USE_INSTRUCTION_COMMENTS
	currentTranslation = "Debug - Service Breakpoints";
#endif
	new_ins = newInstrPUSH(AL, REG_HOST_STM_ALL);
	ADD_LL_NEXT(new_ins, ins);

	new_ins = newInstr(ARM_MOV, AL, REG_HOST_R1, REG_NOT_USED, REG_HOST_SP);
	ADD_LL_NEXT(new_ins, ins);

	ins = insertCall_To_C(codeSegment, ins, AL,(uint32_t)ServiceBreakPoint, 0);

	new_ins = newInstrPOP(AL, REG_HOST_STM_ALL);
	ADD_LL_NEXT(new_ins, ins);
#endif

#if USE_INSTRUCTION_COMMENTS
	currentTranslation = "Debug - Load Segment ID";
#endif

#if USE_TRANSLATE_DEBUG_SET_CURRENT_SEG

	//load segmentData->dbgCurrentSegment address
	addLiteral(codeSegment, &base, &offset, (uint32_t)&segmentData.dbgCurrentSegment);
	new_ins 		= newInstrI(ARM_LDR_LIT, AL, REG_TEMP_SCRATCH1, REG_NOT_USED, base, offset);
	ADD_LL_NEXT(new_ins, ins);

#if USE_INSTRUCTION_COMMENTS
	currentTranslation = "Debug - Store Segment ID";
#endif
#endif

	//store
	new_ins 		= newInstrI(ARM_STR, AL, REG_NOT_USED, REG_TEMP_SCRATCH0, REG_TEMP_SCRATCH1, 0);
	ADD_LL_NEXT(new_ins, ins);

#if USE_TRANSLATE_DEBUG_PRINT_SEGMENT
#if USE_INSTRUCTION_COMMENTS
	currentTranslation = "Call DebugRuntimePrintSegment()";
#endif
	ins = insertCall_To_C(codeSegment, ins, AL,(uint32_t)DebugRuntimePrintSegment, 0);
#endif

#if USE_TRANSLATE_DEBUG_PRINT_REGISTERS_ON_ENTRY
#if USE_INSTRUCTION_COMMENTS
	currentTranslation = "Call DebugRuntimePrintMIPS()";
#endif
	{
		static code_seg_t* lastSeg = NULL;

		if (lastSeg != codeSegment)
		{
			ins = insertCall_To_C(codeSegment, ins, AL,(uint32_t)DebugRuntimePrintMIPS, 0);
			lastSeg = codeSegment;
		}
	}
#endif

#if USE_INSTRUCTION_COMMENTS
	currentTranslation = "Debug - Instruction count";
#endif

#if USE_TRANSLATE_DEBUG_LINE_NUMBERS
	int x=0;
	while (ins->nextInstruction->nextInstruction)
	{
		new_ins = newInstrI(ARM_MOV, AL, REG_EMU_DEBUG1, REG_NOT_USED, REG_NOT_USED, x);
		ADD_LL_NEXT(new_ins, ins);

		x++;
		ins = ins->nextInstruction;
	}
#endif
}