andrei-markeev / ts2c

Convert Javascript/TypeScript to C
ISC License
1.26k stars 95 forks source link

Unable to compile 100 lines of code in 1 minute. #50

Closed zaoqi closed 5 years ago

zaoqi commented 5 years ago

This is the beginning of an es6 file generated by tsc.

function LANG_ERROR() {
    throw "TheLanguage PANIC";
}
function LANG_ASSERT(x) {
    if (!x) {
        return LANG_ERROR();
    }
}
const atom_t = 0;
const construction_t = 1;
const null_t = 2;
const data_t = 3;
const error_t = 4;
const just_t = 5;
const delay_evaluate_t = 6;
const delay_builtin_func_t = 7;
const delay_builtin_form_t = 8;
const delay_apply_t = 9;
const comment_t = 11;
const hole_t = 10;
function new_comment(comment, x) {
    return [comment_t, comment, x];
}
function comment_p(x) {
    return x[0] === comment_t;
}
function comment_comment(x) {
    return x[1];
}
function comment_x(x) {
    return x[2];
}
function un_comment_all(x) {
    while (comment_p(x)) {
        x = comment_x(x);
    }
    return x;
}
function atom_p(x) {
    return x[0] === atom_t;
}
function new_atom(x) {
    return [atom_t, x];
}
function un_atom(x) {
    return x[1];
}
function atom_equal_p(x, y) {
    if (x === y) {
        return true;
    }
    if (un_atom(x) === un_atom(y)) {
        lang_assert_equal_set_do(x, y);
        return true;
    }
    else {
        return false;
    }
}
function new_construction(x, y) {
    return [construction_t, x, y];
}
function construction_p(x) {
    return x[0] === construction_t;
}
function construction_head(x) {
    return x[1];
}
function construction_tail(x) {
    return x[2];
}
const null_v = [null_t];
function null_p(x) {
    return x[0] === null_t;
}
function new_data(x, y) {
    return [data_t, x, y];
}
function data_p(x) {
    return x[0] === data_t;
}
function data_name(x) {
    return x[1];
}
function data_list(x) {
    return x[2];
}
function new_error(x, y) {
    return [error_t, x, y];
}
function error_p(x) {
    return x[0] === error_t;
}
function error_name(x) {
    return x[1];
}
function error_list(x) {
    return x[2];
}
function just_p(x) {
    return x[0] === just_t;
}
andrei-markeev commented 5 years ago

Once again, ts2c currently isn't very good for compiling "library code", so the code where you have a lot of functions but don't use them anywhere. This should be fine if you provide the context for those functions. Same as e.g. in #38.