static private void errInfoSetter(object val, uint id, GlobalEntry gb, NetRuby rb) { RThread th = rb.GetCurrentContext(); if (val != null) { RBasic b = rb.InstanceOf(val); if (b.IsKindOf(rb.eException) == false) throw new eTypeError("assigning non-exception to $!"); } th.errInfo = (RException)val; }
static private void iCaseSetter(object val, uint id, GlobalEntry gb, NetRuby rb) { rb.cRegexp.IsIgnoreCase = RBasic.RTest(val); }
static private void kCodeSetter(object val, uint id, GlobalEntry gb, NetRuby rb) { }
static private object matchGetter(uint id, GlobalEntry gb, NetRuby rb) { RThread th = rb.GetCurrentContext(); object o = th.BackRef; matchBusy(o); return o; }
static private object lastParenGetter(uint id, GlobalEntry gb, NetRuby rb) { RThread th = rb.GetCurrentContext(); RMatchData m = (RMatchData)th.BackRef; if (m == null) return null; string s = m.Last; if (m.IsTainted) return new RString(rb, s, true); return s; }
internal object GVarSet(GlobalEntry entry, object o) { RThread th = GetCurrentContext(); /*if (th.safeLevel >= 4) { throw new SecurityException("Insecure: can't change global variable value"); }*/ lock (entry) { entry.SetValue(o, this); } // trace return o; }
protected RNGAsgn(uint v, GlobalEntry e) : base(null, v, null) { ent = e; }
static internal object lastLineGetter(uint i, GlobalEntry gb, NetRuby rb) { /* RThread th = rb.GetCurrentContext(); if (th.scope.local_vars != null) { return th.scope.local_vars[0]; } */ return null; }
static private void lastLineSetter(object val, uint i, GlobalEntry gb, NetRuby rb) { /* RThread th = rb.GetCurrentContext(); if (th.scope.local_vars != null) { th.scope.local_vars[0] = val.ToString(); } else { } */ }
static private object debugGetter(uint i, GlobalEntry gb, NetRuby rb) { return rb.debug; }
static private void debugSetter(object val, uint i, GlobalEntry gb, NetRuby rb) { if (val == null) rb.debug = false; else if (val is bool) rb.debug = (bool)val; else rb.debug = true; }
static private void verboseSetter(object val, uint i, GlobalEntry gb, NetRuby rb) { if (val == null) rb.verbose = false; else if (val is bool) rb.verbose = (bool)val; else rb.verbose = true; }
/* static private object safeGetter(uint i, GlobalEntry gb, NetRuby rb) { return rb.GetCurrentContext().safeLevel; } static private void safeSetter(object val, uint i, GlobalEntry gb, NetRuby rb) { int level = RInteger.ToInt(rb, val); RThread th = rb.GetCurrentContext(); if (level < th.safeLevel) throw new SecurityException(String.Format("tried to downgrade safe level from {0} to {1}", th.safeLevel, level)); th.safeLevel = level; } */ static private object verboseGetter(uint i, GlobalEntry gb, NetRuby rb) { return rb.verbose; }
static private object errInfoGetter(uint i, GlobalEntry gb, NetRuby rb) { RThread th = rb.GetCurrentContext(); return th.errInfo; }
internal void DefineVirtualVariable(string name, GlobalEntry.Getter gtr, GlobalEntry.Setter str) { DefineVariable(name, null, gtr, str); }
static private object printGetter(uint i, GlobalEntry gb, NetRuby rb) { return rb.doPrint; }
internal void DefineReadonlyVariable(string name, object obj, GlobalEntry.Getter gtr) { GlobalEntry ent = global_entry(global_id(name)); lock (ent) { ent.data = obj; ent.ReplaceGetter(gtr); ent.ReplaceSetter(new GlobalEntry.Setter(GlobalEntry.ReadonlySetter)); } }
static private object splitGetter(uint i, GlobalEntry gb, NetRuby rb) { return rb.doSplit; }
internal object GVarGet(GlobalEntry entry) { return entry.GetValue(this); }
static private object lineGetter(uint i, GlobalEntry gb, NetRuby rb) { return rb.doLine; }
internal RNGVar(uint v, GlobalEntry ent) : base(v, ent) { }
static private object argvGetter(uint i, GlobalEntry gb, NetRuby rb) { return rb.argv; }
static private void matchSetter(object val, uint id, GlobalEntry gb, NetRuby rb) { rb.CheckType(val, typeof(RMatchData)); RThread th = rb.GetCurrentContext(); th.BackRef = val; }
static private void SetArg0(object val, uint i, GlobalEntry gb, NetRuby rb) { }
static private object iCaseGetter(uint id, GlobalEntry gb, NetRuby rb) { return rb.cRegexp.ignoreCase; }
internal GlobalEntry global_entry(uint id) { object o; GlobalEntry ret = null; lock (global_tbl.SyncRoot) { if (global_tbl.lookup(id, out o)) ret = (GlobalEntry)o; else { ret = new GlobalEntry(id); global_tbl.Add(id, ret); } } return ret; }
static private object kCodeGetter(uint id, GlobalEntry gb, NetRuby rb) { return "none"; }
/* internal void CloneGenericIVar(RBasic clone, RBasic obj) { if (generic_iv_tbl == null) return; lock (generic_iv_tbl.SyncRoot) { if (generic_iv_tbl.ContainsKey(obj)) { st_table tbl = (st_table)generic_iv_tbl[obj]; generic_iv_tbl[clone] = tbl.Clone(); } } } internal bool IsGenericIVarDefined(RBasic obj, uint id) { if (generic_iv_tbl == null) return false; st_table tbl = null; if (generic_iv_tbl.lookup(obj, out tbl) == false) return false; object val; return tbl.lookup(id, out val); } internal object GenericIVarGet(RBasic obj, uint id) { if (generic_iv_tbl == null) return null; st_table tbl = null; if (generic_iv_tbl.lookup(obj, out tbl) == false) return null; object val; if (tbl.lookup(id, out val)) return val; return null; } internal void GenericIVarSet(RBasic obj, uint id, object val) { if (generic_iv_tbl == null) { lock (this) { if (generic_iv_tbl == null) { generic_iv_tbl = new st_table(); } } } st_table tbl = null; lock (generic_iv_tbl.SyncRoot) { if (generic_iv_tbl.lookup(obj, out tbl) == false) { tbl = new st_table(); generic_iv_tbl[obj] = tbl; } tbl[id] = val; } } internal object GenericIVarRemove(RBasic obj, uint id) { if (generic_iv_tbl == null) return null; st_table tbl; if (generic_iv_tbl.lookup(obj, out tbl) == false) return null; object val = tbl[id]; lock (tbl.SyncRoot) { tbl.Remove(id); if (tbl.Count == 0) { generic_iv_tbl.Remove(obj); } } return val; } */ public void DefineVariable(string name, object obj, GlobalEntry.Getter gtr, GlobalEntry.Setter str) { GlobalEntry ent = global_entry(global_id(name)); lock (ent) { ent.data = obj; ent.ReplaceGetter(gtr); ent.ReplaceSetter(str); } }
public void Write(GlobalEntry n) { Write("<GlobalEntry>"); }
static private void errAtSetter(object val, uint id, GlobalEntry gb, NetRuby rb) { RThread th = rb.GetCurrentContext(); if (th.errInfo == null) { throw new ArgumentException("$! not set"); } RException.exc_set_backtrace(th.errInfo, val); }