Java Code Examples for jdk.nashorn.internal.ir.FunctionNode#getKind()

The following examples show how to use jdk.nashorn.internal.ir.FunctionNode#getKind() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecompilableScriptFunctionData.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static int getDataFlags(final FunctionNode functionNode) {
    int flags = IS_CONSTRUCTOR;
    if (functionNode.isStrict()) {
        flags |= IS_STRICT;
    }
    if (functionNode.needsCallee()) {
        flags |= NEEDS_CALLEE;
    }
    if (functionNode.usesThis() || functionNode.hasEval()) {
        flags |= USES_THIS;
    }
    if (functionNode.isVarArg()) {
        flags |= IS_VARIABLE_ARITY;
    }
    if (functionNode.getKind() == FunctionNode.Kind.GETTER || functionNode.getKind() == FunctionNode.Kind.SETTER) {
        flags |= IS_PROPERTY_ACCESSOR;
    }
    return flags;
}
 
Example 2
Source File: RecompilableScriptFunctionData.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static int getDataFlags(final FunctionNode functionNode) {
    int flags = IS_CONSTRUCTOR;
    if (functionNode.isStrict()) {
        flags |= IS_STRICT;
    }
    if (functionNode.needsCallee()) {
        flags |= NEEDS_CALLEE;
    }
    if (functionNode.usesThis() || functionNode.hasEval()) {
        flags |= USES_THIS;
    }
    if (functionNode.isVarArg()) {
        flags |= IS_VARIABLE_ARITY;
    }
    if (functionNode.getKind() == FunctionNode.Kind.GETTER || functionNode.getKind() == FunctionNode.Kind.SETTER) {
        flags |= IS_PROPERTY_ACCESSOR;
    }
    return flags;
}
 
Example 3
Source File: RecompilableScriptFunctionData.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static int getDataFlags(final FunctionNode functionNode) {
    int flags = IS_CONSTRUCTOR;
    if (functionNode.isStrict()) {
        flags |= IS_STRICT;
    }
    if (functionNode.needsCallee()) {
        flags |= NEEDS_CALLEE;
    }
    if (functionNode.usesThis() || functionNode.hasEval()) {
        flags |= USES_THIS;
    }
    if (functionNode.isVarArg()) {
        flags |= IS_VARIABLE_ARITY;
    }
    if (functionNode.getKind() == FunctionNode.Kind.GETTER || functionNode.getKind() == FunctionNode.Kind.SETTER) {
        flags |= IS_PROPERTY_ACCESSOR;
    }
    return flags;
}
 
Example 4
Source File: RecompilableScriptFunctionData.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static String functionName(final FunctionNode fn) {
    if (fn.isAnonymous()) {
        return "";
    } else {
        final FunctionNode.Kind kind = fn.getKind();
        if (kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
            final String name = NameCodec.decode(fn.getIdent().getName());
            return name.substring(4); // 4 is "get " or "set "
        } else {
            return fn.getIdent().getName();
        }
    }
}
 
Example 5
Source File: RecompilableScriptFunctionData.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private static String functionName(final FunctionNode fn) {
    if (fn.isAnonymous()) {
        return "";
    }
    final FunctionNode.Kind kind = fn.getKind();
    if (kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        final String name = NameCodec.decode(fn.getIdent().getName());
        return name.substring(GET_SET_PREFIX_LENGTH);
    }
    return fn.getIdent().getName();
}
 
Example 6
Source File: RecompilableScriptFunctionData.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static String functionName(final FunctionNode fn) {
    if (fn.isAnonymous()) {
        return "";
    }
    final FunctionNode.Kind kind = fn.getKind();
    if (kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        final String name = NameCodec.decode(fn.getIdent().getName());
        return name.substring(GET_SET_PREFIX_LENGTH);
    }
    return fn.getIdent().getName();
}
 
Example 7
Source File: RecompilableScriptFunctionData.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static String functionName(final FunctionNode fn) {
    if (fn.isAnonymous()) {
        return "";
    } else {
        final FunctionNode.Kind kind = fn.getKind();
        if (kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
            final String name = NameCodec.decode(fn.getIdent().getName());
            return name.substring(4); // 4 is "get " or "set "
        } else {
            return fn.getIdent().getName();
        }
    }
}
 
Example 8
Source File: RecompilableScriptFunctionData.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static String functionName(final FunctionNode fn) {
    if (fn.isAnonymous()) {
        return "";
    }
    final FunctionNode.Kind kind = fn.getKind();
    if (kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        final String name = NameCodec.decode(fn.getIdent().getName());
        return name.substring(GET_SET_PREFIX_LENGTH);
    }
    return fn.getIdent().getName();
}
 
