Exemplo n.º 1
0
void CCodeGenerator::operator()(Call* expr) {
	// The call expression may actually be a native operator, so check the type
	// first.
	if (expr->arguments()) {
		Type::Ptr type = expr->arguments()->type();
		String::Ptr id = expr->function()->name();
		if (id->string()[0] == '@' && type->is_primitive()) {
            native_operator(expr);
			return;
		}
	}
	call(expr->function(), expr->arguments());
}
Exemplo n.º 2
0
void CCodeGenerator::scope_cleanup(Variable* var) {
    // Emits the code to clean up the stack when exiting a block.  This
    // includes decrementing reference counts, and calling destructors for
    // value types.
    Type::Ptr type = var->type();
    if (type && !type->is_primitive()) {
        if (type->is_value()) {
            assert(!"Need to figure out how to do value types");
            // Call destructor
        } else {
            // Emit a branch to check the variable's reference count and free
            // it if necessary.
            refcount_dec(Operand(var->name()));
        }
    }
}