Code Monkey home page Code Monkey logo

Comments (7)

NalaGinrut avatar NalaGinrut commented on May 12, 2024 1

BTW, to perform type resolution correctly, I think the order should be:

name resolution -> macro expansion -> type resolution

But it's fine if we implement each step parallelly.

from gccrs.

bjorn3 avatar bjorn3 commented on May 12, 2024 1

Name resolution and macro expansion need to be interleaved for the following to work:

macro_rules! a {
    () => {
        macro_rules! b {
            () => {}
        }
    }
}

a!();
b!();
#![feature(decl_macro)]

macro a($b:ident) {
    macro $b() {}
}

b!();
a!(b);

from gccrs.

NalaGinrut avatar NalaGinrut commented on May 12, 2024 1

@philberty Yes, the pass, I think this term implies everything, extensible and can be disabled for certain purposes. We need a tiny framework for these passes (and options for disabling and debug), maybe we can do it after resolution an expansion.

from gccrs.

philberty avatar philberty commented on May 12, 2024

Yes this is a really good idea.

The way i envision things is many "Passes" and a pass i mean a Class using the ASTVisitor pattern and we have a state machine to work the work in there. We can even flesh out later with warning passes such as DeadCode recounting the names as it goes and when things go out of scope we iterate all nodes with a refcount == 0 as dead code.

I recently Added a simple pass rust-scan.cc which we will need in subsequent passes to know about global declarations as functions can be declared after they are used etc.

from gccrs.

NalaGinrut avatar NalaGinrut commented on May 12, 2024

@bjorn3 Ah yes, thanks for mention, I'll keep it.

from gccrs.

philberty avatar philberty commented on May 12, 2024

I have now pushed a big pr for the new resolution frameworks. For macros we need a toplevel name resolution pass and then we can do macro expansion. I will make some documentation on how the IDs are working to help.

from gccrs.

philberty avatar philberty commented on May 12, 2024

I will add documentation to the WIKI on how the resolution is working to be able to close this issue.

from gccrs.

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.