internal P5SymbolTable GetPackage(Runtime runtime, string[] packs, bool skip_last, bool create) { P5SymbolTable current = this; IP5Any value; int last = packs.Length + (skip_last ? -1 : 0); int first = 0; if (IsMain && last > 0 && (packs[0] == "main" || packs[0] == "")) first = 1; for (int i = first; i < last; ++i) { if (!current.hash.TryGetValue(packs[i] + "::", out value)) { if (!create) return null; var name = string.Join("::", packs, 0, i - first + 1); P5Typeglob glob = new P5Typeglob( runtime, string.Join("::", packs)); glob.Hash = new P5SymbolTable(runtime, name); current.hash.Add(packs[i] + "::", glob); value = glob; } current = (value as P5Typeglob).Hash as P5SymbolTable; } return current; }
protected virtual void ApplyMagic(Runtime runtime, string name, P5Typeglob symbol) { if (name.Length == 0 || name[0] == '0') return; for (int i = 0; i < name.Length; ++i) if (!char.IsDigit(name[i])) return; symbol.Scalar = new P5Capture(runtime, int.Parse(name)); }
public P5Typeglob GetStashGlob(Runtime runtime, string name, bool create) { IP5Any value; if (!hash.TryGetValue(name, out value) && create) { P5Typeglob glob = new P5Typeglob( runtime, this.name + "::" + name); ApplyMagic(runtime, name, glob); hash.Add(name, glob); value = glob; } return value as P5Typeglob; }