Beispiel #1
0
struct term *make_appl(struct term *fun, struct term *arg)
{
    struct term *ret = alloc_term(TYPE_APPL);
    ret->appl.fun = term_duplicate(fun);
    ret->appl.arg = term_duplicate(arg);
    return ret;
}
Beispiel #2
0
struct term *make_lambda(char *var, struct term *body)
{
    struct term *ret = alloc_term(TYPE_LAMBDA);
    strncpy(ret->lambda.var, var, VAR_LEN);
    ret->lambda.body = term_duplicate(body);
    return ret;
}
Beispiel #3
0
Term* Block::appendNew()
{
    Term* term = alloc_term(this);
    ca_assert(term != NULL);
    _terms.append(term);
    term->index = _terms.length()-1;
    return term;
}
Beispiel #4
0
struct term *term_duplicate(struct term *term)
{
    struct term *ret = alloc_term(term->type);
    switch(term->type) {
    case TYPE_VAR:
        strncpy(ret->var, term->var, VAR_LEN);
        break;
    case TYPE_LAMBDA:
        strncpy(ret->lambda.var, term->lambda.var, VAR_LEN);
        ret->lambda.body = term_duplicate(term->lambda.body);
        break;
    case TYPE_APPL:
        ret->appl.fun = term_duplicate(term->appl.fun);
        ret->appl.arg = term_duplicate(term->appl.arg);
        break;
    }
    return ret;
}
Beispiel #5
0
struct term *make_var(char *name)
{
    struct term *ret = alloc_term(TYPE_VAR);
    strncpy(ret->var, name, VAR_LEN);
    return ret;
}