void RegExp::finishCreation(VM& vm) { Base::finishCreation(vm); Yarr::YarrPattern pattern(m_patternString, ignoreCase(), multiline(), &m_constructionError); if (m_constructionError) m_state = ParseError; else m_numSubpatterns = pattern.m_numSubpatterns; }
/* ** Read a line and try to load (compile) it first as an expression (by ** adding "return " in front of it) and second as a statement. Return ** the final status of load/call with the resulting function (if any) ** in the top of the stack. */ static int loadline (lua_State *L) { int status; lua_settop(L, 0); if (!pushline(L, 1)) return -1; /* no input */ if ((status = addreturn(L)) != LUA_OK) /* 'return ...' did not work? */ status = multiline(L); /* try as command, maybe with continuation lines */ lua_remove(L, 1); /* remove line from the stack */ lua_assert(lua_gettop(L) == 1); return status; }
RegExpImpl(const void* pattern, int len, unsigned flags) : RegExpBase(flags) { const char* errorMessage = NULL; re_ = jsRegExpCompile( static_cast<const uint16_t*>(pattern), len, ignoreCase() ? dart::jscre::JSRegExpIgnoreCase : dart::jscre::JSRegExpDoNotIgnoreCase, multiline() ? dart::jscre::JSRegExpMultiline : dart::jscre::JSRegExpSingleLine, &numSubpatterns_, &errorMessage, malloc, free); }
RegExp::RegExpState RegExp::compile(JSGlobalData* globalData) { Yarr::RegexPattern pattern(m_patternString, ignoreCase(), multiline(), &m_constructionError); if (m_constructionError) return ParseError; m_numSubpatterns = pattern.m_numSubpatterns; #if ENABLE(YARR_JIT) if (!pattern.m_containsBackreferences && globalData->canUseJIT()) { Yarr::jitCompileRegex(pattern, globalData, m_representation->m_regExpJITCode); if (!m_representation->m_regExpJITCode.isFallBack()) return JITCode; } #endif m_representation->m_regExpBytecode = Yarr::byteCompileRegex(pattern, &globalData->m_regexAllocator); return ByteCode; }
void tree_Node_::draw_tree_buffer( TextBuffer * b) { draw(); int last = f_line(); tree_Node sub = NULL; for ( int i = 0 ; i < (int)subNodes.size(); i++ ) { // glPushMatrix(); switch ( i % 3 ) { case 0 : glColor3d ( 0.5,0,0 ); break; case 1 : glColor3d ( 0,0.5,0 ); break; case 2 : glColor3d ( 0,0,0.5 ); break; } sub = subNodes[i]; if ( sub && ( multiline() || sub->multiline() ) ) { drawTextRange(b, last, sub->f_line() - 1 ); sub->draw_tree_buffer(b); last = sub->l_line() + 1; } // glPopMatrix(); } drawTextRange(b, last, l_line()); }
void RegExp::compileMatchOnly(VM* vm, Yarr::YarrCharSize charSize) { Yarr::YarrPattern pattern(m_patternString, ignoreCase(), multiline(), &m_constructionError); if (m_constructionError) { RELEASE_ASSERT_NOT_REACHED(); #if COMPILER_QUIRK(CONSIDERS_UNREACHABLE_CODE) m_state = ParseError; return; #endif } ASSERT(m_numSubpatterns == pattern.m_numSubpatterns); if (!hasCode()) { ASSERT(m_state == NotCompiled); vm->regExpCache()->addToStrongCache(this); m_state = ByteCode; } #if ENABLE(YARR_JIT) if (!pattern.m_containsBackreferences && !pattern.containsUnsignedLengthPattern() && vm->canUseRegExpJIT()) { Yarr::jitCompile(pattern, charSize, vm, m_regExpJITCode, Yarr::MatchOnly); #if ENABLE(YARR_JIT_DEBUG) if (!m_regExpJITCode.isFallBack()) m_state = JITCode; else m_state = ByteCode; #else if (!m_regExpJITCode.isFallBack()) { m_state = JITCode; return; } #endif } #else UNUSED_PARAM(charSize); #endif m_regExpBytecode = Yarr::byteCompile(pattern, &vm->m_regExpAllocator); }
void RegExp::compile(JSGlobalData* globalData, Yarr::YarrCharSize charSize) { Yarr::YarrPattern pattern(m_patternString, ignoreCase(), multiline(), &m_constructionError); if (m_constructionError) { ASSERT_NOT_REACHED(); m_state = ParseError; return; } ASSERT(m_numSubpatterns == pattern.m_numSubpatterns); if (!m_representation) { ASSERT(m_state == NotCompiled); m_representation = adoptPtr(new RegExpRepresentation); globalData->regExpCache()->addToStrongCache(this); m_state = ByteCode; } #if ENABLE(YARR_JIT) if (!pattern.m_containsBackreferences && globalData->canUseJIT()) { Yarr::jitCompile(pattern, charSize, globalData, m_representation->m_regExpJITCode); #if ENABLE(YARR_JIT_DEBUG) if (!m_representation->m_regExpJITCode.isFallBack()) m_state = JITCode; else m_state = ByteCode; #else if (!m_representation->m_regExpJITCode.isFallBack()) { m_state = JITCode; return; } #endif } #else UNUSED_PARAM(charSize); #endif m_representation->m_regExpBytecode = Yarr::byteCompile(pattern, &globalData->m_regExpAllocator); }
int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector) { if (startOffset < 0) startOffset = 0; if (ovector) ovector->clear(); if (startOffset > s.size() || s.isNull()) return -1; #if ENABLE(YARR_JIT) if (!!m_regExpJITCode) { #else if (m_regExpBytecode) { #endif int offsetVectorSize = (m_numSubpatterns + 1) * 3; // FIXME: should be 2 - but adding temporary fallback to pcre. int* offsetVector; Vector<int, 32> nonReturnedOvector; if (ovector) { ovector->resize(offsetVectorSize); offsetVector = ovector->data(); } else { nonReturnedOvector.resize(offsetVectorSize); offsetVector = nonReturnedOvector.data(); } ASSERT(offsetVector); for (int j = 0; j < offsetVectorSize; ++j) offsetVector[j] = -1; #if ENABLE(YARR_JIT) int result = Yarr::executeRegex(m_regExpJITCode, s.data(), startOffset, s.size(), offsetVector, offsetVectorSize); #else int result = Yarr::interpretRegex(m_regExpBytecode.get(), s.data(), startOffset, s.size(), offsetVector); #endif if (result < 0) { #ifndef NDEBUG // TODO: define up a symbol, rather than magic -1 if (result != -1) fprintf(stderr, "jsRegExpExecute failed with result %d\n", result); #endif if (ovector) ovector->clear(); } return result; } return -1; } #else void RegExp::compile(JSGlobalData* globalData) { m_regExp = 0; #if ENABLE(WREC) m_wrecFunction = Generator::compileRegExp(globalData, m_pattern, &m_numSubpatterns, &m_constructionError, m_executablePool, ignoreCase(), multiline()); if (m_wrecFunction || m_constructionError) return; // Fall through to non-WREC case. #else UNUSED_PARAM(globalData); #endif JSRegExpIgnoreCaseOption ignoreCaseOption = ignoreCase() ? JSRegExpIgnoreCase : JSRegExpDoNotIgnoreCase; JSRegExpMultilineOption multilineOption = multiline() ? JSRegExpMultiline : JSRegExpSingleLine; m_regExp = jsRegExpCompile(reinterpret_cast<const UChar*>(m_pattern.data()), m_pattern.size(), ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError); }
void foo(void) { switch(ch) { // handle 'a' case 'a': { handle_a(); multiline(123, 345); break; } // handle 'b' case 'b': handle_b(); multiline(123, 345); break; // handle 'c' and 'd' case 'c': case 'd': // c and d are really the same thing handle_cd(); multiline(123, 345); break; case 'e': { handle_a(); multiline(123, 345); } break; // case1 case (case1): { //do stuff break; } case (case2): { //do stuff break; } case (case3): /*do stuff*/ break; case (case3): statement(); { another_statement(); } break; // really should not get here default: handle_default(); multiline(123, 345); break; } multiline(123, 345); }