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

How to pass an extern object instance of type X as a parameter to a method call that is a method of type X #124

Open
jafingerhut opened this issue Oct 23, 2023 · 1 comment

Comments

@jafingerhut
Copy link
Collaborator

See the example program attached to this comment: p4lang/p4-spec#1262 (comment)

@jafingerhut
Copy link
Collaborator Author

This is related to a question raised by Mahesh Shirshyad's proposal for a PNA IP checksum extern object that could have a method, perhaps called something like add_dependency, where you could have multiple instance of the IP checksum extern object, and make explicit method calls in the P4 source code that declared data dependencies between these objects, e.g. you could do something like this:

    PNA_IPChecksum c1();
    PNA_IPChecksum c2();

    apply {

        // other code here to set up parameters for c1 and c2, e.g. perhaps start offset and length parameters.

        // in the case that the checksum for c1 included the result of checksum calculation for c2 as part of c1's input data
        // we would like to tell the compiler explicitly in code that this was the case, perhaps with a call like this:
        c1.add_dependency(c2);
        // meaning that c2's result should be calculated first, before c1's checksum calculation could finish.

    }

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