Exemple #1
0
        // ClassDefinition
        public override bool Walk(ClassDefinition node)
        {
            if (node.Name != null)
            {
                node.Variable = DefineName(node.Name);
                node.AddVariableReference(_globalScope, _bindRefs, Reference(node.Name));
            }

            if (node.Bases != null)
            {
                // Base references are in the outer context
                foreach (var b in node.Bases)
                {
                    b.Expression.Walk(this);
                }
            }

            // process the decorators in the outer context
            if (node.Decorators != null)
            {
                foreach (Expression dec in node.Decorators.Decorators)
                {
                    if (dec != null)
                    {
                        dec.Walk(this);
                    }
                }
            }

            PushScope(node);

            node.ModuleNameVariable = _globalScope.EnsureGlobalVariable("__name__");

            // define the __doc__ and the __module__
            if (node.Body.Documentation != null)
            {
                node.DocVariable = DefineName("__doc__");
            }
            node.ModVariable = DefineName("__module__");
            if (_langVersion.Is3x())
            {
                node.ClassVariable = DefineName("__class__");
            }

            // Walk the body
            node.Body.Walk(this);
            return(false);
        }
Exemple #2
0
        // ClassDefinition
        public override bool Walk(ClassDefinition node)
        {
            if (node.Name != null)
            {
                node.Variable = DefineName(node.Name);
                node.AddVariableReference(GlobalScope, BindReferences, Reference(node.Name));
            }

            // Base references are in the outer context
            foreach (var b in node.Bases)
            {
                b.Expression.Walk(this);
            }

            // process the decorators in the outer context
            foreach (var dec in (node.Decorators?.Decorators).MaybeEnumerate().ExcludeDefault())
            {
                dec.Walk(this);
            }

            PushScope(node);
            node.ModuleNameVariable = GlobalScope.EnsureGlobalVariable("__name__");

            // define the __doc__ and the __module__
            if (node.Body.Documentation != null)
            {
                node.DocVariable = DefineName("__doc__");
            }
            node.ModVariable = DefineName("__module__");
            if (LanguageVersion.Is3x())
            {
                node.ClassVariable = DefineName("__class__");
            }

            // Walk the body
            node.Body.Walk(this);
            return(false);
        }
Exemple #3
0
        // ClassDefinition
        public override bool Walk(ClassDefinition node) {
            if (node.Name != null) {
                node.Variable = DefineName(node.Name);
                node.AddVariableReference(_globalScope, _bindRefs, Reference(node.Name));
            }

            if (node.Bases != null) {
                // Base references are in the outer context
                foreach (var b in node.Bases) b.Expression.Walk(this);
            }

            // process the decorators in the outer context
            if (node.Decorators != null) {
                foreach (Expression dec in node.Decorators.Decorators) {
                    if (dec != null) {
                        dec.Walk(this);
                    }
                }
            }
            
            PushScope(node);

            node.ModuleNameVariable = _globalScope.EnsureGlobalVariable("__name__");

            // define the __doc__ and the __module__
            if (node.Body.Documentation != null) {
                node.DocVariable = DefineName("__doc__");
            }
            node.ModVariable = DefineName("__module__");
            if (_langVersion.Is3x()) {
                node.ClassVariable = DefineName("__class__");
            }

            // Walk the body
            node.Body.Walk(this);
            return false;
        }