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

[Maybe Bug?]: cppfront doesn't capture class member variables in symbol table #1323

Open
vanceism7 opened this issue Oct 21, 2024 · 0 comments

Comments

@vanceism7
Copy link
Contributor

vanceism7 commented Oct 21, 2024

I noticed when looking at the symbol table from a cpp2 file, the member variables of a class aren't showing up. The member functions/methods of the class type do, but not the member variables themselves.

Here's a simple example:

Person: type = {
  public name: str = "waka";
  public age: int;
  dob: str;

  setName: (this, newName: str) -> void = {
    this.name = newName;
  }
}

And here's the symbol table output if you run cppfront with the debug option

---------------------------------------------------------------------------
declaration_of: size 6
   & tok            #tok    & sym            identifier      #tok  in_curr_fn prev_was_this & this_param_sym
   00A2A608    2 -> 00A0EA80           Person   2  0          0             00000000
   00A2A878   13 -> 00A0EB10          newName  13  1          0             00000000
   00A2A848   11 -> 00A0EAEC             this  11  1          0             00000000
   00A2A800   10 -> 00A0EAC8          setName  10  0          0             00000000
   00A2A998   20 -> 00A0EB10          newName  13  1          0             00000000
   00A2A938   16 -> 00A0EAEC             this  11  1          0             00000000

---------------------------------------------------------------------------
symbols: size 15
   idx     tok#       & symbol       dep
     0 |      2 |         00A0EA80 |   0 |  type Person
     1 |      0 |         00A0EAA4 |   1 |    scope
     2 |     10 |         00A0EAC8 |   2 |      function setName
     3 |     11 |         00A0EAEC |   3 |        var this
     4 |     13 |         00A0EB10 |   3 |        var newName
     5 |      0 |         00A0EB34 |   3 |        scope
     6 |     16 |         00A0EB58 |   4 |          *** (7,5) DEFINITE LAST POTENTIALLY MOVING USE OF *** use of this
     7 |     20 |         00A0EB7C |   4 |          *** (7,17) DEFINITE LAST POTENTIALLY MOVING USE OF *** use of newName
     8 |      0 |         00A0EBA0 |   4 |          /scope
     9 |     11 |         00A0EBC4 |   3 |        *** use of this
    10 |     13 |         00A0EBE8 |   3 |        *** use of newName
    11 |      0 |         00A0EC0C |   3 |        /function 
    12 |     10 |         00A0EC30 |   2 |      *** use of setName
    13 |      0 |         00A0EC54 |   2 |      /scope
    14 |      0 |         00A0EC78 |   1 |    /type 

From the above table, you can see that the parameters from the setName function are captured, along with setName itself, but name, age, and dob are not captured in the table. These declarations are captured in the tokens parsing, but they never make it into sema (atleast, they didn't make it into sema as far as I've seen).

Is this a bug or is it intentional? (or maybe they are being captured somewhere and I'm just badly mistaken?)

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

1 participant