Пример #1
0
        internal FunctionAnalysisUnit(
            UserFunctionValue function,
            AnalysisUnit declUnit,
            EnvironmentRecord declScope,
            IJsProjectEntry declEntry,
            EnvironmentRecord scope
        )
            : base(function.FunctionObject, declUnit.Tree, null) {
            _declUnit = declUnit;
            Function = function;

            _env = scope;
        }
Пример #2
0
        internal FunctionAnalysisUnit(
            UserFunctionValue function,
            AnalysisUnit declUnit,
            EnvironmentRecord declScope,
            IJsProjectEntry declEntry
        )
            : base(function.FunctionObject, declUnit.Tree, null) {
            _declUnit = declUnit;
            Function = function;

            var scope = new FunctionEnvironmentRecord(Function, this, Function.FunctionObject, declScope, declEntry);
            scope.EnsureParameters(this);
            _env = scope;
        }
        //public readonly GeneratorInfo Generator;

        public FunctionEnvironmentRecord(
            UserFunctionValue function,
            FunctionAnalysisUnit analysisUnit,
            Node node,
            EnvironmentRecord declScope,
            IJsProjectEntry declModule
        )
            : base(node, declScope) {
            _function = function;
            _this = new VariableDef();
            AnalysisUnit = analysisUnit;
#if FALSE
            if (Function.FunctionObject.IsGenerator) {
                Generator = new GeneratorInfo(function.ProjectState, declModule);
                ReturnValue.AddTypes(function.ProjectEntry, Generator.SelfSet, false);
            }
#endif
        }
Пример #4
0
        /// <summary>
        /// Parses the specified file on disk.
        /// </summary>
        /// <param name="filename"></param>
        private void EnqueueFile(IProjectEntry projEntry, string filename)
        {
            // get the current snapshot from the UI thread

            EnqueWorker(() => {
                for (int i = 0; i < 10; i++)
                {
                    try {
                        if (!File.Exists(filename))
                        {
                            break;
                        }

                        var cookie = new FileCookie(filename);
                        var reader = new StreamReader(
                            new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete)
                            );

                        using (reader) {
                            ParseFile(projEntry, filename, reader, cookie);
                        }
                        return;
                    } catch (IOException) {
                        // file being copied, try again...
                        Thread.Sleep(100);
                    } catch (UnauthorizedAccessException) {
                        // file is inaccessible, try again...
                        Thread.Sleep(100);
                    }
                }

                IJsProjectEntry pyEntry = projEntry as IJsProjectEntry;
                if (pyEntry != null)
                {
                    // failed to parse, keep the UpdateTree calls balanced
                    pyEntry.UpdateTree(null, null);
                }
            });
        }
Пример #5
0
 public static void Prepare(IJsProjectEntry entry, string code)
 {
     Prepare(entry, GetSourceUnit(code));
 }
 public static void Prepare(IJsProjectEntry entry, TextReader sourceUnit) {
     var parser = new JSParser(sourceUnit.ReadToEnd());
     var ast = parser.Parse(new CodeSettings());
     entry.UpdateTree(ast, null);
 }
 public static void Prepare(IJsProjectEntry entry, string code) {
     Prepare(entry, GetSourceUnit(code));
 }