int jed_init_user_hooks (void) { if ((-1 == SLadd_intrin_fun_table (Hooks_Intrinsics, NULL)) || (-1 == SLadd_iconstant_table (Hook_IConstants, NULL))) return -1; return 0; }
int SLang_init_posix_process (void) { if ((-1 == SLadd_intrin_fun_table (Process_Name_Table, "__POSIX_PROCESS__")) || (-1 == SLadd_iconstant_table (Const_Table, NULL)) || (-1 == _pSLerrno_init ())) return -1; return 0; }
int init_smg_module (void) { if ((-1 == SLadd_intrin_fun_table (Smg_Intrinsics, "__SMG__")) || (-1 == SLadd_intrin_var_table (Smg_Variables, NULL)) || (-1 == SLadd_iconstant_table (Smg_Constants, NULL))) return -1; SLtt_get_terminfo (); Smg_Initialized = 0; return 0; }
int SLang_init_signal (void) { Signal_Type *s; if ((-1 == SLadd_intrin_fun_table(Intrin_Table, NULL)) || (-1 == SLadd_iconstant_table (IConsts, NULL))) return -1; s = Signal_Table; while (s->name != NULL) { if (-1 == SLns_add_iconstant (NULL, s->name, SLANG_INT_TYPE, s->sig)) return -1; s++; } return 0; }
int SLang_init_posix_io (void) { SLang_Class_Type *cl; if (NULL == (cl = SLclass_allocate_class ("FD_Type"))) return -1; cl->cl_destroy = destroy_fd_type; (void) SLclass_set_push_function (cl, fd_push); cl->cl_datatype_deref = fdtype_datatype_deref; if ((-1 == SLclass_register_class (cl, SLANG_FILE_FD_TYPE, sizeof (SLFile_FD_Type), SLANG_CLASS_TYPE_PTR)) || (-1 == SLclass_add_binary_op (SLANG_FILE_FD_TYPE, SLANG_FILE_FD_TYPE, fd_fd_bin_op, fd_fd_bin_op_result))) return -1; if ((-1 == SLadd_intrin_fun_table(Fd_Name_Table, "__POSIXIO__")) || (-1 == SLadd_iconstant_table (PosixIO_Consts, NULL)) || (-1 == _pSLerrno_init ())) return -1; return 0; }
int SLang_init_slmath (void) { SLtype *int_types; #if SLANG_HAS_COMPLEX if (-1 == _pSLinit_slcomplex ()) return -1; #endif int_types = _pSLarith_Arith_Types; while (*int_types != SLANG_FLOAT_TYPE) { if (-1 == SLclass_add_math_op (*int_types, generic_math_op, double_math_op_result)) return -1; int_types++; } if ((-1 == SLclass_add_math_op (SLANG_FLOAT_TYPE, float_math_op, double_math_op_result)) || (-1 == SLclass_add_math_op (SLANG_DOUBLE_TYPE, double_math_op, double_math_op_result)) #if SLANG_HAS_COMPLEX || (-1 == SLclass_add_math_op (SLANG_COMPLEX_TYPE, complex_math_op, complex_math_op_result)) #endif ) return -1; if ((-1 == SLadd_math_unary_table (SLmath_Table, "__SLMATH__")) || (-1 == SLadd_intrin_fun_table (SLang_Math_Table, NULL)) || (-1 == SLadd_dconstant_table (DConst_Table, NULL)) || (-1 == SLadd_iconstant_table (IConsts, NULL)) || (-1 == add_nan_and_inf ())) return -1; #if defined(__unix__) (void) SLsignal (SIGFPE, math_floating_point_exception); #endif return 0; }
int _pSLarith_register_types (void) { SLang_Class_Type *cl; SLtype a_type, b_type; int i, j; #if defined(HAVE_SETLOCALE) && defined(LC_NUMERIC) /* make sure decimal point it used --- the parser requires it */ (void) setlocale (LC_NUMERIC, "C"); #endif for (i = 0; i < NUM_INTEGER_TYPES; i++) { Integer_Info_Type *info; info = Integer_Types + i; _pSLang_set_arith_type (info->data_type, 1); if (info->name == NULL) { /* This happens when the object is the same size as an integer * For this case, we really want to copy the integer class. * We will handle that when the synonym is created. */ continue; } if (NULL == (cl = SLclass_allocate_class (info->name))) return -1; (void) SLclass_set_string_function (cl, arith_string); (void) SLclass_set_push_function (cl, integer_push); (void) SLclass_set_pop_function (cl, integer_pop); cl->cl_push_literal = info->push_literal; cl->cl_to_bool = integer_to_bool; cl->cl_byte_code_destroy = info->byte_code_destroy; cl->cl_cmp = info->cmp_fun; if (-1 == SLclass_register_class (cl, info->data_type, info->sizeof_type, SLANG_CLASS_TYPE_SCALAR)) return -1; if (-1 == SLclass_add_unary_op (info->data_type, info->unary_fun, arith_unary_op_result)) return -1; #if 0 if (-1 == _pSLclass_add_arith_unary_op (info->data_type, info->arith_unary_fun, arith_unary_arith_op_result)) return -1; #endif } #if SLANG_HAS_FLOAT if (NULL == (cl = SLclass_allocate_class ("Double_Type"))) return -1; (void) SLclass_set_push_function (cl, double_push); (void) SLclass_set_pop_function (cl, double_pop); (void) SLclass_set_string_function (cl, arith_string); cl->cl_byte_code_destroy = double_byte_code_destroy; cl->cl_push_literal = double_push_literal; cl->cl_cmp = double_cmp_function; if (-1 == SLclass_register_class (cl, SLANG_DOUBLE_TYPE, sizeof (double), SLANG_CLASS_TYPE_SCALAR)) return -1; if (-1 == SLclass_add_unary_op (SLANG_DOUBLE_TYPE, double_unary_op, arith_unary_op_result)) return -1; #if 0 if (-1 == _pSLclass_add_arith_unary_op (SLANG_DOUBLE_TYPE, double_arith_unary_op, arith_unary_op_result)) return -1; #endif _pSLang_set_arith_type (SLANG_DOUBLE_TYPE, 2); if (NULL == (cl = SLclass_allocate_class ("Float_Type"))) return -1; (void) SLclass_set_string_function (cl, arith_string); (void) SLclass_set_push_function (cl, float_push); (void) SLclass_set_pop_function (cl, float_pop); cl->cl_cmp = float_cmp_function; if (-1 == SLclass_register_class (cl, SLANG_FLOAT_TYPE, sizeof (float), SLANG_CLASS_TYPE_SCALAR)) return -1; if (-1 == SLclass_add_unary_op (SLANG_FLOAT_TYPE, float_unary_op, arith_unary_op_result)) return -1; #if 0 if (-1 == _pSLclass_add_arith_unary_op (SLANG_FLOAT_TYPE, float_arith_unary_op, arith_unary_op_result)) return -1; #endif _pSLang_set_arith_type (SLANG_FLOAT_TYPE, 2); #endif if (-1 == create_synonyms ()) return -1; for (i = 0; i < MAX_ARITHMETIC_TYPES; i++) { a_type = _pSLarith_Arith_Types[i]; #if 0 if (Alias_Map[TYPE_TO_TABLE_INDEX(a_type)] != a_type) continue; #endif if (a_type == 0) continue; for (j = 0; j < MAX_ARITHMETIC_TYPES; j++) { int implicit_ok; b_type = _pSLarith_Arith_Types[j]; if (b_type == 0) continue; /* Allow implicit typecast, except from int to float */ implicit_ok = ((b_type >= SLANG_FLOAT_TYPE) || (a_type < SLANG_FLOAT_TYPE)); if (-1 == SLclass_add_binary_op (a_type, b_type, arith_bin_op, arith_bin_op_result)) return -1; if (a_type != b_type) if (-1 == SLclass_add_typecast (a_type, b_type, _pSLarith_typecast, implicit_ok)) return -1; } } if (-1 == _pSLadd_arith_unary_table (Unary_Table, NULL)) return -1; if (-1 == _pSLadd_arith_binary_table (Binary_Table, NULL)) return -1; if ((-1 == SLadd_iconstant_table (IConst_Table, NULL)) #if SLANG_HAS_FLOAT || (-1 == SLadd_fconstant_table (FConst_Table, NULL)) || (-1 == SLadd_dconstant_table (DConst_Table, NULL)) #endif #if HAVE_LONG_LONG || (-1 == SLadd_llconstant_table (LLConst_Table, NULL)) #endif ) return -1; compute_inf_an_nan (); return 0; }