Example 9
Source File: RecompilableScriptFunctionData.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static String functionName(final FunctionNode fn) {
    if (fn.isAnonymous()) {
        return "";
    }
    final FunctionNode.Kind kind = fn.getKind();
    if (kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        final String name = NameCodec.decode(fn.getIdent().getName());
        return name.substring(GET_SET_PREFIX_LENGTH);
    }
    return fn.getIdent().getName();
}
 
Example 10
Source File: RecompilableScriptFunctionData.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static String functionName(final FunctionNode fn) {
    if (fn.isAnonymous()) {
        return "";
    }
    final FunctionNode.Kind kind = fn.getKind();
    if (kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        final String name = NameCodec.decode(fn.getIdent().getName());
        return name.substring(GET_SET_PREFIX_LENGTH);
    }
    return fn.getIdent().getName();
}
 
Example 11
Source File: RecompilableScriptFunctionData.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static String functionName(final FunctionNode fn) {
    if (fn.isAnonymous()) {
        return "";
    }
    final FunctionNode.Kind kind = fn.getKind();
    if (kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        final String name = NameCodec.decode(fn.getIdent().getName());
        return name.substring(GET_SET_PREFIX_LENGTH);
    }
    return fn.getIdent().getName();
}
 
Example 12
Source File: JSONWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    final boolean program = functionNode.isProgram();
    if (program) {
        return emitProgram(functionNode);
    }

    enterDefault(functionNode);
    final String name;
    if (functionNode.isDeclared()) {
        name = "FunctionDeclaration";
    } else {
        name = "FunctionExpression";
    }
    type(name);
    comma();

    property("id");
    final FunctionNode.Kind kind = functionNode.getKind();
    if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        nullValue();
    } else {
        functionNode.getIdent().accept(this);
    }
    comma();

    array("params", functionNode.getParameters());
    comma();

    arrayStart("defaults");
    arrayEnd();
    comma();

    property("rest");
    nullValue();
    comma();

    property("body");
    functionNode.getBody().accept(this);
    comma();

    property("generator", false);
    comma();

    property("expression", false);

    return leave();
}
 
Example 13
Source File: JSONWriter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    final boolean program = functionNode.isProgram();
    if (program) {
        return emitProgram(functionNode);
    }

    enterDefault(functionNode);
    final String name;
    if (functionNode.isDeclared()) {
        name = "FunctionDeclaration";
    } else {
        name = "FunctionExpression";
    }
    type(name);
    comma();

    property("id");
    final FunctionNode.Kind kind = functionNode.getKind();
    if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        nullValue();
    } else {
        functionNode.getIdent().accept(this);
    }
    comma();

    array("params", functionNode.getParameters());
    comma();

    arrayStart("defaults");
    arrayEnd();
    comma();

    property("rest");
    nullValue();
    comma();

    property("body");
    functionNode.getBody().accept(this);
    comma();

    property("generator", false);
    comma();

    property("expression", false);

    return leave();
}
 
Example 14
Source File: JSONWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    final boolean program = functionNode.isProgram();
    if (program) {
        return emitProgram(functionNode);
    }

    enterDefault(functionNode);
    final String name;
    if (functionNode.isDeclared()) {
        name = "FunctionDeclaration";
    } else {
        name = "FunctionExpression";
    }
    type(name);
    comma();

    property("id");
    final FunctionNode.Kind kind = functionNode.getKind();
    if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        nullValue();
    } else {
        functionNode.getIdent().accept(this);
    }
    comma();

    array("params", functionNode.getParameters());
    comma();

    arrayStart("defaults");
    arrayEnd();
    comma();

    property("rest");
    nullValue();
    comma();

    property("body");
    functionNode.getBody().accept(this);
    comma();

    property("generator", false);
    comma();

    property("expression", false);

    return leave();
}
 
Example 15
Source File: JSONWriter.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    final boolean program = functionNode.isProgram();
    if (program) {
        return emitProgram(functionNode);
    }

    enterDefault(functionNode);
    final String name;
    if (functionNode.isDeclared()) {
        name = "FunctionDeclaration";
    } else {
        name = "FunctionExpression";
    }
    type(name);
    comma();

    property("id");
    final FunctionNode.Kind kind = functionNode.getKind();
    if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        nullValue();
    } else {
        functionNode.getIdent().accept(this);
    }
    comma();

    array("params", functionNode.getParameters());
    comma();

    arrayStart("defaults");
    arrayEnd();
    comma();

    property("rest");
    nullValue();
    comma();

    property("body");
    functionNode.getBody().accept(this);
    comma();

    property("generator", false);
    comma();

    property("expression", false);

    return leave();
}
 
