org.mozilla.javascript.Context.getLanguageVersion()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 JavaScript  
字(8.9k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中org.mozilla.javascript.Context.getLanguageVersion()方法的一些代码示例,展示了Context.getLanguageVersion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getLanguageVersion()方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:getLanguageVersion

Context.getLanguageVersion介绍

[英]Get the current language version.

The language version number affects JavaScript semantics as detailed in the overview documentation.
[中]获取当前语言版本。
语言版本号影响JavaScript语义,详见概述文档。

代码示例

代码示例来源:origin: geogebra/geogebra

@Override
public Object getDefaultValue(Class<?> hint)
{
  if (hint == ScriptRuntime.NumberClass) {
    Context cx = Context.getContext();
    if (cx.getLanguageVersion() == Context.VERSION_1_2)
      return Long.valueOf(length);
  }
  return super.getDefaultValue(hint);
}

代码示例来源:origin: com.github.tntim96/rhino

@Override
public Object getDefaultValue(Class<?> hint)
{
  if (hint == ScriptRuntime.NumberClass) {
    Context cx = Context.getContext();
    if (cx.getLanguageVersion() == Context.VERSION_1_2)
      return Long.valueOf(length);
  }
  return super.getDefaultValue(hint);
}

代码示例来源:origin: ro.isdc.wro4j/rhino

@Override
public Object getDefaultValue(Class<?> hint)
{
  if (hint == ScriptRuntime.NumberClass) {
    Context cx = Context.getContext();
    if (cx.getLanguageVersion() == Context.VERSION_1_2)
      return Long.valueOf(length);
  }
  return super.getDefaultValue(hint);
}

代码示例来源:origin: rhino/js

@Override
public Object getDefaultValue(Class<?> hint)
{
  if (hint == ScriptRuntime.NumberClass) {
    Context cx = Context.getContext();
    if (cx.getLanguageVersion() == Context.VERSION_1_2)
      return new Long(length);
  }
  return super.getDefaultValue(hint);
}

代码示例来源:origin: io.apigee/rhino

@Override
public Object getDefaultValue(Class<?> hint)
{
  if (hint == ScriptRuntime.NumberClass) {
    Context cx = Context.getContext();
    if (cx.getLanguageVersion() == Context.VERSION_1_2)
      return Long.valueOf(length);
  }
  return super.getDefaultValue(hint);
}

代码示例来源:origin: com.sun.phobos/phobos-rhino

public Object getDefaultValue(Class hint)
{
  if (hint == ScriptRuntime.NumberClass) {
    Context cx = Context.getContext();
    if (cx.getLanguageVersion() == Context.VERSION_1_2)
      return new Long(length);
  }
  return super.getDefaultValue(hint);
}

代码示例来源:origin: org.zkoss.maven/yuicompressor-maven-plugin-zk

/**
 * Get and set the language version.
 *
 * This method is defined as a JavaScript function.
 */
public static double version(Context cx, Scriptable thisObj, Object[] args, Function funObj) {
  double result = cx.getLanguageVersion();
  if (args.length > 0) {
    double d = Context.toNumber(args[0]);
    cx.setLanguageVersion((int) d);
  }
  return result;
}

代码示例来源:origin: com.github.tntim96/rhino

/**
 * Get and set the language version.
 *
 * This method is defined as a JavaScript function.
 */
public static double version(Context cx, Scriptable thisObj,
               Object[] args, Function funObj)
{
  double result = cx.getLanguageVersion();
  if (args.length > 0) {
    double d = Context.toNumber(args[0]);
    cx.setLanguageVersion((int) d);
  }
  return result;
}

代码示例来源:origin: ro.isdc.wro4j/rhino

/**
 * Get and set the language version.
 *
 * This method is defined as a JavaScript function.
 */
public static double version(Context cx, Scriptable thisObj,
               Object[] args, Function funObj)
{
  double result = cx.getLanguageVersion();
  if (args.length > 0) {
    double d = Context.toNumber(args[0]);
    cx.setLanguageVersion((int) d);
  }
  return result;
}

代码示例来源:origin: rhino/js

static void checkDeprecated(Context cx, String name) {
  int version = cx.getLanguageVersion();
  if (version >= Context.VERSION_1_4 || version == Context.VERSION_DEFAULT) {
    String msg = getMessage1("msg.deprec.ctor", name);
    if (version == Context.VERSION_DEFAULT)
      Context.reportWarning(msg);
    else
      throw Context.reportRuntimeError(msg);
  }
}

代码示例来源:origin: io.apigee/rhino

static void checkDeprecated(Context cx, String name) {
  int version = cx.getLanguageVersion();
  if (version >= Context.VERSION_1_4 || version == Context.VERSION_DEFAULT) {
    String msg = getMessage1("msg.deprec.ctor", name);
    if (version == Context.VERSION_DEFAULT)
      Context.reportWarning(msg);
    else
      throw Context.reportRuntimeError(msg);
  }
}

代码示例来源:origin: com.sun.phobos/phobos-rhino

static void checkDeprecated(Context cx, String name) {
  int version = cx.getLanguageVersion();
  if (version >= Context.VERSION_1_4 || version == Context.VERSION_DEFAULT) {
    String msg = getMessage1("msg.deprec.ctor", name);
    if (version == Context.VERSION_DEFAULT)
      Context.reportWarning(msg);
    else
      throw Context.reportRuntimeError(msg);
  }
}

代码示例来源:origin: geogebra/geogebra

static void checkDeprecated(Context cx, String name) {
  int version = cx.getLanguageVersion();
  if (version >= Context.VERSION_1_4 || version == Context.VERSION_DEFAULT) {
    String msg = getMessage1("msg.deprec.ctor", name);
    if (version == Context.VERSION_DEFAULT)
      Context.reportWarning(msg);
    else
      throw Context.reportRuntimeError(msg);
  }
}

代码示例来源:origin: com.github.tntim96/rhino

static void checkDeprecated(Context cx, String name) {
  int version = cx.getLanguageVersion();
  if (version >= Context.VERSION_1_4 || version == Context.VERSION_DEFAULT) {
    String msg = getMessage1("msg.deprec.ctor", name);
    if (version == Context.VERSION_DEFAULT)
      Context.reportWarning(msg);
    else
      throw Context.reportRuntimeError(msg);
  }
}

代码示例来源:origin: ro.isdc.wro4j/rhino

static void checkDeprecated(Context cx, String name) {
  int version = cx.getLanguageVersion();
  if (version >= Context.VERSION_1_4 || version == Context.VERSION_DEFAULT) {
    String msg = getMessage1("msg.deprec.ctor", name);
    if (version == Context.VERSION_DEFAULT)
      Context.reportWarning(msg);
    else
      throw Context.reportRuntimeError(msg);
  }
}

代码示例来源:origin: rhino/js

/**
 * See ECMA 15.4.1,2
 */
private static Object jsConstructor(Context cx, Scriptable scope,
                  Object[] args)
{
  if (args.length == 0)
    return new NativeArray(0);
  // Only use 1 arg as first element for version 1.2; for
  // any other version (including 1.3) follow ECMA and use it as
  // a length.
  if (cx.getLanguageVersion() == Context.VERSION_1_2) {
    return new NativeArray(args);
  } else {
    Object arg0 = args[0];
    if (args.length > 1 || !(arg0 instanceof Number)) {
      return new NativeArray(args);
    } else {
      long len = ScriptRuntime.toUint32(arg0);
      if (len != ((Number)arg0).doubleValue())
        throw Context.reportRuntimeError0("msg.arraylength.bad");
      return new NativeArray(len);
    }
  }
}

代码示例来源:origin: com.sun.phobos/phobos-rhino

public void initFromContext(Context cx)
{
  setErrorReporter(cx.getErrorReporter());
  this.languageVersion = cx.getLanguageVersion();
  useDynamicScope = cx.compileFunctionsWithDynamicScopeFlag;
  generateDebugInfo = (!cx.isGeneratingDebugChanged()
             || cx.isGeneratingDebug());
  reservedKeywordAsIdentifier
    = cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER);
  allowMemberExprAsFunctionName
    = cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME);
  strictMode
    = cx.hasFeature(Context.FEATURE_STRICT_MODE);
  warningAsError = cx.hasFeature(Context.FEATURE_WARNING_AS_ERROR);
  xmlAvailable
    = cx.hasFeature(Context.FEATURE_E4X);
  optimizationLevel = cx.getOptimizationLevel();
  generatingSource = cx.isGeneratingSource();
  activationNames = cx.activationNames;
}

