Class CompilerEnvirons


  • public class CompilerEnvirons
    extends java.lang.Object
    • Constructor Detail

      • CompilerEnvirons

        public CompilerEnvirons()
    • Method Detail

      • initFromContext

        public void initFromContext​(Context cx)
      • getErrorReporter

        public final ErrorReporter getErrorReporter()
      • setErrorReporter

        public void setErrorReporter​(ErrorReporter errorReporter)
      • getLanguageVersion

        public final int getLanguageVersion()
      • setLanguageVersion

        public void setLanguageVersion​(int languageVersion)
      • isGenerateDebugInfo

        public final boolean isGenerateDebugInfo()
      • setGenerateDebugInfo

        public void setGenerateDebugInfo​(boolean flag)
      • isReservedKeywordAsIdentifier

        public final boolean isReservedKeywordAsIdentifier()
      • setReservedKeywordAsIdentifier

        public void setReservedKeywordAsIdentifier​(boolean flag)
      • isAllowMemberExprAsFunctionName

        public final boolean isAllowMemberExprAsFunctionName()
        Extension to ECMA: if 'function <name>' is not followed by '(', assume <name> starts a memberExpr
      • setAllowMemberExprAsFunctionName

        public void setAllowMemberExprAsFunctionName​(boolean flag)
      • isXmlAvailable

        public final boolean isXmlAvailable()
      • setXmlAvailable

        public void setXmlAvailable​(boolean flag)
      • getOptimizationLevel

        public final int getOptimizationLevel()
      • setOptimizationLevel

        public void setOptimizationLevel​(int level)
      • isGeneratingSource

        public final boolean isGeneratingSource()
      • getWarnTrailingComma

        public boolean getWarnTrailingComma()
      • setWarnTrailingComma

        public void setWarnTrailingComma​(boolean warn)
      • isStrictMode

        public final boolean isStrictMode()
      • setStrictMode

        public void setStrictMode​(boolean strict)
      • reportWarningAsError

        public final boolean reportWarningAsError()
      • setGeneratingSource

        public void setGeneratingSource​(boolean generatingSource)
        Specify whether or not source information should be generated.

        Without source information, evaluating the "toString" method on JavaScript functions produces only "[native code]" for the body of the function. Note that code generated without source is not fully ECMA conformant.

      • isGenerateObserverCount

        public boolean isGenerateObserverCount()
        Returns:
        true iff code will be generated with callbacks to enable instruction thresholds
      • setGenerateObserverCount

        public void setGenerateObserverCount​(boolean generateObserverCount)
        Turn on or off generation of code with callbacks to track the count of executed instructions. Currently only affects JVM byte code generation: this slows down the generated code, but code generated without the callbacks will not be counted toward instruction thresholds. Rhino's interpretive mode does instruction counting without inserting callbacks, so there is no requirement to compile code differently.
        Parameters:
        generateObserverCount - if true, generated code will contain calls to accumulate an estimate of the instructions executed.
      • isRecordingComments

        public boolean isRecordingComments()
      • setRecordingComments

        public void setRecordingComments​(boolean record)
      • isRecordingLocalJsDocComments

        public boolean isRecordingLocalJsDocComments()
      • setRecordingLocalJsDocComments

        public void setRecordingLocalJsDocComments​(boolean record)
      • setRecoverFromErrors

        public void setRecoverFromErrors​(boolean recover)
        Turn on or off full error recovery. In this mode, parse errors do not throw an exception, and the parser attempts to build a full syntax tree from the input. Useful for IDEs and other frontends.
      • recoverFromErrors

        public boolean recoverFromErrors()
      • setIdeMode

        public void setIdeMode​(boolean ide)
        Puts the parser in "IDE" mode. This enables some slightly more expensive computations, such as figuring out helpful error bounds.
      • isIdeMode

        public boolean isIdeMode()
      • getActivationNames

        public java.util.Set<java.lang.String> getActivationNames()
      • setActivationNames

        public void setActivationNames​(java.util.Set<java.lang.String> activationNames)
      • setAllowSharpComments

        public void setAllowSharpComments​(boolean allow)
        Mozilla sources use the C preprocessor.
      • getAllowSharpComments

        public boolean getAllowSharpComments()
      • ideEnvirons

        public static CompilerEnvirons ideEnvirons()
        Returns a CompilerEnvirons suitable for using Rhino in an IDE environment. Most features are enabled by default. The ErrorReporter is set to an ErrorCollector.