// Get the data // public static DataSet GetData(Workspace Enviro, HScriptParser.Full_table_nameContext context) { // Get the name // string t_name = context.table_name().IDENTIFIER().GetText(); // Global context // if (context.K_GLOBAL() != null) { if (Enviro.ChunkHeap.Exists(t_name)) return Enviro.ChunkHeap[t_name]; throw new HScriptCompileException("Global chunk '{0}' does not exist", t_name); } // Table context // if (context.database_name() != null) { string d_base = context.database_name().IDENTIFIER().GetText(); if (Enviro.Exists(d_base, t_name)) return Enviro.GetStaticTable(d_base, t_name); throw new HScriptCompileException("Table '{0}' does not exist", t_name); } throw new HScriptCompileException("Data '{0}' does not exist in memory or on disk", t_name); }
public static DataSet GetData(Workspace Enviro, FNodeSet Nodes, HScriptParser.Return_actionContext context) { // Get the table name // string name = context.full_table_name().table_name().IDENTIFIER().GetText(); string db = (context.full_table_name().database_name() == null) ? "global" : context.full_table_name().database_name().GetText(); // Figure out if we need to append // bool appendto = (context.K_INSERT() != null) ? true : false; // Global -- Append // if (context.full_table_name().database_name() == null && appendto) { if (Enviro.ChunkHeap.Exists(name)) return Enviro.ChunkHeap[name]; throw new HScriptCompileException(string.Format("Chunk '{0}' does not exist", name)); } // Static -- Append // if (appendto) { string fullname = db + "." + name; if (Enviro.Exists(db, name)) return Enviro.GetStaticTable(db, name); throw new HScriptCompileException(string.Format("Table '{0}' does not exist", fullname)); } // Global -- Create New // if (context.full_table_name().database_name() == null) { RecordSet data = new RecordSet(Nodes.Columns); Enviro.ChunkHeap.Reallocate(name, data); return data; } // Static -- Create New // string dir = Enviro.Connections[db]; Table t = new Table(dir, name, Nodes.Columns); return t; }