示例#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;
 }
 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));
 }
 // 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)
 {
 }
 public override void PostWalk(DottedName node) { }
 // 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; }
 // 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
文件: Decorator.cs 项目: uxmal/pytocs
 public Decorator(DottedName dn, List<Argument> args, string filename, int start, int end)
     : base(filename, start, end)
 {
     this.className = dn;
     this.arguments = args;
 }