about summary refs log blame commit diff stats
path: root/src/lmathlib.c
blob: 441fbf736c2be400f4bf68e71d4c4a2591e71f55 (plain) (tree)
class="s">'\n" << end(); break; } } out << line.at(i); } // todo: some way to represent a file without a final newline out << '\n'; } return out.str(); } void construct_resources_object(const map<string, string>& contents) { int resources_data_address = allocate(SIZE(contents)*2 + /*array length*/1); int curr = resources_data_address + /*skip refcount and length*/2; for (map<string, string>::const_iterator p = contents.begin(); p != contents.end(); ++p) { put(Memory, curr, new_mu_text(p->first)); trace(9999, "mem") << "storing file name " << get(Memory, curr) << " in location " << curr << end(); put(Memory, get(Memory, curr), 1); trace(9999, "mem") << "storing refcount 1 in location " << get(Memory, curr) << end(); ++curr; put(Memory, curr, new_mu_text(p->second)); trace(9999, "mem") << "storing file contents " << get(Memory, curr) << " in location " << curr << end(); put(Memory, get(Memory, curr), 1); trace(9999, "mem") << "storing refcount 1 in location " << get(Memory, curr) << end(); ++curr; } curr = resources_data_address+/*skip refcount*/1; put(Memory, curr, SIZE(contents)); // size of array trace(9999, "mem") << "storing resources size " << get(Memory, curr) << " in location " << curr << end(); put(Memory, resources_data_address, 1); // initialize refcount trace(9999, "mem") << "storing refcount 1 in location " << resources_data_address << end(); // wrap the resources data in a 'resources' object int resources_address = allocate(size_of_resources()); curr = resources_address+/*skip refcount*/1; put(Memory, curr, resources_data_address); trace(9999, "mem") << "storing resources data address " << resources_data_address << " in location " << curr << end(); put(Memory, resources_address, 1); // initialize refcount trace(9999, "mem") << "storing refcount 1 in location " << resources_address << end(); // save in product put(Memory, RESOURCES, resources_address); trace(9999, "mem") << "storing resources address " << resources_address << " in location " << RESOURCES << end(); } int size_of_resources() { // memoize result if already computed static int result = 0; if (result) return result; assert(get(Type_ordinal, "resources")); type_tree* type = new type_tree("resources"); result = size_of(type)+/*refcount*/1; delete type; return result; } void skip_whitespace(istream& in) { while (true) { if (!has_data(in)) break; if (isspace(in.peek())) in.get(); else break; } }