Пример #1
0
        internal static ClassInfo AddClass(ClassDefinition node, AnalysisUnit outerUnit)
        {
            InterpreterScope scope;

            if (!outerUnit.DeclaringModule.NodeScopes.TryGetValue(node, out scope))
            {
                if (node.Body == null || node.Name == null)
                {
                    return(null);
                }

                var scopes = new InterpreterScope[outerUnit.Scopes.Length + 1];
                outerUnit.Scopes.CopyTo(scopes, 0);

                var unit       = new ClassAnalysisUnit(node, scopes);
                var klass      = new ClassInfo(unit);
                var classScope = scope = klass.Scope;

                var declScope = outerUnit.Scopes[outerUnit.Scopes.Length - 1];
                declScope.SetVariable(node, unit, node.Name, klass.SelfSet);

                declScope.Children.Add(classScope);
                scopes[scopes.Length - 1] = classScope;
                outerUnit.DeclaringModule.NodeScopes[node] = scope;

                unit.Enqueue();
            }
            return(scope.Namespace as ClassInfo);
        }
Пример #2
0
        protected override void AnalyzeWorker(DDG ddg, CancellationToken cancel)
        {
            ddg.SetCurrentUnit(this);

            InterpreterScope scope;

            if (!ddg.Scope.TryGetNodeScope(Ast, out scope))
            {
                return;
            }

            var classInfo = ((ClassScope)scope).Class;
            var bases     = ClassAnalysisUnit.EvaluateBaseClass(
                ddg,
                classInfo,
                _indexInBasesList,
                _baseClassNode
                );

            classInfo.SetBase(_indexInBasesList, bases);

            _outerUnit.Enqueue();
        }