void WriteGeneral(P6any obj) { if (FailSoft && !(obj is P6opaque)) { o.AppendFormat("\"UNSERIALIZABLE {0}\"", obj.mo.name); return; } int a = nextanchor++; anchors[obj] = a; P6opaque dyo = (P6opaque)obj; STable mo = dyo.mo; o.Append('{'); contUsed = true; o.AppendFormat("\"&\":\"A{0}\",\"!\":", a); WriteStr(true, "!perl6/" + mo.name); for (int i = 0; i < mo.nslots; i++) { o.Append(','); WriteStr(true, mo.all_slot[i]); o.Append(':'); WriteObj(((Variable)dyo.slots[i]).Fetch()); } o.Append('}'); }
/// <summary> /// Returns the file that has the given id. /// </summary> public static HashFile FindFileById(int fileId) { var data = DataHolder.DeviceData.CurrentDevice.FileSystem; HashFile file = STable.Find(data.AllFiles, fileId); return(file); }
/// <summary> /// Returns the dir that has the given id. /// </summary> public static HashDir FindDirById(int dirId) { var data = DataHolder.DeviceData.CurrentDevice.FileSystem; var dir = STable.Find(data.AllDirectories, dirId); return(dir); }
static public Int64 Insert(ELogisticsDriverLog eLogDriver) { var table = new STable(SharedLibDefines.TableLogisticsDriversLogs); eLogDriver.creationDateUTC = DateTime.UtcNow; return(table.Insert(eLogDriver)); }
public static FileSystemData GetFileSystemFromSerializedData(SerializedFileSystem serializedFileSystem) { var fileSystemData = new FileSystemData(); fileSystemData.AllDirectories = STable.Create <int, HashDir>(serializedFileSystem.Dirs.Length, true); var dirs = serializedFileSystem.Dirs; for (int i = 0; i < dirs.Length; i++) { var serializedDir = dirs[i]; var dir = GetDirFromSerializedData(serializedDir); fileSystemData.AllDirectories[dir.DirId] = dir; } var files = serializedFileSystem; fileSystemData.AllFiles = STable.Create <int, HashFile>(files.ImageFiles.Length + files.TextFiles.Length, true); for (int i = 0; i < files.TextFiles.Length; i++) { var txtFile = files.TextFiles[i]; var file = GetTextFileFromSerializedData(txtFile); fileSystemData.AllFiles[file.FileId] = file; } for (int i = 0; i < files.ImageFiles.Length; i++) { var imgFile = files.ImageFiles[i]; var file = GetImageFileFromSerializedData(imgFile); fileSystemData.AllFiles[file.FileId] = file; } return(fileSystemData); }
static void Main(string[] args) { STable c = new STable(); object o = c.getString("a", "A", 1); PrintObj(o); System.Console.In.ReadLine(); }
SList <TreeInfo> Info(STable tb, SList <long> cols) { if (cols == null) { return(SList <TreeInfo> .Empty); } return(Info(tb, cols.next).InsertAt(new TreeInfo(tb.cols.Lookup(cols.element).name, 'D', 'D'), 0)); }
public User(int id, STable s, int nRow, TextWriter logger, int seed) { this.id = id; this.s = s; this.nRow = nRow; this.logger = logger; r = new Random(seed); }
// END CUT HERE // BEGIN CUT HERE public static void Main() { STable ___test = new STable(); ___test.run_test(-1); try { } catch(Exception e) { //Console.WriteLine(e.StackTrace); Console.WriteLine(e.ToString()); } }
// END CUT HERE // BEGIN CUT HERE public static void Main() { STable ___test = new STable(); ___test.run_test(-1); try { } catch (Exception e) { //Console.WriteLine(e.StackTrace); Console.WriteLine(e.ToString()); } }
public SDatabase Install(SDrop d, long c) { var obs = objects; if (d.uid >= STransaction._uid) { obs = obs + (d.uid, d); } if (d.parent == 0) { var nms = names; var ot = objects[d.drpos]; switch (ot.type) { case Types.STable: nms = nms - ((STable)ot).name; break; case Types.SIndex: { var x = (SIndex)ot; var tb = (STable)objects[x.table]; tb = new STable(tb, tb.indexes - x.uid); obs = obs + (tb.uid, tb); break; } default: break; } return(New(obs - d.drpos, nms, c)); } else { var ot = (STable)objects[d.parent]; var nt = ot.Remove(d.drpos); return(New(obs + (d.parent, nt), names, c)); } }
public SDatabase Install(SAlter a, long c) { var obs = objects; if (a.uid >= STransaction._uid) { obs += (a.uid, a); } if (a.parent == 0) { var ot = (STable)obs[a.defpos]; var nt = new STable(ot, a.name); return(New(obs + (a.defpos, nt), names - ot.name + (a.name, nt), c)); } else { var ot = (STable)objects[a.parent]; var oc = (SColumn)ot.cols[a.defpos]; var nc = new SColumn(oc, a.name, a.dataType); var nt = ot + nc; return(New(obs + (a.defpos, nt), names + (a.name, nt), c)); } }
//=====================================================GETS ABOVE===================================================== #region Insert static public Int64 Insert(string content, Int64?tripID = null, Int64?userID = null, Int64?driverID = null, bool insertIntoServerErrorsTable = false) { try { EServerLog eLogServer = new EServerLog { creationDate = DateTime.UtcNow, content = content, //tripID = tripID, //userID = userID, //driverID = driverID }; STable table = new STable(SharedLibDefines.TableServerLogs); //SLogger.LogDebug("(SLogsServer)Insert." + content); var id = table.Insert(eLogServer); if (insertIntoServerErrorsTable) { StringBuilder errorBuilder = new StringBuilder(); if (tripID.HasValue) { errorBuilder.Append("TripID:" + tripID.ToString() + "."); } if (userID.HasValue) { errorBuilder.Append("UserID:" + userID.ToString() + "."); } if (driverID.HasValue) { errorBuilder.Append("DriverID:" + driverID.ToString() + "."); } errorBuilder.Append(content); SErrorsService.Insert(errorBuilder.ToString()); } return(id); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } return(0); }
public static Lexer GetLexer(Frame fromf, STable kl, LAD[] lads, string title) { LexerCache lc = kl.GetLexerCache(); Lexer ret; if (lc.nfas.TryGetValue(lads, out ret)) return ret; if (lc.parent != null && lc.parent.mo.name != "Cursor" && lc.parent.mo.name != "Any") { ret = GetLexer(fromf, lc.parent.mo, lads, title); foreach (string u in ret.pad.used_methods) { if (lc.repl_methods.Contains(u)) goto anew; } if (LtmTrace) Console.WriteLine("Reused {0} alternation lexer for {1} in {2}", title, lc.parent.mo.name, kl.name); return lc.nfas[lads] = ret; } anew: if (LtmTrace) { Console.WriteLine("Need new alternation lexer for {0} in {1}", title, kl.name); } NFA pad = new NFA(); pad.cursor_class = kl; LAD[] lads_p = new LAD[lads.Length]; pad.outer_stack.Add(fromf); pad.info_stack.Add(fromf.info); for (int i = 0; i < lads_p.Length; i++) lads_p[i] = lads[i].Reify(pad); ret = new Lexer(pad, title, lads_p); lc.nfas[lads] = ret; return ret; }
static public Int64 Insert(ECompanyAdminUserLog eLog) { var table = new STable(SharedLibDefines.TableCompaniesAdminUsersLogs); return(table.Insert(eLog)); }
public static Lexer GetDispatchLexer(STable kl, SubInfo disp) { LexerCache lc = kl.GetLexerCache(); Lexer ret; if (lc.dispatch_nfas.TryGetValue(disp, out ret)) return ret; if (lc.parent != null && lc.parent.mo.name != "Cursor" && lc.parent.mo.name != "Any") { ret = GetDispatchLexer(lc.parent.mo, disp); foreach (string u in ret.pad.used_methods) { if (lc.repl_methods.Contains(u)) goto anew; } if (LtmTrace) Console.WriteLine("Reused {0} dispatch lexer for {1} in {2}", disp.name, lc.parent.mo.name, kl.name); return lc.dispatch_nfas[disp] = ret; } anew: if (LtmTrace) { Console.WriteLine("Need new dispatch lexer for {0} in {1}", disp.name, kl.name); } NFA pad = new NFA(); pad.cursor_class = kl; P6any[] cands = (P6any[])disp.param[0]; LAD[] lads_p = new LAD[cands.Length]; for (int i = 0; i < lads_p.Length; i++) { pad.outer_stack.Add(Kernel.GetOuter(cands[i])); pad.info_stack.Add(Kernel.GetInfo(cands[i])); lads_p[i] = pad.info_stack[0].ltm.Reify(pad); pad.outer_stack.RemoveAt(pad.outer_stack.Count - 1); pad.info_stack.RemoveAt(pad.info_stack.Count - 1); } ret = new Lexer(pad, disp.name, lads_p); lc.dispatch_nfas[disp] = ret; return ret; }
internal void PushRevalidate(STable f) { revalidate.Add(f); }
// When calling builtins, the binder is often bypassed, so we need to // check arguement types ourselves. This is the really simple version // that doesn't handle junctions, not often used. public static P6any NominalCheck(string name, STable mo, Variable v) { P6any r = v.Fetch(); if (!r.mo.HasMRO(mo)) throw new NieczaException("Nominal type check failed for " + name + " needed " + mo.name + " got " + r.mo.name); return r; }
public NState(NState f) { next = f.next; name = f.name; cut_to = f.cut_to; quant = f.quant; klass = f.klass; }
public Cursor(GState g, STable klass, int from, int pos, CapInfo captures, P6any ast, string reduced) { this.global = g; this.captures = captures; this.pos = pos; this.ast = ast; this.from = from; this.mo = Kernel.MatchMO; this.save_klass = klass; this.reduced = reduced; }
public SAliasedTable(STable tb, string a) : base(Types.SAliasedTable, tb) { table = tb; alias = a; }
public new static SAliasedTable Get(SDatabase d, Reader f) { return(new SAliasedTable(STable.Get(d, f), f.GetString())); }
public TableRowSet(STransaction db, STable t) : base(db + t.uid /*read constraint*/, t, SDict <long, SFunction> .Empty, t.rows.Length) { _tb = t; }
SQuery TableExp(SDict <int, string> als, SDict <int, Serialisable> cp) { if (lxr.tok == Sym.LPAREN) { SQuery r; Next(); if (lxr.tok == Sym.SELECT) { r = (SQuery)Select(); } else { r = TableExp(SDict <int, string> .Empty, SDict <int, Serialisable> .Empty); } Mustbe(Sym.RPAREN); return(r); } var id = MustBeID(); var tb = new STable(id.str); if (lxr.tok == Sym.ID && lxr.val != null) { var alias = ((SString)lxr.val).str; Next(); tb = new SAliasedTable(tb, alias); } var jt = SJoin.JoinType.None; if (lxr.tok == Sym.COMMA) { Next(); jt = SJoin.JoinType.Cross; } else if (lxr.tok == Sym.CROSS) { Next(); Mustbe(Sym.JOIN); jt = SJoin.JoinType.Cross; } else { if (lxr.tok == Sym.NATURAL) { Next(); jt |= SJoin.JoinType.Natural; Mustbe(Sym.JOIN); } else { if (lxr.tok == Sym.INNER) { Next(); jt |= SJoin.JoinType.Inner; } else { if (lxr.tok == Sym.LEFT) { Next(); jt |= SJoin.JoinType.Left; } else if (lxr.tok == Sym.RIGHT) { Next(); jt |= SJoin.JoinType.Right; } else if (lxr.tok == Sym.FULL) { Next(); jt |= (SJoin.JoinType.Left | SJoin.JoinType.Right); } if (jt != SJoin.JoinType.None && lxr.tok == Sym.OUTER) { Next(); } } if (jt != SJoin.JoinType.None) { Mustbe(Sym.JOIN); } } } if (jt != SJoin.JoinType.None) { var on = SList <SExpression> .Empty; var ra = TableExp(SDict <int, string> .Empty, SDict <int, Serialisable> .Empty); var da = SDict <int, string> .Empty; var ca = SDict <int, Serialisable> .Empty; var na = SDict <string, Serialisable> .Empty; var us = SList <string> .Empty; if ((jt & (SJoin.JoinType.Cross | SJoin.JoinType.Natural)) == 0) { if (lxr.tok == Sym.USING) { Next(); jt |= SJoin.JoinType.Named; for (; ;) { var v = lxr.val; Mustbe(Sym.ID); us += ((SString)v).str; if (lxr.tok == Sym.COMMA) { Next(); } else { break; } } } else { Mustbe(Sym.ON); for (; ;) { var ex = Conjunct(); if (!(ex is SExpression e) || e.op != SExpression.Op.Eql || e.left.type != Types.SColumn || e.right.type != Types.SColumn) { throw new Exception("Column matching expression expected"); } on += (SExpression)ex; if (lxr.tok == Sym.AND) { Next(); } else { break; } } } } return(new SJoin(tb, false, jt, ra, on, us, da, ca, new Context(na, null))); } return(tb); }
static Variable BoxRW <T>(T o, STable mo) { return(Kernel.NewMuScalar(new BoxObject <T>(o, mo))); }
public static Variable enum_mixin_role(string name, P6any meth) { STable r = new STable('{' + name + '}'); r.mo.FillRole(new STable[0], null); r.typeObject = r.initObject = new P6opaque(r); r.typeVar = r.initVar = Kernel.NewROScalar(r.typeObject); r.mo.AddMethod(0, name, meth); r.mo.Revalidate(); r.SetupVTables(); return r.typeVar; }
public void Server() { // client.Blocking = false; // process the connection string asy = new ServerStream(client); var rdr = asy.rbuf; int p = -1; try { var fn = rdr.GetString(); db = SDatabase.Open(path, fn); asy.Write(Types.Done); asy.Flush(); } catch (IOException) { asy.Close(); return; } catch (Exception e) { try { asy.StartException(); asy.Write(Types.Exception); asy.PutString(e.Message); asy.Flush(); } catch (Exception) { } goto _return; } // start a Strong protocol service for (; ;) { p = -1; try { p = rdr.ReadByte(); } catch (Exception) { p = -1; } if (p < 0) { goto _return; } try { switch ((Types)p) { case Types.DescribedGet: case Types.Get: { var tr = db.Transact(); SQuery?qy = null; try { qy = rdr._Get(tr) as SQuery; } catch (Exception e) { rdr.buf.len = 0; throw e; } if (qy == null) { throw new Exception("Bad query"); } RowSet rs = qy.RowSet(tr, qy, SDict <long, SFunction> .Empty, Context.Empty); var sb = new StringBuilder("["); var cm = ""; for (var b = rs?.First(); b != null; b = b.Next()) { sb.Append(cm); cm = ","; ((RowBookmark)b)._ob.Append(db, sb); } sb.Append(']'); db = db.MaybeAutoCommit(rs._tr); asy.Write(Types.Done); if ((Types)p == Types.DescribedGet) { asy.PutInt(rs._qry.Display.Length ?? 0); for (var b = rs._qry.Display.First(); b != null; b = b.Next()) { asy.PutString(b.Value.Item2); } } asy.PutString(sb.ToString()); asy.Flush(); break; } case Types.SCreateTable: { var tr = db.Transact(); var tn = rdr.GetString(); // table name if (tr.names.Contains(tn)) { throw new Exception("Duplicate table name " + tn); } var tb = new STable(tr, tn); tr = (STransaction)tr.Install(tb, tr.curpos); var n = rdr.GetInt(); // #cols for (var i = 0; i < n; i++) { var cn = rdr.GetString(); // column name var dt = (Types)rdr.ReadByte(); // dataType tr = (STransaction)tr.Install(new SColumn(tr, cn, dt, tb.uid), tr.curpos); } db = db.MaybeAutoCommit(tr); asy.Write(Types.Done); asy.Flush(); break; } case Types.SInsert: { var tr = db.Transact(); tr = SInsertStatement.Get(db, rdr).Obey(tr); db = db.MaybeAutoCommit(tr); asy.Write(Types.Done); asy.Flush(); break; } case Types.Insert: { var tr = db.Transact(); var tb = (STable)tr.names.Lookup(rdr.GetString()); // table name var n = rdr.GetInt(); // # named cols var cs = SList <long> .Empty; Exception?ex = null; for (var i = 0; i < n; i++) { var cn = rdr.GetString(); if (tb.names.Lookup(cn) is SColumn sc) { cs += (sc.uid, i); } else { ex = new Exception("Column " + cn + " not found"); } } var nc = rdr.GetInt(); // #cols if ((n == 0 && nc != tb.cpos.Length) || (n != 0 && n != nc)) { throw new Exception("Wrong number of columns"); } var nr = rdr.GetInt(); // #records for (var i = 0; i < nr; i++) { var f = SDict <long, Serialisable> .Empty; if (n == 0) { for (var b = tb.cpos.First(); b != null; b = b.Next()) { if (b.Value.Item2 is SColumn sc) { f += (sc.uid, rdr._Get(tr)); // serialisable values } } } else { for (var b = cs; b.Length != 0; b = b.next) { f += (b.element, rdr._Get(tr)); // serialisable values } } tr = (STransaction)tr.Install(new SRecord(tr, tb.uid, f), tr.curpos); } if (ex != null) { throw ex; } db = db.MaybeAutoCommit(tr); asy.Write(Types.Done); asy.Flush(); break; } case Types.SAlter: { var tr = db.Transact(); var tn = rdr.GetString(); // table name var tb = (STable)tr.names.Lookup(tn) ?? throw new Exception("Table " + tn + " not found"); var cn = rdr.GetString(); // column name or "" var nm = rdr.GetString(); // new name if (cn.Length == 0) { tr = (STransaction)tr.Install(new SAlter(tr, nm, Types.STable, tb.uid, 0), tr.curpos); } else { tr = (STransaction)tr.Install(new SAlter(tr, nm, Types.SColumn, tb.uid, (tb.names.Lookup(cn) is SColumn sc) ? sc.uid : throw new Exception("Column " + cn + " not found")), tr.curpos); } db = db.MaybeAutoCommit(tr); asy.Write(Types.Done); asy.Flush(); break; } case Types.SDrop: { var tr = db.Transact(); var nm = rdr.GetString(); // object name var pt = tr.names.Lookup(nm) ?? throw new Exception("Object " + nm + " not found"); var cn = rdr.GetString(); tr = (STransaction)tr.Install( (cn.Length == 0) ? new SDrop(tr, pt.uid, -1) : new SDrop(tr, (((STable)pt).names.Lookup(cn) is SColumn sc) ? sc.uid : throw new Exception("Column " + cn + " not found"), pt.uid), tr.curpos); db = db.MaybeAutoCommit(tr); asy.Write(Types.Done); asy.Flush(); break; } case Types.SCreateIndex: { var tr = db.Transact(); var tn = rdr.GetString(); // table name var tb = (STable)tr.names.Lookup(tn) ?? throw new Exception("Table " + tn + " not found"); var xt = rdr.ReadByte(); var rn = rdr.GetString(); var ru = (rn.Length == 0)?-1: (tr.names.Lookup(rn)?.uid ?? throw new Exception("Table " + tn + " not found")); var nc = rdr.GetInt(); var cs = SList <long> .Empty; for (var i = 0; i < nc; i++) { var cn = rdr.GetString(); var se = (tb.names.Lookup(cn) is SColumn sc)? sc.uid : throw new Exception("Column " + cn + " not found"); cs += (se, i); } tr = (STransaction)tr.Install(new SIndex(tr, tb.uid, xt < 2, ru, cs), tr.curpos); db = db.MaybeAutoCommit(tr); asy.Write(Types.Done); asy.Flush(); break; } case Types.Read: { var id = rdr.GetLong(); var sb = new StringBuilder(); db.Get(id).Append(db, sb); asy.PutString(sb.ToString()); asy.Flush(); break; } case Types.SUpdateSearch: { var tr = db.Transact(); tr = SUpdateSearch.Get(db, rdr).Obey(tr, Context.Empty); db = db.MaybeAutoCommit(tr); asy.Write(Types.Done); asy.Flush(); break; } case Types.SUpdate: { var tr = db.Transact(); var id = rdr.GetLong(); var rc = db.Get(id); var tb = (STable)tr.objects[rc.table]; var n = rdr.GetInt(); // # cols updated var f = SDict <string, Serialisable> .Empty; for (var i = 0; i < n; i++) { var cn = rdr.GetString(); f += (cn, rdr._Get(db)); } tr = (STransaction)tr.Install(new SUpdate(tr, rc, f), tr.curpos); db = db.MaybeAutoCommit(tr); asy.Write(Types.Done); asy.Flush(); break; } case Types.SDeleteSearch: { var tr = db.Transact(); tr = SDeleteSearch.Get(db, rdr).Obey(tr, Context.Empty); db = db.MaybeAutoCommit(tr); asy.Write(Types.Done); asy.Flush(); break; } case Types.SDelete: { var tr = db.Transact(); var id = rdr.GetLong(); var rc = db.Get(id) as SRecord ?? throw new Exception("Record " + id + " not found"); tr = (STransaction)tr.Install(new SDelete(tr, rc.table, rc.uid), tr.curpos); db = db.MaybeAutoCommit(tr); asy.Write(Types.Done); asy.Flush(); break; } case Types.SBegin: db = new STransaction(db, false); asy.WriteByte((byte)Types.Done); asy.Flush(); break; case Types.SRollback: db = db.Rollback(); asy.WriteByte((byte)Types.Done); asy.Flush(); break; case Types.SCommit: { var tr = db as STransaction ?? throw new Exception("No transaction to commit"); db = tr.Commit(); asy.WriteByte((byte)Types.Done); asy.Flush(); break; } default: throw new Exception("Protocol error"); } } catch (SocketException) { return; } catch (Exception e) { try { db = db.Rollback(); // db.result = null; asy.StartException(); asy.Write(Types.Exception); asy.PutString(e.Message); asy.Flush(); } catch (Exception) { } } } _return :; }
public LexerCache(STable mo) { this.mo = mo; if (mo.mo.superclasses.Count == 1) { parent = mo.mo.superclasses[0].GetLexerCache(); repl_methods = new HashSet<string>(); foreach (P6how.MethodInfo mi in mo.mo.lmethods) { if ((mi.flags & P6how.V_MASK) != P6how.V_PUBLIC) continue; string mn = mi.short_name; int ix = mn.IndexOf(':'); if (ix >= 0) repl_methods.Add(mn.Substring(0,ix)); else repl_methods.Add(mn); } } }
// TODO: merge public static Variable cat_mixin_role(string name, P6any meth) { STable r = new STable('{' + name + '}'); r.mo.FillRole(new STable[0], null); r.typeObj = r.initObj = new P6opaque(r); r.mo.AddMethod(P6how.M_MULTI, name, meth); r.mo.Revalidate(); r.SetupVTables(); return r.typeObj; }
public NState(Choice cut_to, string name, NState proto) { next = proto; this.cut_to = cut_to; this.name = name; if (proto != null) klass = proto.klass; }
public static Variable mixin(Constants c, P6any obj, Variable role_list, Variable init, Variable newtype) { VarDeque iter = start_iter(role_list); List<STable> roles = new List<STable>(); while (Kernel.IterHasFlat(iter, true)) roles.Add(iter.Shift().Fetch().mo); STable n = new STable(c.setting, obj.mo.name + "+" + Kernel.JoinS(",", roles)); n.how = Kernel.BoxAny<STable>(n, obj.mo.how).Fetch(); n.typeObj = n.initObj = new P6opaque(n); ((P6opaque)n.typeObj).slots = null; n.mo.superclasses.Add(obj.mo); n.mo.local_roles = roles; n.mo.Compose(); newtype.Store(n.typeObj); string aname = null; if (init != c.setting.AnyP) { if (!obj.IsDefined()) throw new NieczaException("Cannot initialize a slot when mixing into a type object"); if (n.mo.local_attr.Count != 1 || (n.mo.local_attr[0].flags & P6how.A_PUBLIC) == 0) throw new NieczaException("Role(s) being mixed in do not define precisely one, public attribute"); aname = n.mo.local_attr[0].name; } if (obj.IsDefined()) { obj.ChangeType(n); BuildMostDerived(obj); if (aname != null) Kernel.Assign((Variable)obj.GetSlot(n, aname), init); return obj; } else { return n.typeObj; } }
public void SetClass(STable dm) { st.ns.klass = dm; }
public static Variable type_mixin_role(Variable type, Variable meth) { STable stype = type.Fetch().mo; string name = stype.name; STable r = new STable(stype.setting, "ANON"); r.mo.FillRole(new STable[0], null); r.typeObj = r.initObj = new P6opaque(r); r.mo.AddMethod(0, name, meth.Fetch()); r.mo.AddMethod(P6how.V_PRIVATE, name, meth.Fetch()); r.mo.AddAttribute(name, P6how.A_PUBLIC, null, stype); r.mo.Revalidate(); return r.typeObj; }
public Cursor(GState g, STable klass, RxFrame feedback, NState ns, Choice xact, int pos, CapInfo captures) { this.mo = this.save_klass = klass; this.xact = xact; this.nstate = ns; this.feedback = feedback; this.global = g; this.pos = pos; this.captures = captures; }
public static Variable enum_mixin_role(string name, P6any meth) { STable r = new STable(meth.mo.setting, '{' + name + '}'); r.mo.FillRole(new STable[0], null); r.typeObj = r.initObj = new P6opaque(r); r.mo.AddMethod(0, name, meth); r.mo.Revalidate(); r.SetupVTables(); return r.typeObj; }
public object ObjRef() { var tag = (SerializationCode)Byte(); if (Config.SerTrace) { Console.WriteLine("Reading {0} from {1}...", tag, rpointer - 1); } int i, j; switch (tag) { case SerializationCode.Null: return(null); case SerializationCode.ForeignRef: i = Int(); j = Int(); return(unit_map[i].bynum[j]); case SerializationCode.SelfRef: i = Int(); return(unit.bynum[i]); case SerializationCode.NewUnitRef: return(LoadNewUnit()); case SerializationCode.RuntimeUnit: return(RuntimeUnit.Thaw(this)); case SerializationCode.SubInfo: return(SubInfo.Thaw(this)); case SerializationCode.STable: return(STable.Thaw(this)); case SerializationCode.StashEnt: return(StashEnt.Thaw(this)); case SerializationCode.Rat: return(Rat.Thaw(this)); case SerializationCode.FatRat: return(FatRat.Thaw(this)); case SerializationCode.Complex: return(Complex.Thaw(this)); case SerializationCode.BigInteger: return(BigInteger.Thaw(this)); case SerializationCode.VarDeque: return(VarDeque.Thaw(this)); case SerializationCode.VarHash: return(VarHash.Thaw(this)); case SerializationCode.DispatchEnt: return(DispatchEnt.Thaw(this)); //case SerializationCode.RxFrame: // return RxFrame.Thaw(this); case SerializationCode.P6how: return(P6how.Thaw(this)); case SerializationCode.CC: return(CC.Thaw(this)); case SerializationCode.AltInfo: return(AltInfo.Thaw(this)); case SerializationCode.Signature: return(Signature.Thaw(this)); case SerializationCode.Parameter: return(Parameter.Thaw(this)); case SerializationCode.ReflectObj: return(ReflectObj.Thaw(this)); case SerializationCode.P6opaque: return(P6opaque.Thaw(this)); case SerializationCode.Frame: return(Frame.Thaw(this)); //Cursor, case SerializationCode.String: return(Register(String())); case SerializationCode.ArrP6any: return(RefsARegister <P6any>()); case SerializationCode.ArrVariable: return(RefsARegister <Variable>()); case SerializationCode.ArrString: return(RefsARegister <string>()); case SerializationCode.ArrCC: return(RefsARegister <CC>()); case SerializationCode.Boolean: return(Register(Byte() != 0)); case SerializationCode.Int: return(Register(Int())); case SerializationCode.Double: return(Register(Double())); case SerializationCode.Type: return(Register(Type.GetType(String(), true))); case SerializationCode.SimpleVariable: case SerializationCode.SimpleVariable_1: case SerializationCode.SimpleVariable_2: case SerializationCode.SimpleVariable_3: return(SimpleVariable.Thaw(this, (int)tag - (int)SerializationCode.SimpleVariable)); case SerializationCode.SubstrLValue: return(SubstrLValue.Thaw(this)); case SerializationCode.TiedVariable: return(TiedVariable.Thaw(this)); case SerializationCode.SubViviHook: return(SubViviHook.Thaw(this)); case SerializationCode.ArrayViviHook: return(ArrayViviHook.Thaw(this)); case SerializationCode.NewArrayViviHook: return(NewArrayViviHook.Thaw(this)); case SerializationCode.HashViviHook: return(HashViviHook.Thaw(this)); case SerializationCode.NewHashViviHook: return(NewHashViviHook.Thaw(this)); case SerializationCode.LADNone: return(Register(new LADNone())); case SerializationCode.LADNull: return(Register(new LADNull())); case SerializationCode.LADDot: return(Register(new LADDot())); case SerializationCode.LADDispatcher: return(Register(new LADDispatcher())); case SerializationCode.LADImp: return(Register(new LADImp())); case SerializationCode.LADStr: return(LADStr.Thaw(this)); case SerializationCode.LADStrNoCase: return(LADStrNoCase.Thaw(this)); case SerializationCode.LADMethod: return(LADMethod.Thaw(this)); case SerializationCode.LADParam: return(LADParam.Thaw(this)); case SerializationCode.LADQuant: return(LADQuant.Thaw(this)); case SerializationCode.LADSequence: return(LADSequence.Thaw(this)); case SerializationCode.LADAny: return(LADAny.Thaw(this)); case SerializationCode.LADCC: return(LADCC.Thaw(this)); default: throw new ThawException("unexpected object tag " + tag); } }
public SDatabase Install(STable t, long c) { return(New(objects + (t.uid, t), names + (t.name, t), c)); }
public IndexRowSet(STransaction tr, STable t, SIndex ix, SCList <Variant> key, SList <Serialisable> wh) : base(Rdc(tr, ix, key), t, SDict <long, SFunction> .Empty, t.rows.Length) { _ix = ix; _key = key; _wh = wh; _unique = key.Length == _ix.cols.Length; }
public static IADNode st_main() { var token = MainFSM.GetNextToken(); if (token.Type != TokenType.idType) { SyntaxError("Byl ocekavan identifikator funkce."); } if (STSearch(token.Attribute, true) != null) { SemanticError($"Funkce nebo globalni promenna se jmenem {token.Attribute} je j*z deklarovana."); } ADFunctionDeclaration fceDeclaration = new ADFunctionDeclaration() { Name = token.Attribute }; var newRecord = new STRecord() { Access = STAccess.global, Name = token.Attribute, Type = STType.function, Function = fceDeclaration }; FunctionsST.Records.Add(newRecord); if (MainFSM.GetNextToken().Type != TokenType.leftRBType) { SyntaxError("Byl ocekavan znak \'(\'"); } var arguments = decl_arg(); var symbolTable = new STable(); foreach (var arg in arguments) { var stRecord = new STRecord() { Access = STAccess.local, Name = arg, Type = STType.variable }; symbolTable.Records.Add(stRecord); fceDeclaration.Arguments.Add(new ADVariable { Name = arg, Type = ADVariable.VarType.variable, STRecord = stRecord }); } STablesStack.Push(symbolTable); if (MainFSM.GetNextToken().Type != TokenType.leftCBType) { SyntaxError("Byl ocekavan znak \'{\'"); } fceDeclaration.Body = statement_list(true); if (MainFSM.GetNextToken().Type != TokenType.rightCBType) { SyntaxError("Byl ocekavan znak \'}\'"); } STablesStack.Pop(); return(fceDeclaration); }