@@ -53,8 +53,12 @@ RUBY_SYMBOL_EXPORT_BEGIN
53
53
#define UNLIMITED_ARGUMENTS (-1)
54
54
55
55
/* array.c */
56
+ #ifdef TRUFFLERUBY
56
57
void rb_mem_clear (VALUE * , long );
57
- #define rb_assoc_new (a , b ) rb_ary_new3(2, a, b)
58
+ #else
59
+ void rb_mem_clear (register VALUE * , register long );
60
+ #endif
61
+ VALUE rb_assoc_new (VALUE , VALUE );
58
62
VALUE rb_check_array_type (VALUE );
59
63
VALUE rb_ary_new (void );
60
64
VALUE rb_ary_new_capa (long capa );
@@ -63,12 +67,12 @@ VALUE rb_ary_new_from_values(long n, const VALUE *elts);
63
67
VALUE rb_ary_tmp_new (long );
64
68
void rb_ary_free (VALUE );
65
69
void rb_ary_modify (VALUE );
66
- #define rb_ary_freeze (array ) rb_obj_freeze(array)
70
+ VALUE rb_ary_freeze (VALUE );
67
71
VALUE rb_ary_shared_with_p (VALUE , VALUE );
68
72
VALUE rb_ary_aref (int , const VALUE * , VALUE );
69
73
VALUE rb_ary_subseq (VALUE , long , long );
70
74
void rb_ary_store (VALUE , long , VALUE );
71
- #define rb_ary_dup (array ) rb_obj_dup(array)
75
+ VALUE rb_ary_dup (VALUE );
72
76
VALUE rb_ary_resurrect (VALUE ary );
73
77
VALUE rb_ary_to_ary (VALUE );
74
78
VALUE rb_ary_to_s (VALUE );
@@ -291,6 +295,25 @@ void rb_check_trusted(VALUE);
291
295
} \
292
296
} while (0)
293
297
#define rb_check_trusted_internal (obj ) ((void) 0)
298
+ #ifndef TRUFFLERUBY
299
+ #ifdef __GNUC__
300
+ #define rb_check_frozen (obj ) __extension__({rb_check_frozen_internal(obj);})
301
+ #define rb_check_trusted (obj ) __extension__({rb_check_trusted_internal(obj);})
302
+ #else
303
+ static inline void
304
+ rb_check_frozen_inline (VALUE obj )
305
+ {
306
+ rb_check_frozen_internal (obj );
307
+ }
308
+ #define rb_check_frozen (obj ) rb_check_frozen_inline(obj)
309
+ static inline void
310
+ rb_check_trusted_inline (VALUE obj )
311
+ {
312
+ rb_check_trusted_internal (obj );
313
+ }
314
+ #define rb_check_trusted (obj ) rb_check_trusted_inline(obj)
315
+ #endif
316
+ #endif
294
317
void rb_check_copyable (VALUE obj , VALUE orig );
295
318
296
319
#define RB_OBJ_INIT_COPY (obj , orig ) \
@@ -302,8 +325,14 @@ int rb_sourceline(void);
302
325
const char * rb_sourcefile (void );
303
326
VALUE rb_check_funcall (VALUE , ID , int , const VALUE * );
304
327
305
- NORETURN (void rb_error_arity (int , int , int ));
306
- int rb_check_arity (int argc , int min , int max );
328
+ NORETURN (MJIT_STATIC void rb_error_arity (int , int , int ));
329
+ static inline int
330
+ rb_check_arity (int argc , int min , int max )
331
+ {
332
+ if ((argc < min ) || (max != UNLIMITED_ARGUMENTS && argc > max ))
333
+ rb_error_arity (argc , min , max );
334
+ return argc ;
335
+ }
307
336
#define rb_check_arity rb_check_arity /* for ifdef */
308
337
309
338
#if defined(NFDBITS ) && defined(HAVE_RB_FD_INIT )
@@ -509,7 +538,7 @@ void rb_hash_foreach(VALUE, int (*)(ANYARGS), VALUE);
509
538
VALUE rb_hash (VALUE );
510
539
VALUE rb_hash_new (void );
511
540
VALUE rb_hash_dup (VALUE );
512
- #define rb_hash_freeze (array ) rb_obj_freeze(array)
541
+ VALUE rb_hash_freeze (VALUE );
513
542
VALUE rb_hash_aref (VALUE , VALUE );
514
543
VALUE rb_hash_lookup (VALUE , VALUE );
515
544
VALUE rb_hash_lookup2 (VALUE , VALUE , VALUE );
@@ -733,11 +762,11 @@ VALUE rb_str_buf_append(VALUE, VALUE);
733
762
VALUE rb_str_buf_cat (VALUE , const char * , long );
734
763
VALUE rb_str_buf_cat2 (VALUE , const char * );
735
764
VALUE rb_str_buf_cat_ascii (VALUE , const char * );
736
- VALUE rb_obj_as_string (VALUE object );
765
+ VALUE rb_obj_as_string (VALUE );
737
766
VALUE rb_check_string_type (VALUE );
738
767
void rb_must_asciicompat (VALUE );
739
- #define rb_str_dup (string ) rb_obj_dup(string)
740
- #define rb_str_resurrect (string ) rb_obj_dup(string)
768
+ VALUE rb_str_dup (VALUE );
769
+ VALUE rb_str_resurrect (VALUE str );
741
770
VALUE rb_str_locktmp (VALUE );
742
771
VALUE rb_str_unlocktmp (VALUE );
743
772
VALUE rb_str_dup_frozen (VALUE );
@@ -750,7 +779,7 @@ VALUE rb_str_subseq(VALUE, long, long);
750
779
char * rb_str_subpos (VALUE , long , long * );
751
780
void rb_str_modify (VALUE );
752
781
void rb_str_modify_expand (VALUE , long );
753
- #define rb_str_freeze (string ) rb_obj_freeze(string)
782
+ VALUE rb_str_freeze (VALUE );
754
783
void rb_str_set_len (VALUE , long );
755
784
VALUE rb_str_resize (VALUE , long );
756
785
VALUE rb_str_cat (VALUE , const char * , long );
@@ -774,7 +803,7 @@ VALUE rb_str_equal(VALUE str1, VALUE str2);
774
803
VALUE rb_str_drop_bytes (VALUE , long );
775
804
void rb_str_update (VALUE , long , long , VALUE );
776
805
VALUE rb_str_replace (VALUE , VALUE );
777
- #define rb_str_inspect (string ) rb_inspect(string)
806
+ VALUE rb_str_inspect (VALUE );
778
807
VALUE rb_str_dump (VALUE );
779
808
VALUE rb_str_split (VALUE , const char * );
780
809
void rb_str_setter (VALUE , ID , VALUE * );
@@ -789,23 +818,70 @@ VALUE rb_str_scrub(VALUE, VALUE);
789
818
/* symbol.c */
790
819
VALUE rb_sym_all_symbols (void );
791
820
821
+ #ifndef TRUFFLERUBY
792
822
#ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
793
- VALUE rb_str_new_cstr (const char * string );
823
+ #define rb_str_new (str , len ) RB_GNUC_EXTENSION_BLOCK( \
824
+ (__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
825
+ rb_str_new_static((str), (len)) : \
826
+ rb_str_new((str), (len)) \
827
+ )
828
+ #define rb_str_new_cstr (str ) RB_GNUC_EXTENSION_BLOCK( \
829
+ (__builtin_constant_p(str)) ? \
830
+ rb_str_new_static((str), (long)strlen(str)) : \
831
+ rb_str_new_cstr(str) \
832
+ )
833
+ #define rb_usascii_str_new (str , len ) RB_GNUC_EXTENSION_BLOCK( \
834
+ (__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
835
+ rb_usascii_str_new_static((str), (len)) : \
836
+ rb_usascii_str_new((str), (len)) \
837
+ )
794
838
#define rb_utf8_str_new (str , len ) RB_GNUC_EXTENSION_BLOCK( \
795
839
(__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
796
840
rb_utf8_str_new_static((str), (len)) : \
797
841
rb_utf8_str_new((str), (len)) \
798
842
)
843
+ #define rb_tainted_str_new_cstr (str ) RB_GNUC_EXTENSION_BLOCK( \
844
+ (__builtin_constant_p(str)) ? \
845
+ rb_tainted_str_new((str), (long)strlen(str)) : \
846
+ rb_tainted_str_new_cstr(str) \
847
+ )
848
+ #define rb_usascii_str_new_cstr (str ) RB_GNUC_EXTENSION_BLOCK( \
849
+ (__builtin_constant_p(str)) ? \
850
+ rb_usascii_str_new_static((str), (long)strlen(str)) : \
851
+ rb_usascii_str_new_cstr(str) \
852
+ )
799
853
#define rb_utf8_str_new_cstr (str ) RB_GNUC_EXTENSION_BLOCK( \
800
854
(__builtin_constant_p(str)) ? \
801
855
rb_utf8_str_new_static((str), (long)strlen(str)) : \
802
856
rb_utf8_str_new_cstr(str) \
803
857
)
858
+ #define rb_external_str_new_cstr (str ) RB_GNUC_EXTENSION_BLOCK( \
859
+ (__builtin_constant_p(str)) ? \
860
+ rb_external_str_new((str), (long)strlen(str)) : \
861
+ rb_external_str_new_cstr(str) \
862
+ )
863
+ #define rb_locale_str_new_cstr (str ) RB_GNUC_EXTENSION_BLOCK( \
864
+ (__builtin_constant_p(str)) ? \
865
+ rb_locale_str_new((str), (long)strlen(str)) : \
866
+ rb_locale_str_new_cstr(str) \
867
+ )
868
+ #define rb_str_buf_new_cstr (str ) RB_GNUC_EXTENSION_BLOCK( \
869
+ (__builtin_constant_p(str)) ? \
870
+ rb_str_buf_cat(rb_str_buf_new((long)strlen(str)), \
871
+ (str), (long)strlen(str)) : \
872
+ rb_str_buf_new_cstr(str) \
873
+ )
804
874
#define rb_str_cat_cstr (str , ptr ) RB_GNUC_EXTENSION_BLOCK( \
805
875
(__builtin_constant_p(ptr)) ? \
806
876
rb_str_cat((str), (ptr), (long)strlen(ptr)) : \
807
877
rb_str_cat_cstr((str), (ptr)) \
808
878
)
879
+ #define rb_exc_new_cstr (klass , ptr ) RB_GNUC_EXTENSION_BLOCK( \
880
+ (__builtin_constant_p(ptr)) ? \
881
+ rb_exc_new((klass), (ptr), (long)strlen(ptr)) : \
882
+ rb_exc_new_cstr((klass), (ptr)) \
883
+ )
884
+ #endif
809
885
#endif
810
886
#define rb_str_new2 rb_str_new_cstr
811
887
#define rb_str_new3 rb_str_new_shared
@@ -814,6 +890,7 @@ VALUE rb_str_new_cstr(const char *string);
814
890
#define rb_tainted_str_new2 rb_tainted_str_new_cstr
815
891
#define rb_str_buf_new2 rb_str_buf_new_cstr
816
892
#define rb_usascii_str_new2 rb_usascii_str_new_cstr
893
+ #define rb_str_buf_cat rb_str_cat
817
894
#define rb_str_buf_cat2 rb_str_cat_cstr
818
895
#define rb_str_cat2 rb_str_cat_cstr
819
896
#define rb_strlen_lit (str ) (sizeof(str "") - 1)
0 commit comments