当前位置: 首页>>代码示例>>C++>>正文


C++ ErrorList::empty方法代码示例

本文整理汇总了C++中ErrorList::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ErrorList::empty方法的具体用法?C++ ErrorList::empty怎么用?C++ ErrorList::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ErrorList的用法示例。


在下文中一共展示了ErrorList::empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: compile


//.........这里部分代码省略.........
	catch (Error const& error)
	{
		errors.append(formatError(error, error.typeName(), scannerFromSourceName));
	}
	catch (CompilerError const& exception)
	{
		errors.append(formatError(exception, "Compiler error", scannerFromSourceName));
	}
	catch (InternalCompilerError const& exception)
	{
		errors.append(formatError(exception, "Internal compiler error", scannerFromSourceName));
	}
	catch (Exception const& exception)
	{
		errors.append("Exception during compilation: " + boost::diagnostic_information(exception));
	}
	catch (...)
	{
		errors.append("Unknown exception during compilation.");
	}

	if (errors.size() > 0)
		output["errors"] = errors;

	if (success)
	{
		try
		{
			output["contracts"] = Json::Value(Json::objectValue);
			for (string const& contractName: compiler.contractNames())
			{
				Json::Value contractData(Json::objectValue);
				contractData["interface"] = compiler.interface(contractName);
				contractData["bytecode"] = compiler.object(contractName).toHex();
				contractData["runtimeBytecode"] = compiler.runtimeObject(contractName).toHex();
				contractData["opcodes"] = solidity::disassemble(compiler.object(contractName).bytecode);
				contractData["functionHashes"] = functionHashes(compiler.contractDefinition(contractName));
				contractData["gasEstimates"] = estimateGas(compiler, contractName);
				auto sourceMap = compiler.sourceMapping(contractName);
				contractData["srcmap"] = sourceMap ? *sourceMap : "";
				auto runtimeSourceMap = compiler.runtimeSourceMapping(contractName);
				contractData["srcmapRuntime"] = runtimeSourceMap ? *runtimeSourceMap : "";
				ostringstream unused;
				contractData["assembly"] = compiler.streamAssembly(unused, contractName, _sources, true);
				output["contracts"][contractName] = contractData;
			}
		}
		catch (...)
		{
			output["errors"].append("Unknown exception while generating contract data output.");
		}

		try
		{
			// Do not taint the internal error list
			ErrorList formalErrors;
			if (compiler.prepareFormalAnalysis(&formalErrors))
				output["formal"]["why3"] = compiler.formalTranslation();
			if (!formalErrors.empty())
			{
				Json::Value errors(Json::arrayValue);
				for (auto const& error: formalErrors)
					errors.append(formatError(
						*error,
						(error->type() == Error::Type::Warning) ? "Warning" : "Error",
						scannerFromSourceName
					));
				output["formal"]["errors"] = errors;
			}
		}
		catch (...)
		{
			output["errors"].append("Unknown exception while generating formal method output.");
		}

		try
		{
			// Indices into this array are used to abbreviate source names in source locations.
			output["sourceList"] = Json::Value(Json::arrayValue);
			for (auto const& source: compiler.sourceNames())
				output["sourceList"].append(source);
			output["sources"] = Json::Value(Json::objectValue);
			for (auto const& source: compiler.sourceNames())
				output["sources"][source]["AST"] = ASTJsonConverter(compiler.ast(source), compiler.sourceIndices()).json();
		}
		catch (...)
		{
			output["errors"].append("Unknown exception while generating source name output.");
		}
	}

	try
	{
		return Json::FastWriter().write(output);
	}
	catch (...)
	{
		return "{\"errors\":[\"Unknown error while generating JSON.\"]}";
	}
}
开发者ID:M0rrisChang,项目名称:Smart-Contract,代码行数:101,代码来源:jsonCompiler.cpp


注:本文中的ErrorList::empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。