Example 16
Source File: JSONWriter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    final boolean program = functionNode.isProgram();
    if (program) {
        return emitProgram(functionNode);
    }

    enterDefault(functionNode);
    final String name;
    if (functionNode.isDeclared()) {
        name = "FunctionDeclaration";
    } else {
        name = "FunctionExpression";
    }
    type(name);
    comma();

    property("id");
    final FunctionNode.Kind kind = functionNode.getKind();
    if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        nullValue();
    } else {
        functionNode.getIdent().accept(this);
    }
    comma();

    array("params", functionNode.getParameters());
    comma();

    arrayStart("defaults");
    arrayEnd();
    comma();

    property("rest");
    nullValue();
    comma();

    property("body");
    functionNode.getBody().accept(this);
    comma();

    property("generator", false);
    comma();

    property("expression", false);

    return leave();
}
 
Example 17
Source File: JSONWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    final boolean program = functionNode.isProgram();
    if (program) {
        return emitProgram(functionNode);
    }

    enterDefault(functionNode);
    final String name;
    if (functionNode.isDeclared()) {
        name = "FunctionDeclaration";
    } else {
        name = "FunctionExpression";
    }
    type(name);
    comma();

    property("id");
    final FunctionNode.Kind kind = functionNode.getKind();
    if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        nullValue();
    } else {
        functionNode.getIdent().accept(this);
    }
    comma();

    array("params", functionNode.getParameters());
    comma();

    arrayStart("defaults");
    arrayEnd();
    comma();

    property("rest");
    nullValue();
    comma();

    property("body");
    functionNode.getBody().accept(this);
    comma();

    property("generator", false);
    comma();

    property("expression", false);

    return leave();
}
 
Example 18
Source File: JSONWriter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    final boolean program = functionNode.isProgram();
    if (program) {
        return emitProgram(functionNode);
    }

    enterDefault(functionNode);
    final String name;
    if (functionNode.isDeclared()) {
        name = "FunctionDeclaration";
    } else {
        name = "FunctionExpression";
    }
    type(name);
    comma();

    property("id");
    final FunctionNode.Kind kind = functionNode.getKind();
    if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        nullValue();
    } else {
        functionNode.getIdent().accept(this);
    }
    comma();

    array("params", functionNode.getParameters());
    comma();

    arrayStart("defaults");
    arrayEnd();
    comma();

    property("rest");
    nullValue();
    comma();

    property("body");
    functionNode.getBody().accept(this);
    comma();

    property("generator", false);
    comma();

    property("expression", false);

    return leave();
}
 
Example 19
Source File: JSONWriter.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    final boolean program = functionNode.isProgram();
    if (program) {
        return emitProgram(functionNode);
    }

    enterDefault(functionNode);
    final String name;
    if (functionNode.isDeclared()) {
        name = "FunctionDeclaration";
    } else {
        name = "FunctionExpression";
    }
    type(name);
    comma();

    property("id");
    final FunctionNode.Kind kind = functionNode.getKind();
    if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        nullValue();
    } else {
        functionNode.getIdent().accept(this);
    }
    comma();

    array("params", functionNode.getParameters());
    comma();

    arrayStart("defaults");
    arrayEnd();
    comma();

    property("rest");
    nullValue();
    comma();

    property("body");
    functionNode.getBody().accept(this);
    comma();

    property("generator", false);
    comma();

    property("expression", false);

    return leave();
}
 
Example 20
Source File: JSONWriter.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterFunctionNode(final FunctionNode functionNode) {
    final boolean program = functionNode.isProgram();
    if (program) {
        return emitProgram(functionNode);
    }

    enterDefault(functionNode);
    final String name;
    if (functionNode.isDeclared()) {
        name = "FunctionDeclaration";
    } else {
        name = "FunctionExpression";
    }
    type(name);
    comma();

    property("id");
    final FunctionNode.Kind kind = functionNode.getKind();
    if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
        nullValue();
    } else {
        functionNode.getIdent().accept(this);
    }
    comma();

    array("params", functionNode.getParameters());
    comma();

    arrayStart("defaults");
    arrayEnd();
    comma();

    property("rest");
    nullValue();
    comma();

    property("body");
    functionNode.getBody().accept(this);
    comma();

    property("generator", false);
    comma();

    property("expression", false);

    return leave();
}