Пример #1
0
InternedString InternedStringPool::get(llvm::StringRef arg) {
    // HACK: should properly track this liveness:
    BoxedString* s = internStringImmortal(arg);

#ifndef NDEBUG
    return InternedString(s, this);
#else
    return InternedString(s);
#endif
}
Пример #2
0
	void testRangeConstruction()
	{

		const char *aa = "aa";
		const char *aabb = "aabb";
		const char *aabbaa = "aabbaa";

		BOOST_CHECK_EQUAL( InternedString( aa ), InternedString( aa, 2 ) );
		BOOST_CHECK_EQUAL( InternedString( aa, 2 ), InternedString( aa, 2 ) );
		BOOST_CHECK_EQUAL( InternedString( aa, 1 ), InternedString( aa, 1 ) );
		BOOST_CHECK_EQUAL( InternedString( aa, 2 ), InternedString( aabb, 2 ) );
		BOOST_CHECK_EQUAL( InternedString( aabb ), InternedString( aabbaa, 4 ) );

	};
Пример #3
0
		virtual task *execute()
		{				
			
			ContextPtr context = new Context( *m_context );
			context->set( ScenePlug::scenePathContextName, m_scenePath );
			Context::Scope scopedContext( context );
			
			m_scenePlug->transformPlug()->getValue();
			m_scenePlug->boundPlug()->getValue();
			m_scenePlug->attributesPlug()->getValue();
			m_scenePlug->objectPlug()->getValue();
				
			ConstInternedStringVectorDataPtr childNamesData = m_scenePlug->childNamesPlug()->getValue();
			const vector<InternedString> &childNames = childNamesData->readable();
			
			set_ref_count( 1 + childNames.size() );
			
			ScenePlug::ScenePath childPath = m_scenePath;
			childPath.push_back( InternedString() ); // space for the child name
			for( vector<InternedString>::const_iterator it = childNames.begin(), eIt = childNames.end(); it != eIt; it++ )
			{
				childPath[m_scenePath.size()] = *it;
				SceneTraversalTask *t = new( allocate_child() ) SceneTraversalTask( m_scenePlug, m_context, childPath );
				spawn( *t );
			}
			
			wait_for_all();
			
			return 0;
		}
Пример #4
0
bool ASTPrintVisitor::visit_functiondef(AST_FunctionDef* node) {
    for (auto d : node->decorator_list) {
        stream << "@";
        d->accept(this);
        stream << "\n";
        printIndent();
    }

    stream << "def ";
    if (node->name != InternedString())
        stream << node->name.s();
    else
        stream << "<lambda>";
    stream << "(";
    node->args->accept(this);
    stream << ")";

    indent += 4;
    for (int i = 0; i < node->body.size(); i++) {
        stream << "\n";
        printIndent();
        node->body[i]->accept(this);
    }
    indent -= 4;
    return true;
}
Пример #5
0
const InternedString &InternedString::numberString( int64_t number )
{
	typedef tbb::concurrent_hash_map< int64_t, InternedString > NumbersMap;
	static NumbersMap *g_numbers = 0;
	if ( !g_numbers )
	{
		g_numbers = new NumbersMap;
	}
	NumbersMap::accessor it;
	if ( g_numbers->insert( it, number ) )
	{
		it->second = InternedString( boost::lexical_cast<std::string>( number ) );
	}
	return it->second;
}
Пример #6
0
const InternedString &InternedString::numberString( int64_t number )
{
	typedef tbb::concurrent_hash_map< int64_t, InternedString > NumbersMap;
	static NumbersMap *g_numbers = 0;
	if ( !g_numbers )
	{
		g_numbers = new NumbersMap;
	}
	NumbersMap::accessor it;
	if ( g_numbers->insert( it, number ) )
	{
		it->second = InternedString( ( boost::format("%d") % number ).str() );
	}
	return it->second;
}
Пример #7
0
BORROWED(BoxedString*) AST::getName() noexcept {
    static BoxedString* lambda_name = getStaticString("<lambda>");
    static BoxedString* module_name = getStaticString("<module>");

    switch (this->type) {
        case AST_TYPE::ClassDef:
            return ast_cast<AST_ClassDef>(this)->name.getBox();
        case AST_TYPE::FunctionDef:
            if (ast_cast<AST_FunctionDef>(this)->name != InternedString())
                return ast_cast<AST_FunctionDef>(this)->name.getBox();
            return lambda_name;
        case AST_TYPE::Module:
        case AST_TYPE::Expression:
        case AST_TYPE::Suite:
            return module_name;
        default:
            RELEASE_ASSERT(0, "%d", this->type);
    }
}