[ruby-cvs:78345] a3e6f52c17 (master): rename __builtin_inline!(code) and introduce others.

"Koichi Sasada" <[email protected]>
Newsgroups gmane.comp.lang.ruby.cvs
Message-ID <[email protected]>
Koichi Sasada	2019-11-26 12:20:53 +0900 (Tue, 26 Nov 2019)

  New Revision: a3e6f52c17

  https://github.com/ruby/ruby/commit/a3e6f52c17

  Log:
    rename __builtin_inline!(code) and introduce others.
    
    rename __builtin_inline!(code) to __builtin_cstmt(code).
    Also this commit introduce the following inlining C code features.
    
    * __builtin_cstmt!(STMT)
    
    (renamed from __builtin_inline!)
    
    Define a function which run STMT implicitly and call this function at
    evatuation time. Note that you need to return some value in STMT.
    If there is a local variables (includes method parameters), you can
    read these values.
    
      static VALUE func(ec, self) {
        VALUE x = ...;
        STMT
      }
    
    Usage:
      def double a
        # a is readable from C code.
        __builtin_cstmt! 'return INT2FIX(FIX2INT(a) * 2);'
      end
    
    * __builtin_cexpr!(EXPR)
    
    Define a function which invoke EXPR implicitly like `__builtin_cstmt!`.
    Different from cstmt!, which compiled with `return EXPR;`.
    (`return` and `;` are added implicitly)
    
      static VALUE func(ec, self) {
        VALUE x = ...;
        return EXPPR;
      }
    
    Usage:
      def double a
        __builtin_cexpr! 'INT2FIX(FIX2INT(a) * 2)'
      end
    
    * __builtin_cconst!(EXPR)
    
    Define a function which invoke EXPR implicitly like cexpr!.
    However, the function is called once at compile time, not evaluated time.
    Any local variables are not accessible (because there is no local variable
    at compile time).
    
    Usage:
      GCC = __builtin_cconst! '__GNUC__'
    
    * __builtin_cinit!(STMT)
    
    STMT are writtein in auto-generated code.
    This code does not return any value.
    
    Usage:
    
      __builtin_cinit! '#include <zlib.h>'
      def no_compression?
        __builtin_cconst! 'Z_NO_COMPRESSION ? Qtrue : Qfalse'
      end

  Modified files:
    compile.c
    tool/mk_builtin_loader.rb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.