代码示例来源:origin: rhino/js

public void initFromContext(Context cx)
{
  setErrorReporter(cx.getErrorReporter());
  this.languageVersion = cx.getLanguageVersion();
  useDynamicScope = cx.compileFunctionsWithDynamicScopeFlag;
  generateDebugInfo = (!cx.isGeneratingDebugChanged()
             || cx.isGeneratingDebug());
  reservedKeywordAsIdentifier
    = cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER);
  allowMemberExprAsFunctionName
    = cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME);
  strictMode
    = cx.hasFeature(Context.FEATURE_STRICT_MODE);
  warningAsError = cx.hasFeature(Context.FEATURE_WARNING_AS_ERROR);
  xmlAvailable
    = cx.hasFeature(Context.FEATURE_E4X);
  optimizationLevel = cx.getOptimizationLevel();
  generatingSource = cx.isGeneratingSource();
  activationNames = cx.activationNames;
  
  // Observer code generation in compiled code :
  generateObserverCount = cx.generateObserverCount;
}

代码示例来源:origin: geogebra/geogebra

public void initFromContext(Context cx)
{
  setErrorReporter(cx.getErrorReporter());
  languageVersion = cx.getLanguageVersion();
  generateDebugInfo = (!cx.isGeneratingDebugChanged()
             || cx.isGeneratingDebug());
  reservedKeywordAsIdentifier
    = cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER);
  allowMemberExprAsFunctionName
    = cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME);
  strictMode
    = cx.hasFeature(Context.FEATURE_STRICT_MODE);
  warningAsError = cx.hasFeature(Context.FEATURE_WARNING_AS_ERROR);
  xmlAvailable
    = cx.hasFeature(Context.FEATURE_E4X);
  optimizationLevel = cx.getOptimizationLevel();
  generatingSource = cx.isGeneratingSource();
  activationNames = cx.activationNames;
  // Observer code generation in compiled code :
  generateObserverCount = cx.generateObserverCount;
}

代码示例来源:origin: ro.isdc.wro4j/rhino

public void initFromContext(Context cx)
{
  setErrorReporter(cx.getErrorReporter());
  languageVersion = cx.getLanguageVersion();
  generateDebugInfo = (!cx.isGeneratingDebugChanged()
             || cx.isGeneratingDebug());
  reservedKeywordAsIdentifier
    = cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER);
  allowMemberExprAsFunctionName
    = cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME);
  strictMode
    = cx.hasFeature(Context.FEATURE_STRICT_MODE);
  warningAsError = cx.hasFeature(Context.FEATURE_WARNING_AS_ERROR);
  xmlAvailable
    = cx.hasFeature(Context.FEATURE_E4X);
  optimizationLevel = cx.getOptimizationLevel();
  generatingSource = cx.isGeneratingSource();
  activationNames = cx.activationNames;
  // Observer code generation in compiled code :
  generateObserverCount = cx.generateObserverCount;
}

相关文章

微信公众号

Context类方法