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); }
private void SetName(DottedName importNames) { if (SetName(importNames as RelativeModuleName)) { return; } ImportedName = importNames.MakeString(); }
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)); }
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); } }
// DottedName public override bool Walk(DottedName node) { return(false); }
public CodeExpression VisitDottedName(DottedName d) { throw new NotImplementedException(); }
public void PostWalk(DottedName node) { PostProcess(node); }
public ImportDefinition(DottedName name, ImportStatement import) { this.name = name; this.importStatement = import; }
public virtual void PostWalk(DottedName node) { }
public override bool Walk(DottedName node) { writer.WriteLine("DottedName"); return(base.Walk(node)); }
// DottedName public virtual bool Walk(DottedName node) { return(true); }
public DataType VisitDottedName(DottedName name) { throw new NotImplementedException(); }
public AliasedName(DottedName orig, Identifier alias, string filename, int start, int end) : base(filename, start, end) { this.orig = orig; this.alias = alias; }
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); }
public void VisitDottedName(DottedName d) { throw new NotImplementedException(); }
public override void PostWalk(DottedName node) { }
// DottedName public override bool Walk(DottedName node) { return(Location >= node.StartIndex && Location <= node.EndIndex); }
// DottedName public virtual bool Walk(DottedName node) { return true; }
// DottedName public override bool Walk(DottedName node) { return Location >= node.StartIndex && Location <= node.EndIndex; }
// DottedName public override bool Walk(DottedName node) { return false; }
// DottedName public bool Walk(DottedName node) { return(Process(node)); }
public override bool Walk(DottedName node) => Save(node, base.Walk(node), _options.ImportNames);
public Decorator(DottedName dn, List<Argument> args, string filename, int start, int end) : base(filename, start, end) { this.className = dn; this.arguments = args; }