Пример #1
0
 public override bool Walk(DottedName node)
 {
     if (base.Walk(node))
     {
         string totalName = null;
         foreach (var n in node.Names.MaybeEnumerate())
         {
             if (n?.Name == null)
             {
                 break;
             }
             if (Location >= n.StartIndex && Location <= n.EndIndex)
             {
                 if (totalName == null)
                 {
                     Expression = n;
                 }
                 else
                 {
                     Expression = new NameExpression(totalName + n.Name);
                     Expression.SetLoc(node.StartIndex, n.EndIndex);
                 }
                 break;
             }
             totalName = (totalName ?? "") + n.Name + ".";
         }
     }
     return(false);
 }
Пример #2
0
        private void SetName(DottedName importNames)
        {
            if (SetName(importNames as RelativeModuleName))
            {
                return;
            }

            ImportedName = importNames.MakeString();
        }
Пример #3
0
        public override bool Walk(DottedName node)
        {
            string totalName = "";

            foreach (var name in node.Names)
            {
                _head.Names.Add(Tuple.Create(totalName + name.Name, Span.FromBounds(name.StartIndex, name.EndIndex)));
                totalName += name.Name + ".";
            }
            return(base.Walk(node));
        }
Пример #4
0
        private static PythonNode Wrap(DottedName stmt, PythonNode parent)
        {
            var result = new DottedNameNode(stmt)
            {
                Parent = parent
            };

            if (stmt.Names != null)
            {
                result.Value = stmt.Names;
            }
            //result.AddChild(Wrap(stmt.Root));
            return(result);
        }
        private void AssignImportedVariables(IPythonModule module, DottedName moduleImportExpression, NameExpression asNameExpression)
        {
            // "import fob.oar as baz" is handled as
            // baz = import_module('fob.oar')
            if (asNameExpression != null)
            {
                Eval.DeclareVariable(asNameExpression.Name, module, asNameExpression);
                return;
            }

            // "import fob.oar" is handled as
            // import_module('fob.oar')
            // fob = import_module('fob')
            var importNames = moduleImportExpression.Names;

            PythonPackage pythonPackage = null;
            var           existingDepth = 0;

            var childPackage = Eval.GetInScope <PythonPackage>(importNames[0].Name);

            while (childPackage != null && existingDepth < importNames.Count - 1)
            {
                existingDepth++;
                pythonPackage = childPackage;
                childPackage  = pythonPackage.GetMember <PythonPackage>(importNames[existingDepth].Name);
            }

            var child = module;

            for (var i = importNames.Count - 2; i >= existingDepth; i--)
            {
                var childName  = importNames[i + 1].Name;
                var parentName = importNames[i].Name;
                var parent     = new PythonPackage(parentName, Eval.Services);
                parent.AddChildModule(childName, child);
                child = parent;
            }

            if (pythonPackage == null)
            {
                Eval.DeclareVariable(importNames[0].Name, child, importNames[0]);
            }
            else
            {
                pythonPackage.AddChildModule(importNames[existingDepth].Name, child);
            }
        }
Пример #6
0
 // DottedName
 public override bool Walk(DottedName node)
 {
     return(false);
 }
Пример #7
0
 public CodeExpression VisitDottedName(DottedName d)
 {
     throw new NotImplementedException();
 }
Пример #8
0
 public void PostWalk(DottedName node)
 {
     PostProcess(node);
 }
Пример #9
0
 public ImportDefinition(DottedName name, ImportStatement import)
 {
     this.name            = name;
     this.importStatement = import;
 }
Пример #10
0
 public virtual void PostWalk(DottedName node) { }
Пример #11
0
 public override bool Walk(DottedName node)
 {
     writer.WriteLine("DottedName");
     return(base.Walk(node));
 }
Пример #12
0
 // DottedName
 public virtual bool Walk(DottedName node)
 {
     return(true);
 }
Пример #13
0
 public DataType VisitDottedName(DottedName name)
 {
     throw new NotImplementedException();
 }
Пример #14
0
 public AliasedName(DottedName orig, Identifier alias, string filename, int start, int end)
     : base(filename, start, end)
 {
     this.orig = orig;
     this.alias = alias;
 }
Пример #15
0
 public AliasedName(Identifier orig, Identifier alias, string filename, int start, int end)
     : base(filename, start, end)
 {
     this.orig = new DottedName(new List<Identifier> {orig }, filename, start, end);
     this.alias = alias;
 }
 public override void PostWalk(DottedName node)
 {
     PostWalkWorker(node);
 }
 // DottedName
 public override bool Walk(DottedName node)
 {
     return(ShouldWalkWorker(node));
 }
Пример #18
0
 // DottedName
 public override bool Walk(DottedName node)
 {
     Reference(node.Names[0]);
     return(true);
 }
Пример #19
0
 public void VisitDottedName(DottedName d)
 {
     throw new NotImplementedException();
 }
Пример #20
0
 public override void PostWalk(DottedName node)
 {
 }
Пример #21
0
 // DottedName
 public override bool Walk(DottedName node)
 {
     return(Location >= node.StartIndex && Location <= node.EndIndex);
 }
Пример #22
0
 public void VisitDottedName(DottedName d)
 {
     throw new NotImplementedException();
 }
Пример #23
0
 public virtual void PostWalk(DottedName node)
 {
 }
Пример #24
0
 public override void PostWalk(DottedName node) { }
Пример #25
0
 // DottedName
 public virtual bool Walk(DottedName node) { return true; }
Пример #26
0
 // DottedName
 public override bool Walk(DottedName node) { return Location >= node.StartIndex && Location <= node.EndIndex; }
Пример #27
0
 // DottedName
 public override bool Walk(DottedName node) { return false; }
Пример #28
0
 // DottedName
 public bool Walk(DottedName node)
 {
     return(Process(node));
 }
Пример #29
0
 public override bool Walk(DottedName node) => Save(node, base.Walk(node), _options.ImportNames);
Пример #30
0
 public Decorator(DottedName dn, List<Argument> args, string filename, int start, int end)
     : base(filename, start, end)
 {
     this.className = dn;
     this.arguments = args;
 }