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

support .IL files #883

Closed
danmoseley opened this issue Jan 22, 2025 · 2 comments
Closed

support .IL files #883

danmoseley opened this issue Jan 22, 2025 · 2 comments

Comments

@danmoseley
Copy link

Currently CLOC counts ".il" extension as "SKILL" type (which I'm unfamiliar with). There's another use of this extension, which is .NET intermediate language -- analagous to Java bytecode. Is it possible to handle that also? Right now on https://github.com/dotnet/runtime, which is something like the 15th most active repo on Github, it reports the following:

---------------------------------------------------------------------------------------
Language                             files          blank        comment           code
---------------------------------------------------------------------------------------
C#                                   30361         932200         759232        6092105
SKILL                                 5279         118704           4314        5827362
C++                                   1904         220459         243690        1042026
C/C++ Header                          2207         120472         113670         487687
C                                     1165          83956          73155         454080

but there are no "SKILL" files.

Details:

example .IL file:

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

.assembly extern System.Console
{
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
  .ver 4:0:0:0
}
.assembly extern mscorlib { }
.assembly 'devdiv_815942_' {}
.assembly extern xunit.core {}

.class public Repro
{
    .method public static int32 Main() cil managed
    {
        .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
            01 00 00 00
        )
        // This testcase ensures that we correctly compare a double local
        // against a float const by converting the float const to double
        // instead of converting the local to float and losing precision
  
        .entrypoint
        .locals init (float64 V_1)
        ldc.i4.1
        conv.i8
        call       float64 [mscorlib]System.BitConverter::Int64BitsToDouble(int64)
        conv.r8
        stloc.0
        ldloc.0
        ldc.r4     0.0
        bne.un.s   PASS
        ldstr      "FAIL!"
        call       void [System.Console]System.Console::WriteLine(string)
        ldloc.0
        call       void [System.Console]System.Console::WriteLine(float64)
        ldc.i4.s   101
        ret
PASS:
        ldstr      "PASS!"
        call       void [System.Console]System.Console::WriteLine(string)
        ldc.i4.s   100
        ret
    }
}

more info: https://en.wikipedia.org/wiki/Common_Intermediate_Language

@AlDanial
Copy link
Owner

Sure, I'll be able to add a fix that supports both .NET IL and SKILL. Cases where file extensions collide mean I'll need to write a disambiguation function but that shouldn't be hard as SKILL doesn't used braces.

Will be a few days before I have time though.

AlDanial added a commit that referenced this issue Jan 24, 2025
new disambiguation function SKILL_or_DotNetIL(); add test
for SKILL
@AlDanial
Copy link
Owner

Give 37dea80 a try

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

No branches or pull requests

2 participants