Git Product home page Git Product logo

Comments (5)

jyn514 avatar jyn514 commented on July 30, 2024

Error is different since 5b2bcaf:

struct s { int i; }
thread 'main' panicked at 'not yet implemented: struct and union members', src/parse/decl.rs:578:9

from saltwater.

jyn514 avatar jyn514 commented on July 30, 2024

Enums are done since ddc165c!

from saltwater.

jyn514 avatar jyn514 commented on July 30, 2024

Struct and union declarations are done since 44a13ce. Need to implement expressions and codegen.

struct s { int i; } s;
int main() {
        return s.i;
}
thread 'main' panicked at 'not yet implemented: struct and union members are very much not implemented', src/parse/expr.rs:706:33

from saltwater.

jyn514 avatar jyn514 commented on July 30, 2024

Possible ways to implement this:

Have a cache in ir::LLVMCompiler that stores offsets into structs. For unions, the offset is always zero. The size of a struct is the greatest offset + sizeof(member at that offset). Accessing a struct member is fetching *(s + offset).

Ways to calculate the offset: For now, just do sizeof(member) + (8-sizeof(member))%8, i.e. round up to the nearest multiple of the alignment.
In the future, sort members from largest size to smallest, excluding arrays. Put chars, shorts in spare bytes. Prohibited by the C standard, see section 6.7.2.1.

from saltwater.

jyn514 avatar jyn514 commented on July 30, 2024

Done in 01f53f2!!!

from saltwater.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.