/
CDC-1.2b/
CDC-1.2b/src/
parent $frob_class
object $message_class

var $root dbref 'message_class
var $root child_index 0
var $root fertile 0
var $root manager $message_class
var $root owned [$message_class]
var $root owners [$]
var $root writable []
var $root readable ['parameters, 'methods, 'code]
var $root inited 1

method add_entry
    arg this, key, what;
    
    if (!(type(key) in ['string, 'dbref]))
        throw(~type, "The key should be a string or dbref.");
    if (type(what) == 'string)
        what = $ctext_class.new(($compile_evaluator.compile_cml(what))['result]);
    if ((type(what) == 'frob) && (class(what) == $ctext_class))
        this = dict_add(this, key, what);
    else
        throw(~type, "Values should be $ctext_class or strings.");
    return <this(), this>;
.

method del_entry
    arg this, key;
    
    this = dict_del(this, key);
.

method eval_ctext
    arg this, [vars];
    var key, new, temp, t, list;
    
    vars = [@vars, #[]][1];
    if (!('time in dict_keys(vars)))
        vars = dict_add(vars, 'time, 'pre);
    if (!('evaluator in dict_keys(vars)))
        vars = dict_add(vars, 'evaluator, $base_evaluator);
    if (!('this in dict_keys(vars)))
        vars = dict_add(vars, 'this, sender());
    new = .new(#[]);
    switch (vars['time]) {
        case 'pre:
            if ("general" in dict_keys(this)) {
                vars = dict_add(vars, "general", ['string_type, "general"]);
                list = ["general", @dict_keys(this)];
            } else {
                list = dict_keys(this);
            }
            for key in (list) {
                vars = dict_add(vars, 'sender, ['string_type, key]);
                temp = (this[key]).eval_ctext(vars);
                if (((vars[key])[1]) == 'list_type) {
                    for t in ((vars[key])[2])
                        new = new.add_entry(t[2], temp);
                } else {
                    new = new.add_entry((vars[key])[2], temp);
                }
            }
            return new;
        case 'post:
            new = (| this[vars['sender]] |) || ((| this["general"] |) || ($ctext_class.new([""])));
            new = new.eval_ctext(vars);
            return new;
    }
.

method new
    arg what;
    var key, this;
    
    if (type(what) != 'dictionary)
        throw(~type, "A message should be a dictionary.");
    this = <this(), #[]>;
    for key in (dict_keys(what))
        this = this.add_entry(key, what[key]);
    return this;
.

method has_entry
    arg this, name;
    
    return name in dict_keys(this);
.

method get_part
    arg this, part;
    
    return this[part];
.

method uncompile
    arg this;
    var key, output;
    
    output = #[];
    for key in (dict_keys(this))
        output = dict_add(output, key, (this[key]).uncompile());
    return output;
.