当前位置: 首页>>代码示例>>Java>>正文


Java RegexToken类代码示例

本文整理汇总了Java中jdk.nashorn.internal.parser.Lexer.RegexToken的典型用法代码示例。如果您正苦于以下问题:Java RegexToken类的具体用法?Java RegexToken怎么用?Java RegexToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RegexToken类属于jdk.nashorn.internal.parser.Lexer包,在下文中一共展示了RegexToken类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadRegex

import jdk.nashorn.internal.parser.Lexer.RegexToken; //导入依赖的package包/类
private MethodEmitter loadRegex(final RegexToken regexToken) {
    if (regexFieldCount > MAX_REGEX_FIELDS) {
        return loadRegexToken(regexToken);
    }
    // emit field
    final String       regexName    = lc.getCurrentFunction().uniqueName(REGEX_PREFIX.symbolName());
    final ClassEmitter classEmitter = unit.getClassEmitter();

    classEmitter.field(EnumSet.of(PRIVATE, STATIC), regexName, Object.class);
    regexFieldCount++;

    // get field, if null create new regex, finally clone regex object
    method.getStatic(unit.getUnitClassName(), regexName, typeDescriptor(Object.class));
    method.dup();
    final Label cachedLabel = new Label("cached");
    method.ifnonnull(cachedLabel);

    method.pop();
    loadRegexToken(regexToken);
    method.dup();
    method.putStatic(unit.getUnitClassName(), regexName, typeDescriptor(Object.class));

    method.label(cachedLabel);
    globalRegExpCopy();

    return method;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:CodeGenerator.java

示例2: enterLiteralNode

import jdk.nashorn.internal.parser.Lexer.RegexToken; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public boolean enterLiteralNode(final LiteralNode literalNode) {
    enterDefault(literalNode);

    if (literalNode instanceof LiteralNode.ArrayLiteralNode) {
        type("ArrayExpression");
        comma();

        array("elements", ((LiteralNode.ArrayLiteralNode)literalNode).getElementExpressions());
    } else {
        type("Literal");
        comma();

        property("value");
        final Object value = literalNode.getValue();
        if (value instanceof RegexToken) {
            // encode RegExp literals as Strings of the form /.../<flags>
            final RegexToken regex = (RegexToken)value;
            final StringBuilder regexBuf = new StringBuilder();
            regexBuf.append('/');
            regexBuf.append(regex.getExpression());
            regexBuf.append('/');
            regexBuf.append(regex.getOptions());
            buf.append(quote(regexBuf.toString()));
        } else {
            final String str = literalNode.getString();
            // encode every String literal with prefix '$' so that script
            // can differentiate b/w RegExps as Strings and Strings.
            buf.append(literalNode.isString()? quote("$" + str) : str);
        }
    }

    return leave();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:JSONWriter.java

示例3: loadLiteral

import jdk.nashorn.internal.parser.Lexer.RegexToken; //导入依赖的package包/类
private void loadLiteral(final LiteralNode<?> node, final TypeBounds resultBounds) {
    final Object value = node.getValue();

    if (value == null) {
        method.loadNull();
    } else if (value instanceof Undefined) {
        method.loadUndefined(resultBounds.within(Type.OBJECT));
    } else if (value instanceof String) {
        final String string = (String)value;

        if (string.length() > MethodEmitter.LARGE_STRING_THRESHOLD / 3) { // 3 == max bytes per encoded char
            loadConstant(string);
        } else {
            method.load(string);
        }
    } else if (value instanceof RegexToken) {
        loadRegex((RegexToken)value);
    } else if (value instanceof Boolean) {
        method.load((Boolean)value);
    } else if (value instanceof Integer) {
        if(!resultBounds.canBeNarrowerThan(Type.OBJECT)) {
            method.load((Integer)value);
            method.convert(Type.OBJECT);
        } else if(!resultBounds.canBeNarrowerThan(Type.NUMBER)) {
            method.load(((Integer)value).doubleValue());
        } else if(!resultBounds.canBeNarrowerThan(Type.LONG)) {
            method.load(((Integer)value).longValue());
        } else {
            method.load((Integer)value);
        }
    } else if (value instanceof Long) {
        if(!resultBounds.canBeNarrowerThan(Type.OBJECT)) {
            method.load((Long)value);
            method.convert(Type.OBJECT);
        } else if(!resultBounds.canBeNarrowerThan(Type.NUMBER)) {
            method.load(((Long)value).doubleValue());
        } else {
            method.load((Long)value);
        }
    } else if (value instanceof Double) {
        if(!resultBounds.canBeNarrowerThan(Type.OBJECT)) {
            method.load((Double)value);
            method.convert(Type.OBJECT);
        } else {
            method.load((Double)value);
        }
    } else if (node instanceof ArrayLiteralNode) {
        final ArrayLiteralNode arrayLiteral = (ArrayLiteralNode)node;
        final ArrayType atype = arrayLiteral.getArrayType();
        loadArray(arrayLiteral, atype);
        globalAllocateArray(atype);
    } else {
        throw new UnsupportedOperationException("Unknown literal for " + node.getClass() + " " + value.getClass() + " " + value);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:56,代码来源:CodeGenerator.java

示例4: loadRegexToken

import jdk.nashorn.internal.parser.Lexer.RegexToken; //导入依赖的package包/类
private MethodEmitter loadRegexToken(final RegexToken value) {
    method.load(value.getExpression());
    method.load(value.getOptions());
    return globalNewRegExp();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:CodeGenerator.java

示例5: loadLiteral

import jdk.nashorn.internal.parser.Lexer.RegexToken; //导入依赖的package包/类
private void loadLiteral(final LiteralNode<?> node, final TypeBounds resultBounds) {
    final Object value = node.getValue();

    if (value == null) {
        method.loadNull();
    } else if (value instanceof Undefined) {
        method.loadUndefined(resultBounds.within(Type.OBJECT));
    } else if (value instanceof String) {
        final String string = (String)value;

        if (string.length() > MethodEmitter.LARGE_STRING_THRESHOLD / 3) { // 3 == max bytes per encoded char
            loadConstant(string);
        } else {
            method.load(string);
        }
    } else if (value instanceof RegexToken) {
        loadRegex((RegexToken)value);
    } else if (value instanceof Boolean) {
        method.load((Boolean)value);
    } else if (value instanceof Integer) {
        if(!resultBounds.canBeNarrowerThan(Type.OBJECT)) {
            method.load((Integer)value);
            method.convert(Type.OBJECT);
        } else if(!resultBounds.canBeNarrowerThan(Type.NUMBER)) {
            method.load(((Integer)value).doubleValue());
        } else {
            method.load((Integer)value);
        }
    } else if (value instanceof Double) {
        if(!resultBounds.canBeNarrowerThan(Type.OBJECT)) {
            method.load((Double)value);
            method.convert(Type.OBJECT);
        } else {
            method.load((Double)value);
        }
    } else if (node instanceof ArrayLiteralNode) {
        final ArrayLiteralNode arrayLiteral = (ArrayLiteralNode)node;
        final ArrayType atype = arrayLiteral.getArrayType();
        loadArray(arrayLiteral, atype);
        globalAllocateArray(atype);
    } else {
        throw new UnsupportedOperationException("Unknown literal for " + node.getClass() + " " + value.getClass() + " " + value);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:45,代码来源:CodeGenerator.java


注:本文中的jdk.nashorn.internal.parser.Lexer.RegexToken类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。