Ejemplo n.º 1
0
        public virtual object CreateCompileUnit(string script)
        {
            var parser  = new Esprima.JavaScriptParser(script);
            var program = parser.ParseProgram();

            return(program);
        }
        protected override IPrecompiledScript InnerPrecompile(string code, string documentName)
        {
            OriginalProgram       program;
            string                uniqueDocumentName = _documentNameManager.GetUniqueName(documentName);
            OriginalParserOptions parserOptions      = CreateParserOptions(uniqueDocumentName);

            try
            {
                var parser = new OriginalParser(code, parserOptions);
                program = parser.ParseProgram();
            }
            catch (OriginalParserException e)
            {
                throw WrapParserException(e);
            }

            return(new JintPrecompiledScript(program));
        }
Ejemplo n.º 3
0
        public virtual object CreateCompileUnit(string script,
                                                out bool isExpression)
        {
            try
            {
                isExpression = false;

                var parser  = new Esprima.JavaScriptParser(script);
                var program = parser.ParseProgram();

                isExpression = this.IsExpression(program);

                return(program);
            }
            catch (Exception ex)
            {
                throw new ScriptingException($"Javascript parse error occurs: {ex.Message}.", ex);
            }
        }