private static boolean isSingleChar(char lo, char hi) { CompilerAsserts.partialEvaluationConstant(lo); CompilerAsserts.partialEvaluationConstant(hi); return lo == hi; }
/** * Gets called when {@link #checkMatch1(VirtualFrame, TRegexDFAExecutorNode, boolean)} finds a * successor. * * @param frame a virtual frame as described by {@link TRegexDFAExecutorProperties}. * @param executor this node's parent {@link TRegexDFAExecutorNode}. * @param i the index of the matching transition (corresponds to an entry in * {@link #getMatchers()} and {@link #getSuccessors()}). */ protected void successorFound1(VirtualFrame frame, TRegexDFAExecutorNode executor, int i) { CompilerAsserts.partialEvaluationConstant(this); }
private static boolean isTwoChars(char lo, char hi) { CompilerAsserts.partialEvaluationConstant(lo); CompilerAsserts.partialEvaluationConstant(hi); return lo + 1 == hi; }
public int checkMatchTree3(VirtualFrame frame, TRegexDFAExecutorNode executor, DFAStateNode stateNode, char c, int preLoopIndex) { CompilerAsserts.partialEvaluationConstant(this); CompilerAsserts.partialEvaluationConstant(stateNode); return checkMatchTree3(frame, executor, stateNode, 0, sortedRanges.length - 1, c, preLoopIndex); }
public int checkMatchTree2(VirtualFrame frame, TRegexDFAExecutorNode executor, DFAStateNode stateNode, char c) { CompilerAsserts.partialEvaluationConstant(this); CompilerAsserts.partialEvaluationConstant(stateNode); return checkMatchTree2(frame, executor, stateNode, 0, sortedRanges.length - 1, c); }
@Override protected int atEnd2(VirtualFrame frame, TRegexDFAExecutorNode executor) { CompilerAsserts.partialEvaluationConstant(this); return atEndLoop(frame, executor); }
@Override protected void noSuccessor2(VirtualFrame frame, TRegexDFAExecutorNode executor) { CompilerAsserts.partialEvaluationConstant(this); assert executor.isSearching(); checkFinalStateLoop(frame, executor); }
public void applyPreFinalTransition(VirtualFrame frame, TRegexDFAExecutorNode executor, short transitionIndex, int currentIndex) { CompilerAsserts.partialEvaluationConstant(this); if (precedingTransitions.length > EXPLODE_THRESHOLD) { applyPreFinalTransitionBoundary(executor, executor.getCGData(frame), transitionIndex, currentIndex); } else { applyPreFinalTransitionExploded(frame, executor, executor, transitionIndex, currentIndex); } }
@SuppressWarnings("unchecked") @Override public <T extends TruffleLanguage<?>> T getCurrentLanguage(Class<T> languageClass) { CompilerAsserts.partialEvaluationConstant(languageClass); PolyglotContextImpl context = PolyglotContextImpl.requireContext(); return (T) NODES.getLanguageSpi(context.getLanguageContext(languageClass).language.info); }
@SuppressWarnings("unchecked") @Override public <T extends TruffleLanguage<?>> T getCurrentLanguage(Class<T> languageClass) { CompilerAsserts.partialEvaluationConstant(languageClass); PolyglotContextImpl context = PolyglotContextImpl.requireContext(); Env env = context.getLanguageContext(languageClass).env; if (env == null) { CompilerDirectives.transferToInterpreter(); throw new IllegalStateException("Current context is not yet initialized or already disposed."); } return (T) VMAccessor.LANGUAGE.getLanguage(env); }
@SuppressWarnings("unchecked") @Override public <C, T extends TruffleLanguage<C>> C getCurrentContext(Class<T> languageClass) { CompilerAsserts.partialEvaluationConstant(languageClass); PolyglotContextImpl context = PolyglotContextImpl.requireContext(); Env env = context.getLanguageContext(languageClass).env; if (env == null) { CompilerDirectives.transferToInterpreter(); throw new IllegalStateException("Current context is not yet initialized or already disposed."); } return (C) LANGUAGE.getContext(env); }
@SuppressWarnings("unchecked") @Override public <C, T extends TruffleLanguage<C>> C getCurrentContext(Class<T> languageClass) { CompilerAsserts.partialEvaluationConstant(languageClass); PolyglotContextImpl context = PolyglotContextImpl.requireContext(); Env env = context.getLanguageContext(languageClass).env; if (env == null) { CompilerDirectives.transferToInterpreter(); throw new IllegalStateException("Current context is not yet initialized or already disposed."); } return (C) LANGUAGE.getContext(env); }
@ExplodeLoop public DynamicObject newInstance(Object... initialValues) { assert initialValues.length == instanceFields.length : wrongArguments(initialValues.length); DynamicObject store = shape.newInstance(); CompilerAsserts.partialEvaluationConstant(instanceFields.length); for (int i = 0; i < instanceFields.length; i++) { instanceFields[i].setInternal(store, initialValues[i]); } return store; }
@ExplodeLoop public DynamicObject newInstance(Object... initialValues) { assert initialValues.length == instanceFields.length : wrongArguments(initialValues.length); DynamicObject store = shape.newInstance(); CompilerAsserts.partialEvaluationConstant(instanceFields.length); for (int i = 0; i < instanceFields.length; i++) { instanceFields[i].setInternal(store, initialValues[i]); } return store; }
@Override protected int atEnd1(VirtualFrame frame, TRegexDFAExecutorNode executor) { CompilerAsserts.partialEvaluationConstant(this); if (isAnchoredFinalState() && executor.atEnd(frame)) { applyAnchoredFinalStateTransition(frame, executor); } else { checkFinalState(frame, executor); } return FS_RESULT_NO_SUCCESSOR; }
@Override protected void noSuccessor3(VirtualFrame frame, TRegexDFAExecutorNode executor, int preLoopIndex) { CompilerAsserts.partialEvaluationConstant(this); assert executor.isSearching(); applyLoopTransitions(frame, executor, preLoopIndex, prevIndex(frame, executor) - 1); checkFinalStateLoop(frame, executor); }
@Override protected void successorFound1(VirtualFrame frame, TRegexDFAExecutorNode executor, int i) { CompilerAsserts.partialEvaluationConstant(this); CompilerAsserts.partialEvaluationConstant(i); if (precedingCaptureGroupTransitions.length == 1) { executor.getCGTransitions()[precedingCaptureGroupTransitions[0]].getPartialTransitions()[i].apply(executor, executor.getCGData(frame), prevIndex(frame, executor)); } else { transitionDispatchNode.applyPartialTransition(frame, executor, executor.getLastTransition(frame), i, prevIndex(frame, executor)); } executor.setLastTransition(frame, captureGroupTransitions[i]); }
@Override protected void successorFound3(VirtualFrame frame, TRegexDFAExecutorNode executor, int i, int preLoopIndex) { CompilerAsserts.partialEvaluationConstant(this); CompilerAsserts.partialEvaluationConstant(i); applyLoopTransitions(frame, executor, preLoopIndex, prevIndex(frame, executor) - 1); if (executor.isSearching()) { checkFinalStateLoop(frame, executor); } getCGTransitionToSelf(executor).getPartialTransitions()[i].apply(executor, executor.getCGData(frame), prevIndex(frame, executor)); executor.setLastTransition(frame, captureGroupTransitions[i]); }
private void storeResult(VirtualFrame frame, TRegexDFAExecutorNode executor) { CompilerAsserts.partialEvaluationConstant(this); if (!executor.isSearching()) { executor.getCGData(frame).exportResult((byte) DFACaptureGroupPartialTransitionNode.FINAL_STATE_RESULT_INDEX); } executor.setResultObject(frame, executor.getCGData(frame).currentResult); } }
public void applyPreFinalStateTransition(TRegexDFAExecutorNode executor, DFACaptureGroupTrackingData d, boolean searching, final int currentIndex) { CompilerAsserts.partialEvaluationConstant(this); if (!searching) { apply(executor, d, currentIndex); return; } if (executor.recordExecution()) { executor.getDebugRecorder().recordCGPartialTransition(currentIndex, id); } d.exportResult(preReorderFinalStateResultIndex); applyFinalStateTransition(executor, d, true, currentIndex); }