Beispiel #1
0
		const SEM::Type* getBuiltInType(Context& context, const String& typeName, SEM::TypeArray templateArgs) {
			const auto& scopeStack = context.scopeStack();
			const auto rootElement = scopeStack[0];
			assert(rootElement.isNamespace());
			
			const auto iterator = rootElement.nameSpace()->items().find(typeName);
			assert(iterator != rootElement.nameSpace()->items().end() && "Failed to find built-in type!");
			
			const auto& value = iterator->second;
			assert(value.isTypeInstance() || value.isAlias());
			
			SEM::ValueArray templateArgValues;
			templateArgValues.reserve(templateArgs.size());
			
			const auto& templateVariables = (value.isTypeInstance() ? value.typeInstance().templateVariables() : value.alias().templateVariables());
			
			for (size_t i = 0; i < templateArgs.size(); i++) {
				const auto& argVar = templateVariables[i];
				const auto& argType = templateArgs[i];
				templateArgValues.push_back(SEM::Value::TypeRef(argType, argVar->type()->createStaticRefType(argType)));
			}
			
			if (value.isTypeInstance()) {
				assert(templateArgs.size() == value.typeInstance().templateVariables().size());
				return SEM::Type::Object(&(value.typeInstance()), std::move(templateArgValues));
			} else {
				assert(templateArgs.size() == value.alias().templateVariables().size());
				return SEM::Type::Alias(value.alias(), std::move(templateArgValues));
			}
		}
Beispiel #2
0
		const AST::Namespace& GlobalStructure::nextNamespace() const {
			auto next = this;
			while (!next->isNamespace()) {
				next = &(next->parent());
			}
			return next->nameSpace();
		}
int main(int argc, char* argv[])
{
    Object* ns = 0;
    esInit(&ns);
    Iso9660FileSystem::initializeConstructor();
    Handle<es::Context> nameSpace(ns);

#ifdef __es__
    Handle<es::Stream> disk = nameSpace->lookup("device/ata/channel1/device0");
#else
    es::Stream* disk = new VDisk(static_cast<char*>("isotest.iso"));
#endif
    TEST(disk);
    long long diskSize;
    diskSize = disk->getSize();
    esReport("diskSize: %lld\n", diskSize);
    TEST(0 < diskSize);

    Handle<es::FileSystem> isoFileSystem;
    isoFileSystem = es::Iso9660FileSystem::createInstance();
    TEST(isoFileSystem);
    isoFileSystem->mount(disk);
    {
        Handle<es::Context> root;

        root = isoFileSystem->getRoot();
        TEST(root);
        test(root);
    }
    isoFileSystem->dismount();

    esReport("done.\n");
}
int main(void)
{
    Object* ns = 0;
    esInit(&ns);
    FatFileSystem::initializeConstructor();
    Handle<es::Context> nameSpace(ns);

#ifdef __es__
    Handle<es::Stream> disk = nameSpace->lookup("device/ata/channel0/device0");
#else
    Handle<es::Stream> disk = new VDisk(static_cast<char*>("fat32.img"));
#endif
    long long diskSize;
    diskSize = disk->getSize();
    esReport("diskSize: %lld\n", diskSize);

    Handle<es::FileSystem> fatFileSystem;
    long long freeSpace;
    long long totalSpace;

    fatFileSystem = es::FatFileSystem::createInstance();
    fatFileSystem->mount(disk);
    fatFileSystem->format();
    freeSpace = fatFileSystem->getFreeSpace();
    totalSpace = fatFileSystem->getTotalSpace();
    esReport("Free space %lld, Total space %lld\n", freeSpace, totalSpace);
    {
        Handle<es::Context> root;

        root = fatFileSystem->getRoot();
        long ret = TestFileSystem(root);
        TEST (ret == 0);
        freeSpace = fatFileSystem->getFreeSpace();
        totalSpace = fatFileSystem->getTotalSpace();
        esReport("Free space %lld, Total space %lld\n", freeSpace, totalSpace);
        esReport("\nChecking the file system...\n");
        TEST(fatFileSystem->checkDisk(false));
    }
    fatFileSystem->dismount();
    fatFileSystem = 0;

    fatFileSystem = es::FatFileSystem::createInstance();
    fatFileSystem->mount(disk);
    freeSpace = fatFileSystem->getFreeSpace();
    totalSpace = fatFileSystem->getTotalSpace();
    esReport("Free space %lld, Total space %lld\n", freeSpace, totalSpace);
    esReport("\nChecking the file system...\n");
    TEST(fatFileSystem->checkDisk(false));
    fatFileSystem->dismount();
    fatFileSystem = 0;

    esReport("done.\n\n");
}
Beispiel #5
0
		const SEM::Type* getBuiltInTypeWithValueArgs(Context& context, const String& typeName, SEM::ValueArray templateArgValues) {
			const auto& scopeStack = context.scopeStack();
			const auto rootElement = scopeStack[0];
			assert(rootElement.isNamespace());
			
			const auto iterator = rootElement.nameSpace()->items().find(typeName);
			if (iterator == rootElement.nameSpace()->items().end()) {
				throw std::runtime_error(makeString("Failed to find built-in type '%s'.", typeName.c_str()));
			}
			
			const auto& value = iterator->second;
			assert(value.isTypeInstance() || value.isAlias());
			
			if (value.isTypeInstance()) {
				assert(templateArgValues.size() == value.typeInstance().templateVariables().size());
				return SEM::Type::Object(&(value.typeInstance()), std::move(templateArgValues));
			} else {
				assert(templateArgValues.size() == value.alias().templateVariables().size());
				return SEM::Type::Alias(value.alias(), std::move(templateArgValues));
			}
		}
