Exemplo n.º 1
0
void LoadAssemblyFile(const std::wstring& fileName, TextFile::Encoding encoding)
{
	tTextData Text;
	int num = 0;

	AddFileName((char*)convertWStringToUtf8(fileName).c_str());
	Global.IncludeNestingLevel++;

	if (Global.IncludeNestingLevel == ASSEMBLER_INCLUDE_NESTING_LEVEL)
	{
		Logger::printError(Logger::Error,L"Maximum include nesting level reached");
		return;
	}

	TextFile input;
	if (input.open(fileName,TextFile::Read,encoding) == false)
	{
		Logger::printError(Logger::Error,L"Could not open file");
		return;
	}

	while (!input.atEnd())
	{
		Global.FileInfo.LineNumber++;
		Global.FileInfo.TotalLineCount++;

		if (GetLine(input,Text.buffer) == false) continue;
		if (Text.buffer.size() == 0) continue;
		
		Text.buffer = Global.symbolTable.insertEquations(Text.buffer,Global.FileInfo.FileNum,Global.Section);

		if (CheckEquLabel(Text.buffer) == false)
		{
			Text.buffer = checkLabel(Text.buffer,false);
			splitLine(Text.buffer,Text.name,Text.params);
			if (Text.name.empty()) continue;

			if (ParseMacro(input,Text.name,Text.params) == true) continue;
			if (Arch->AssembleDirective(Text.name,Text.params) == false)
			{
				Arch->AssembleOpcode(Text.name,Text.params);
			}
		}

		if (Logger::hasFatalError())
			return;
	}
	
	Logger::printQueue();
	Global.IncludeNestingLevel--;
	input.close();
}
Exemplo n.º 2
0
void SynonymMap::save(const string& sFileName)
{
    TextFile tf;
    tf.open(sFileName.c_str(), "w");
    
    for(SynMap::const_iterator it = m_synMap.begin(); it != m_synMap.end();it++)
    {
        tf.write(it->first.c_str());
        Group* pGroup = it->second;
        tf.write(":");
        for(Group::const_iterator git = pGroup->begin(); git != pGroup->end(); git++)
        {
            tf.write((*git).c_str());
            if( (git + 1) != pGroup->end())
            {
                tf.write(",");
            }            
        }
        tf.write("\n");        
    }
    tf.close();    
}
Exemplo n.º 3
0
void ExtensionsWizard::OnWizardFinished(wxWizardEvent &e)
{
	String extensionName = conversions::to_utf16(m_pageGeneral->getExtensionName());
	String extensionDescription = conversions::to_utf16(m_pageGeneral->getExtensionDescription());
	String extensionAuthor = conversions::to_utf16(m_pageGeneral->getExtensionAuthor());
	shared_ptr<ExtensionsWizardPageTemplate::TemplateDetails> extensionTemplate = m_pageTemplate->getTemplate();
	const ExtensionsWizardPageTemplate::TemplateDetails::Files &extensionFiles = extensionTemplate->getFiles();

	ExtensionID extensionID = ExtensionID::generate();

	String rootPath = ExtensionsSystem::instance()->getDataPath();
	String extensionPath = utils::makeFolderPath(rootPath, extensionID.toUTF16());

	shared_ptr<XMLDocument> document(OS_NEW XMLDocument());
	shared_ptr<XMLNode> nodeRoot = document->create(OS_EXTENSION_XML_NODE_ROOT);
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_ID, extensionID.getString());
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_NAME, extensionName);
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_DESCRIPTION, extensionDescription);
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_AUTHOR, extensionAuthor);
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_VERSION_CODE, _S("1"));
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_VERSION_NAME, _S("0.1"));
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_ICON, _S("icon.png"));
	nodeRoot->setAttributeString(OS_EXTENSION_XML_NODE_ROOT_LOGO, _S("logo.png"));

	shared_ptr<XMLNode> nodeScripts;
	ExtensionsWizardPageTemplate::TemplateDetails::Files::const_iterator i;
	for(i = extensionFiles.begin(); i != extensionFiles.end(); ++i)
	{
		if((*i).script)
		{
			if(nodeScripts == nullptr)
				nodeScripts = nodeRoot->addChild(OS_EXTENSION_XML_NODE_SCRIPTS);

			shared_ptr<XMLNode> nodeScript = nodeScripts->addChild(OS_EXTENSION_XML_NODE_SCRIPT);
			nodeScript->setAttributeString(OS_EXTENSION_XML_NODE_SCRIPT_PATH, (*i).target);
			// TODO: temp
			nodeScript->setAttributeString(OS_EXTENSION_XML_NODE_SCRIPT_LANGUAGE, "python");
		}
	}

	String documentString;
	if(document->writeString(documentString) == false)
	{
		OS_ASSERTFALSE();
		Application::instance()->reportError("Internal error generating extension's xml, please report it", true);
		return;
	}

	if(XMLManager::instance()->validateString(documentString, XMLSchema::fromFile(utils::makeFilePath(utils::makeFolderPath(Options::instance()->getSharePath(), OS_SCHEMAS_PATH), OS_EXTENSIONS_EXTENSION_SCHEMA))) == false)
	{
		OS_ASSERTFALSE();
		Application::instance()->reportError("Internal error validating extension's xml, please report it", true);
		return;
	}

	if(FileSystem::instance()->ensureDirectory(extensionPath) == false)
	{
		Application::instance()->reportError("Cannot create directory '" + extensionPath + "'", true);
		return;
	}

	for(i = extensionFiles.begin(); i != extensionFiles.end(); ++i)
	{
		String targetFile = utils::makeFilePath(extensionPath, (*i).target);
		String sourceFile = utils::makeFilePath(extensionTemplate->getFolder(), (*i).source);

		String targetPath = FileSystem::instance()->getFilePath(targetFile);
		if(FileSystem::instance()->ensureDirectory(targetPath) == false)
		{
			Application::instance()->reportError("Cannot create directory '" + targetPath + "'", true);
			return;
		}

		if(FileSystem::instance()->copyFile(sourceFile, targetFile) == false)
		{
			Application::instance()->reportError("Cannot copy file '" + sourceFile + "' to '" + targetFile + "'", true);
			return;
		}

		if((*i).macro)
		{
			// Open file, do replaces and save.
			String data;
			TextFile::readFile(targetFile, data);

			data = data.replace_all("{extension_id}", extensionID.getString());
			data = data.replace_all("{extension_name}", extensionName);
			data = data.replace_all("{extension_description}", extensionDescription);
			data = data.replace_all("{extension_author}", extensionAuthor);
			UniqueID uniqueID = UniqueID::generate();
			data = data.replace_all("{unique_id}", uniqueID.getString());

			TextFile file;
			file.open(targetFile, TextFile::ofWrite);
			file.writeLine(data);
			file.close();
		}
	}

	String documentFile = utils::makeFilePath(extensionPath, OS_MANIFESTXML);
	if(document->writeFile(documentFile) == false)
	{
		Application::instance()->reportError("Error writing file '" + documentFile + "'", true);
		return;
	}

	OS_ASSERT(XMLManager::instance()->validateFile(documentFile, XMLSchema::fromFile(utils::makeFilePath(utils::makeFolderPath(Options::instance()->getSharePath(), OS_SCHEMAS_PATH), OS_EXTENSIONS_EXTENSION_SCHEMA))));

	if(m_pageFinish->getOpenFolder())
		Application::instance()->shell(extensionPath);

	Application::instance()->reloadExtensions();
}
Exemplo n.º 4
0
void SymbolData::writeNocashSym()
{
    if (nocashSymFileName.empty())
        return;

    std::vector<NocashSymEntry> entries;
    for (size_t k = 0; k < modules.size(); k++)
    {
        SymDataModule& module = modules[k];
        for (size_t i = 0; i < module.symbols.size(); i++)
        {
            SymDataSymbol& sym = module.symbols[i];

            NocashSymEntry entry;
            entry.address = sym.address;
            entry.text = sym.name;
            entries.push_back(entry);
        }

        for (size_t i = 0; i < module.data.size(); i++)
        {
            SymDataData& data = module.data[i];
            NocashSymEntry entry;
            entry.address = data.address;

            switch (data.type)
            {
            case Data8:
                entry.text = formatString(".byt:%04X",data.size);
                break;
            case Data16:
                entry.text = formatString(".wrd:%04X",data.size);
                break;
            case Data32:
                entry.text = formatString(".dbl:%04X",data.size);
                break;
            case DataAscii:
                entry.text = formatString(".asc:%04X",data.size);
                break;
            }

            entries.push_back(entry);
        }
    }

    std::sort(entries.begin(),entries.end());

    TextFile file;
    if (file.open(nocashSymFileName,TextFile::Write,TextFile::ASCII) == false)
    {
        Logger::printError(Logger::Error,L"Could not open sym file %s.",file.getFileName().c_str());
        return;
    }
    file.writeLine(L"00000000 0");

    for (size_t i = 0; i < entries.size(); i++)
    {
        file.writeFormat(L"%08X %S\n",entries[i].address,entries[i].text.c_str());
    }

    file.write("\x1A");
    file.close();
}