blob: 1d203db2fde994400cad19ae379bf77a13eb5397 [file]
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.javascript;
import org.mozilla.classfile.DynamicDescriberRegistry;
/**
* A proxy for the regexp package, so that the regexp package can be loaded optionally.
*
* @author Norris Boyd
*/
public interface RegExpProxy {
// Types of regexp actions
public static final int RA_MATCH = 1;
public static final int RA_REPLACE = 2;
public static final int RA_REPLACE_ALL = 3;
public static final int RA_SEARCH = 4;
public void register(Context cx, TopLevel scope, boolean sealed);
public boolean isRegExp(Scriptable obj);
public Object compileRegExp(Context cx, String source, String flags);
/**
* Compile a regexp literal that the caller intends to write to a class file as a {@code
* CONSTANT_Dynamic} entry, rather than to compile again on every run.
*
* <p>Anything wrong with the expression must be reported here, because the class file records
* only a description of the compiled form: whatever recreates it when the constant is resolved
* is not in a position to report an error against the script being compiled.
*
* @return a value that one of the {@link #getDynamicConstantDescribers describers} of this
* proxy can describe, or null if this implementation has no constant form, in which case
* the caller falls back to compiling the expression at run time.
*/
default Object prepareRegExpConstant(Context cx, String source, String flags) {
return null;
}
/**
* Register Describers for the values this proxy returns from {@link #prepareRegExpConstant}, to
* be registered with the class file writer that will write them.
*
* <p>An implementation that returns describers here must also implement {@code
* prepareRegExpConstant}, and one that does not must return an empty list.
*/
default void registerDynamicConstantDescribers(DynamicDescriberRegistry registry) {}
public Scriptable wrapRegExp(Context cx, VarScope scope, Object compiled);
public Object action(Context cx, VarScope scope, Object thisObj, Object[] args, int actionType);
public int find_split(
Context cx,
VarScope scope,
String target,
String separator,
Scriptable re,
int[] ip,
int[] matchlen,
boolean[] matched,
String[][] parensp);
public Object js_split(Context _cx, VarScope _scope, String thisString, Object[] _args);
}