Beispiel #6
0
bool QQmlMetaType::namespaceContainsRegistrations(const QString &uri)
{
    QQmlMetaTypeData *data = metaTypeData();

    // Has any type previously been installed to this namespace?
    QHashedString nameSpace(uri);
    foreach (const QQmlType *type, data->types)
        if (type->module() == nameSpace)
            return true;

    return false;
}
Beispiel #7
0
		const GlobalStructure& GlobalStructure::parent() const {
			switch (kind()) {
				case ALIAS:
					return alias().parent();
				case NAMESPACE:
					return nameSpace().parent();
				case TYPEINSTANCE:
					return typeInstance().parent();
			}
			
			locic_unreachable("Unknown GlobalStructure kind.");
		}
int main(int argc, char* argv[])
{
    Object* ns = 0;
    esInit(&ns);
    Iso9660FileSystem::initializeConstructor();
    Handle<es::Context> nameSpace(ns);

#ifdef __es__
    Handle<es::Stream> disk = nameSpace->lookup("device/ata/channel1/device0");
#else
    es::Stream* disk = new VDisk(static_cast<char*>("isotest.iso"));
#endif
    TEST(disk);
    long long diskSize;
    diskSize = disk->getSize();
    esReport("diskSize: %lld\n", diskSize);
    TEST(0 < diskSize);

    Handle<es::FileSystem> isoFileSystem;
    isoFileSystem = es::Iso9660FileSystem::createInstance();
    TEST(isoFileSystem);
    isoFileSystem->mount(disk);
    {
        Handle<es::Context> root;

        root = isoFileSystem->getRoot();
        TEST(root);

        Handle<es::Binding> binding = root;
        TEST(binding);

        Handle<Object> interface = binding->getObject();
        TEST(interface);

        Handle<es::Context> object = interface;
        TEST(object);
        TEST(object == root);

        // setObject() must return an exception.
        try
        {
            binding->setObject(interface);
            TEST(false);
        }
        catch (Exception& error)
        {
        }
    }
    isoFileSystem->dismount();

    esReport("done.\n");
}
Beispiel #9
0
bool Function::isVirtual() const
{
	if (_flags & FN_VIRTUAL)
	{
		return true;
	}
	else if (isDestructor())
	{
		Struct* pClass = dynamic_cast<Struct*>(nameSpace());
		return pClass && pClass->hasVirtualDestructor();
	}
	else return getOverridden() != 0;
	return false;
}
void UNIX_ApplicationSystemDirectoryFixture::Run()
{
	CIMName className("UNIX_ApplicationSystemDirectory");
	CIMNamespaceName nameSpace("root/cimv2");
	UNIX_ApplicationSystemDirectory _p;
	UNIX_ApplicationSystemDirectoryProvider _provider;
	Uint32 propertyCount;
	CIMOMHandle omHandle;
	_provider.initialize(omHandle);
	_p.initialize();

	for(int pIndex = 0; _p.load(pIndex); pIndex++)
	{
		CIMInstance instance = _provider.constructInstance(className,
					nameSpace,
					_p);
		CIMObjectPath path = instance.getPath();
		cout << path.toString() << endl;
		propertyCount = instance.getPropertyCount();
		for(Uint32 i = 0; i < propertyCount; i++)
		{

			CIMProperty propertyItem = instance.getProperty(i);
			if (propertyItem.getType() == CIMTYPE_REFERENCE) {
				CIMValue subValue = propertyItem.getValue();
				CIMInstance subInstance;
				subValue.get(subInstance);
				CIMObjectPath subPath = subInstance.getPath();
				cout << "	Name: " << propertyItem.getName().getString() << ": " << subPath.toString() << endl;
				Uint32 subPropertyCount = subInstance.getPropertyCount();
				for(Uint32 j = 0; j < subPropertyCount; j++)
				{
					CIMProperty subPropertyItem = subInstance.getProperty(j);
					cout << "		Name: " << subPropertyItem.getName().getString() << " - Value: " << subPropertyItem.getValue().toString() << endl;
				}
			}
			else {
				cout << "	Name: " << propertyItem.getName().getString() << " - Value: " << propertyItem.getValue().toString() << endl;
			}

		}
		cout << "------------------------------------" << endl;
		cout << endl;
	}

	_p.finalize();
	
}
Beispiel #11
0
Function* Function::getOverridden() const
{
	if (isMethod() && !(_flags & FN_STATIC))
	{
		Struct* pClass = dynamic_cast<Struct*>(nameSpace());
		if (pClass)
		{
			for (Struct::BaseIterator it = pClass->baseBegin(); it != pClass->baseEnd(); ++it)
			{
				if (it->pClass)
				{
					Function* pOverridden = it->pClass->findFunction(signature());
					if (pOverridden && pOverridden->isVirtual())
						return pOverridden;
				}
			}
		}
	}
	return 0;
}
int main(int argc, char* argv[])
{
    Object* ns = 0;
    esInit(&ns);

    Handle<es::Context> nameSpace(ns);

    Handle<es::Context> classStore(nameSpace->lookup("class"));

    Handle<es::Stream> disk = nameSpace->lookup("device/ata/channel0/device0");
    long long diskSize;
    diskSize = disk->getSize();
    esReport("diskSize: %lld\n", diskSize);

    Handle<es::FileSystem> fatFileSystem;
    long long freeSpace;
    long long totalSpace;

    fatFileSystem = es::FatFileSystem::createInstance();
    fatFileSystem->mount(disk);
    {
        Handle<es::Context> root;

        root = fatFileSystem->getRoot();
        nameSpace->bind("file", root);
        test(nameSpace);

        freeSpace = fatFileSystem->getFreeSpace();
        totalSpace = fatFileSystem->getTotalSpace();
        esReport("Free space %lld, Total space %lld\n", freeSpace, totalSpace);

        nameSpace->unbind("file");
    }
    fatFileSystem->dismount();
    fatFileSystem = 0;

    esSleep(10000000);
    esReport("done.\n");
}
Beispiel #13
0
int CXslTransform::setExternalFunction(const char* pszNameSpace, IXslFunction* pXslFunction, bool set)
{
    CXslFunction* pFn = (CXslFunction*) pXslFunction;

    if (pFn == NULL || pFn->get() == NULL)
        throw MakeStringException(-1, "Null pointer violation in CXslTransform::setExternalFunction.");

    XalanDOMString nameSpace(pszNameSpace);
    XalanDOMString functionName(pFn->getName());
    bool bAssigned = pFn->isAssigned();

    if (set && !bAssigned)
        m_XalanTransformer.installExternalFunction(nameSpace, functionName, *pFn->get());
    else
    {
        if (!set && bAssigned)
            m_XalanTransformer.uninstallExternalFunction(nameSpace, functionName);
        else
            throw MakeStringException(-1, "XSLT external function assignment error!");
    }

    pFn->setAssigned(set);
    return 0;
}
Beispiel #14
0
Symbol* NameSpace::lookup(const std::string& name, std::set<const NameSpace*>& alreadyVisited) const
{
    Symbol* pSymbol = 0;

    if (name.empty())
        return pSymbol;

    if (alreadyVisited.find(this) != alreadyVisited.end())
        return pSymbol;
    std::string head;
    std::string tail;
    splitName(name, head, tail);

    alreadyVisited.insert(this);
    bool currentNSInserted = true;


    if (head.empty())
    {
        alreadyVisited.insert(this);
        return root()->lookup(tail, alreadyVisited);
    }
    SymbolTable::const_iterator it = _symbols.find(head);
    if (it != _symbols.end())
    {
        pSymbol = it->second;
        if (!tail.empty())
        {
            alreadyVisited.insert(this);
            NameSpace* pNS = dynamic_cast<NameSpace*>(pSymbol);
            if (pNS)
                pSymbol = static_cast<NameSpace*>(pSymbol)->lookup(tail, alreadyVisited);
            else
                pSymbol = 0;
        }
    }
    else if (tail.empty())
    {
        AliasMap::const_iterator itAlias = _importedSymbols.find(head);
        if (itAlias != _importedSymbols.end())
            pSymbol = lookup(itAlias->second, alreadyVisited);
        else
        {
            for (NameSpaceVec::const_iterator it = _importedNameSpaces.begin(); !pSymbol && it != _importedNameSpaces.end(); ++it)
            {
                Symbol* pNS = lookup(*it, alreadyVisited);
                if (pNS && pNS->kind() == Symbol::SYM_NAMESPACE)
                {
                    pSymbol = static_cast<NameSpace*>(pNS)->lookup(name, alreadyVisited);
                }
            }
        }
    }
    NameSpace* pNS = nameSpace();
    if (!pSymbol && pNS && (alreadyVisited.find(pNS) == alreadyVisited.end()))
    {
        // if we have to go up, never push the NS!
        if (currentNSInserted)
            alreadyVisited.erase(this);
        pSymbol = nameSpace()->lookup(name, alreadyVisited);
    }
    return pSymbol;
}
int main(void)
{
    Object* ns = 0;
    esInit(&ns);
    FatFileSystem::initializeConstructor();
    Handle<es::Context> nameSpace(ns);

#ifdef __es__
    Handle<es::Stream> disk = nameSpace->lookup("device/ata/channel0/device0");
#else
    Handle<es::Stream> disk = new VDisk(static_cast<char*>("fat16_5MB.img"));
#endif
    long long diskSize;
    diskSize = disk->getSize();
    esReport("diskSize: %lld\n", diskSize);

    Handle<es::FileSystem> fatFileSystem;
    long long freeSpace;
    long long totalSpace;

    fatFileSystem = es::FatFileSystem::createInstance();
    fatFileSystem->mount(disk);
    fatFileSystem->format();
    freeSpace = fatFileSystem->getFreeSpace();
    totalSpace = fatFileSystem->getTotalSpace();
    esReport("Free space %lld, Total space %lld\n", freeSpace, totalSpace);
    {
        Handle<es::Context> root;
        root = fatFileSystem->getRoot();

        Handle<es::Binding> binding = root;
        TEST(binding);

        Handle<Object> interface = binding->getObject();
        TEST(interface);

        Handle<es::Context> object = interface;
        TEST(object);
        TEST(object == root);

        long ret = TestFileSystem(object);
        TEST(ret == 0);

        // setObject() must return an exception.
        try
        {
            binding->setObject(interface);
            TEST(false);
        }
        catch (Exception& error)
        {
        }
    }
    fatFileSystem->dismount();
    fatFileSystem = 0;

    fatFileSystem = es::FatFileSystem::createInstance();
    fatFileSystem->mount(disk);
    freeSpace = fatFileSystem->getFreeSpace();
    totalSpace = fatFileSystem->getTotalSpace();
    esReport("Free space %lld, Total space %lld\n", freeSpace, totalSpace);
    esReport("\nChecking the file system...\n");
    TEST(fatFileSystem->checkDisk(false));
    fatFileSystem->dismount();
    fatFileSystem = 0;

    esReport("done.\n\n");
}
Beispiel #16
0
void emulInit(int32_t argc, char **argv, char **envp){
  FileSys::Node::insert("/dev/null",new FileSys::NullNode());
  FileSys::Node::insert("/dev/tty",0);

  FileSys::Description *inDescription=0;
  FileSys::Description *outDescription=0;
  FileSys::Description *errDescription=0;

  extern char *optarg;
  int32_t opt;
  while((opt=getopt(argc, argv, "+hi:o:e:"))!=-1){
    switch(opt){
    case 'i':
      inDescription=FileSys::Description::open(optarg,O_RDONLY,S_IRUSR);
      if(!inDescription)
	fail("Could not open `%s' as simulated stdin file\n",optarg);
      break;
    case 'o':
      outDescription=FileSys::Description::open(optarg,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
      if(!outDescription)
	fail("Could not open `%s' as simulated stdout file\n",optarg);
      break;
    case 'e':
      errDescription=FileSys::Description::open(optarg,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
      if(!errDescription)
	fail("Could not open `%s' as simulated stderr file %s\n",optarg);
      break;
    case 'h':
    default:
      fail("\n"
	   "Usage: %s [EmulOpts] [-- SimOpts] AppExec [AppOpts]\n"
	   "  EmulOpts:\n"
	   "  [-i FName] Use file FName as stdin  for AppExec\n"
	   "  [-o FName] Use file FName as stdout for AppExec\n"
	   "  [-e FName] Use file FName as stderr for AppExec\n",
	   argv[0]);
    }
  }
  if(!inDescription){
    inDescription=FileSys::TtyDescription::wrap(STDIN_FILENO);
    if(!inDescription)
      fail("Could not wrap stdin\n");
  }
  if(!outDescription){
    outDescription=FileSys::TtyDescription::wrap(STDOUT_FILENO);
    if(!outDescription)
      fail("Could not wrap stdout\n");
  }
  if(!errDescription){
    errDescription=FileSys::TtyDescription::wrap(STDERR_FILENO);
    if(!errDescription)
      fail("Could not wrap stderr\n");
  }
  int32_t    appArgc=argc-optind;
  char **appArgv=&(argv[optind]);
  char **appEnvp=envp;
  // Count environment variables
  int32_t    appEnvc=0;
  while(appEnvp[appEnvc])
    appEnvc++;

  FileSys::NameSpace::pointer nameSpace(new FileSys::NameSpace(SescConf->getCharPtr("FileSys","mount")));
  char hostCwd[PATH_MAX];
  if(getcwd(hostCwd,PATH_MAX)==0)
    fail("emulInit: Failed to get host current directory (getcwd)\n");
  const string targetCwd(nameSpace->toTarget(nameSpace->normalize("/",hostCwd)));
  FileSys::FileSys::pointer fileSys(new FileSys::FileSys(nameSpace,targetCwd));
  const string exeLinkName(fileSys->toHost(appArgv[0]));
  const string exeRealName(FileSys::Node::resolve(exeLinkName));
  if(exeRealName.empty())
    fail("emulInit: Link loop when executable %s\n",exeLinkName.c_str());
  FileSys::Node *node=FileSys::Node::lookup(exeRealName);
  if(!node)
    fail("emulInit: Executable %s does not exist\n",exeLinkName.c_str());
  FileSys::FileNode *fnode=dynamic_cast<FileSys::FileNode *>(node);
  if(!fnode)
    fail("emulInit: Executable %s is not a regular file\n",exeLinkName.c_str());
  FileSys::FileDescription *fdesc=new FileSys::FileDescription(fnode,O_RDONLY);
  FileSys::Description::pointer pdesc(fdesc);
  ThreadContext *mainThread=new ThreadContext(fileSys);
  // TODO: Use ELF_ET_DYN_BASE instead of a constant here
  loadElfObject(mainThread,fdesc,0x200000);
  mainThread->getSystem()->initSystem(mainThread);
  mainThread->getSystem()->createStack(mainThread);
  mainThread->getSystem()->setProgArgs(mainThread,appArgc,appArgv,appEnvc,appEnvp);
  FileSys::OpenFiles *openFiles=mainThread->getOpenFiles();
  openFiles->openDescriptor(STDIN_FILENO,inDescription);
  openFiles->openDescriptor(STDOUT_FILENO,outDescription);
  openFiles->openDescriptor(STDERR_FILENO,errDescription);
}
Beispiel #17
0
bool Function::isConstructor() const
{
	return name() == nameSpace()->name();
}
Beispiel #18
0
bool Function::isFunction() const
{
	return nameSpace()->kind() == Symbol::SYM_NAMESPACE;
}
Beispiel #19
0
bool Function::isMethod() const
{
	return !isConstructor() && !isDestructor() && nameSpace()->kind() == Symbol::SYM_STRUCT;
}