예제 #1
0
	void ClassCheck::doCheck(
			const StaticContextPtr& pRootCtx,
			const ASTNodePtr& pNode,
			const LogPtr& pLog) const
	{
		if (pNode->getASTNodeType() != ASTN_CLASS)
		{
			return;
		}

		ClassDefPtr pClassDef = boost::static_pointer_cast<ClassDef>(pNode);

		const list<const wstring>& ifaces = pClassDef->getImplementedInterfaces();
		
		list<const wstring>::const_iterator it;

		for (it = ifaces.begin(); it != ifaces.end(); it++)
		{
			const wstring& ifaceName = *it;

			CStaticContextEntryPtr pEntry;
			InterfaceDefPtr pInterfaceDef;

			if (!pRootCtx->lookup(ifaceName, pEntry))
			{
				boost::wformat f(L"Interface %1% not found.");
				f % ifaceName;
				pLog->log(*pClassDef, msg::ErrAnaClassDef_IfaceNotFound, f.str());
				continue;
			}
			else if (!pEntry->getInterface(pInterfaceDef))
			{
				boost::wformat f(L"%1% is not an interface.");
				f % ifaceName;
				pLog->log(*pClassDef, msg::ErrAnaClassDef_NotAnIface, f.str());
				continue;
			}

			checkInterfaceParams(pClassDef, pInterfaceDef, pRootCtx, pLog);
			checkInterfaceVars(pClassDef, pInterfaceDef, pRootCtx, pLog);
		}

		const list<VariableDeclDefPtr>& vars = pClassDef->getVariableDecls();

		list<VariableDeclDefPtr>::const_iterator vit;

		for (vit = vars.begin(); vit != vars.end(); vit++)
		{
			const VariableDeclDefPtr& pVar = *vit;

			if (pVar->getValue().get() == NULL)
			{
				boost::wformat f(L"Unassigned class variable %1%.");
				f % pVar->getName();
				pLog->log(*pClassDef, msg::ErrAnaClassDef_UnassignedClassVar, f.str());
				continue;
			}
		}
	}