Beispiel #1
0
void PropertyManager::setValue(QtProperty *prop, const QVariant &value)
{
	QtAbstractPropertyManager *mngr = prop->propertyManager();

	if (mngr == m_boolManager)
		setBoolValue(prop, value.toBool());
	else if (mngr == m_stringManager)
		setStringValue(prop, value.toString());
	else if (mngr == m_intManager)
		setIntValue(prop, value.toInt());
	else if (mngr == m_scriptManager)
		setScriptValue(prop, value.toString());
	else if (mngr == m_labelManager)
		setLabelValue(prop, value.toString());
}
Beispiel #2
0
void assembleFile(FILE *f_source, FILE *f_destination)
{
    tDatabase label_values;
    constructLabelValuesDatabase(&label_values);

    //the first file parsing
    tAddress current_address = 0;
    while (!feof(f_source))
    {
        tLine line = getLineFromFile(f_source);
        if (labelExistsInLine(line))
        {
            tLine label = getLabelFromLine(line);
            //FIXME: check that name of label doesn't coinside with processor register name
            setLabelValue(&label_values, label, current_address);
        }
        if (commandTextExistsInLine(line))
        {
            tLine command_text = getCommandTextFromLine(line);
            int command_size_in_bytes = calculateCommandSizeInBytes(command_text); //FIXME: implement it!
            current_address += command_size_in_bytes;
        }
    }
    //for debugging print labels with their values
    printLabelValues(label_values);

    //the second file parsing
    fseek(f_source, 0, SEEK_SET); //rewind to the start of file
    while (!feof(f_source))
    {
        tLine line = getLineFromFile(f_source);
        if (commandTextExistsInLine(line))
        {
            tLine command_text = getCommandTextFromLine(line);
            tCommandWithOperands command = parseCommandText(command_text, label_values);
            tCode code = makeCodeFromCommandWithOperands(command);
            writeCodeToBinaryFile(f_destination, code);
            free(code.words);
        }
    }
    printf("Successfully assembled file.\n");
    destructLabelValuesDatabase(&label_values); //FIXME: implement it!
}