diff options
Diffstat (limited to 'Build/source/utils/asymptote/record.cc')
-rw-r--r-- | Build/source/utils/asymptote/record.cc | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/record.cc b/Build/source/utils/asymptote/record.cc new file mode 100644 index 00000000000..b19083d51d4 --- /dev/null +++ b/Build/source/utils/asymptote/record.cc @@ -0,0 +1,76 @@ +/***** + * record.cc + * Tom Prince 2004/07/15 + * + * The type for records and modules in the language. + *****/ + +#include "record.h" +#include "inst.h" +#include "runtime.h" +#include "coder.h" + + + +namespace types { + +record::record(symbol *name, frame *level) + : ty(ty_record), + name(name), + level(level), + init(new vm::lambda), + e() +{ + assert(init); +} + +record::~record() +{} + +record *record::newRecord(symbol *id, bool statically) +{ + frame *underlevel = getLevel(statically); + assert(underlevel); + + frame *level = new frame(underlevel, 0); + + record *r = new record(id, level); + return r; +} + +// Initialize to null by default. +trans::access *record::initializer() { + static trans::bltinAccess a(run::pushNullRecord); + return &a; +} + +dummyRecord::dummyRecord(symbol *name) + : record(name, new frame(0,0)) +{ + // Encode the instructions to put an placeholder instance of the record + // on the stack. + trans::coder c(this, 0); + c.closeRecord(); +} + +dummyRecord::dummyRecord(string s) + : record (symbol::trans(s), new frame(0,0)) +{ + // Encode the instructions to put an placeholder instance of the record + // on the stack. + trans::coder c(this, 0); + c.closeRecord(); +} + +void dummyRecord::add(string name, ty *t, trans::access *a, + trans::permission perm) { + e.addVar(symbol::trans(name), + new trans::varEntry(t, a, perm, this, this, position())); +} + +void dummyRecord::add(string name, function *t, vm::bltin f, + trans::permission perm) { + add(name, t, new trans::bltinAccess(f), perm); +} + +} // namespace types |