Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve test for %l of mrb_vformat(); ref #4613 #4622

Closed

Conversation

shuujii
Copy link
Contributor

@shuujii shuujii commented Aug 9, 2019

The following compilation error occurs on Visual Studio 2017 in AppVeyor if
commented out part in previous mrbgems/mruby-test/vformat.c is enabled.

CC    mrbgems/mruby-test/vformat.c -> build/cxx_abi/mrbgems/mruby-test/vformat.obj
  C:\projects\mruby\mrbgems\mruby-test\vformat.c(176): fatal error C1060: compiler is out of heap space
  INTERNAL COMPILER ERROR in 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe'
      Please choose the Technical Support command on the Visual C++
      Help menu, or open the Technical Support help file for more information

This error seems to occur only C++, and not occur Visual Studio 2013/2015.

The cause seems to be deep nested conditional operator (? :). So I decided
to generate mrbgems/mruby-test/vformat.c with ERB to avoid it.

The following compilation error occurs on Visual Studio 2017 in AppVeyor if
commented out part in previous `mrbgems/mruby-test/vformat.c` is enabled.

  CC    mrbgems/mruby-test/vformat.c -> build/cxx_abi/mrbgems/mruby-test/vformat.obj
  C:\projects\mruby\mrbgems\mruby-test\vformat.c(176): fatal error C1060: compiler is out of heap space
  INTERNAL COMPILER ERROR in 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe'
      Please choose the Technical Support command on the Visual C++
      Help menu, or open the Technical Support help file for more information

This error seems to occur only C++, and not occur Visual Studio 2013/2015.

The cause seems to be deep nested conditional operator (`? :`). So I decided
to generate `mrbgems/mruby-test/vformat.c` with ERB to avoid it.
@matz
Copy link
Member

matz commented Dec 17, 2019

Introducing more dependency (erb) is not preferable. Is there any other workaround?

@shuujii
Copy link
Contributor Author

shuujii commented Dec 18, 2019

I didn't use erb command but ERB library which is a Ruby standard library, so I thought it was acceptable.

If it is not acceptable, what about the following actions?

  • Commit the generated file like lex.def as well.

  • Incorporates a small template engine implementation such as Mote, Ate and Erubi. If we only support % and <%= ... %> (newlines are not allowed), the following one-liner can also be used :)

    # one-liner-erb.rb
    eval$<.map{|l|l=~/^%/?$':%|$><<"#{l.gsub(/<%=(.*?)%>/,'#{\1}')}"|}*$/
    %# example.erb
    % native_types = {
    %   c: {type: "char", code: "RSTRING_PTR(obj)[0]"},
    %   d: {type: "int" , code: "(int)mrb_fixnum(obj)"},
    % }
    typedef struct {
    % native_types.each do |spec, attrs|
      <%=attrs[:type]%> <%=spec%>;
    % end
    } VFNative;
    $ ruby one-liner-erb.rb example.erb
    typedef struct {
      char c;
      int d;
    } VFNative;
    
    $ diff -s =(ruby one-liner-erb.rb example.erb) =(erb example.erb)
    Files /tmp/zshq5HoG1 and /tmp/zshuoc8X6 are identical

@matz matz closed this in 429f6de Dec 19, 2019
@matz
Copy link
Member

matz commented Dec 19, 2019

I addressed this issue in a different way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants