calling variadic functions from a strongly typed language
play

Calling Variadic Functions from a Strongly Typed Language Matthias - PowerPoint PPT Presentation

Calling Variadic Functions from a Strongly Typed Language Matthias Blume Toyota Technological Institute at Chicago Mike Rainey University of Chicago John Reppy University of Chicago Variadic functions in C int printf (const char *, ...); M.


  1. Calling Variadic Functions from a Strongly Typed Language Matthias Blume Toyota Technological Institute at Chicago Mike Rainey University of Chicago John Reppy University of Chicago

  2. Variadic functions in C int printf (const char *, ...); M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  3. Variadic functions in C int printf (const char *, ...); printf (“%d”, 10); M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  4. Variadic functions in C int printf (const char *, ...); printf (“%d”, 10); printf (“%g: %d(%f)\n”, 10.0, 3, 0.25); M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  5. Outline • Why are we doing this? • How does calling variadic functions work in C? • Why doesn’t the same approach work in ML? • Located Arguments via Staged Allocation: Our solution to the (low-level part of the) problem • Conclusions • High-level interface via “Danvy-style” typing M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  6. Outline • Why are we doing this? • How does calling variadic functions work in C? • Why doesn’t the same approach work in ML? • Located Arguments via Staged Allocation: Our solution to the (low-level part of the) problem • Conclusions • High-level interface via “Danvy-style” typing M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  7. Outline • Why are we doing this? • How does calling variadic functions work in C? • Why doesn’t the same approach work in ML? • Located Arguments via Staged Allocation: Our solution to the (low-level part of the) problem • Conclusions • High-level interface via “Danvy-style” typing M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  8. Outline • Why are we doing this? • How does calling variadic functions work in C? • Why doesn’t the same approach work in ML? • Located Arguments via Staged Allocation: Our solution to the (low-level part of the) problem • Conclusions • High-level interface via “Danvy-style” typing M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  9. Outline • Why are we doing this? • How does calling variadic functions work in C? • Why doesn’t the same approach work in ML? • Located Arguments via Staged Allocation: Our solution to the (low-level part of the) problem • Conclusions • High-level interface via “Danvy-style” typing M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  10. Outline • Why are we doing this? • How does calling variadic functions work in C? • Why doesn’t the same approach work in ML? • Located Arguments via Staged Allocation: Our solution to the (low-level part of the) problem • Conclusions • High-level interface via “Danvy-style” typing M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  11. Outline • Why are we doing this? • How does calling variadic functions work in C? • Why doesn’t the same approach work in ML? • Located Arguments via Staged Allocation: Our solution to the (low-level part of the) problem • Conclusions • High-level interface via “Danvy-style” typing M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  12. Outline • Why are we doing this? • How does calling variadic functions work in C? • Why doesn’t the same approach work in ML? • Located Arguments via Staged Allocation: Our solution to the (low-level part of the) problem • Conclusions • High-level interface via “Danvy-style” typing M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  13. Why? M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  14. Why? • Being able to call printf ? • no M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  15. Why? • Being able to call printf ? • no • Utility: • Some APIs rely heavily on variadic functions M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  16. Why? • Being able to call printf ? • no • Utility: • Some APIs rely heavily on variadic functions • Completeness: • NLFFI models the entire C type system - but (until now) with the single exception of variadic functions M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  17. Calling a fixed-arity C function Call: j = f (i, x, w, c, p); Prototype: int f (int, double, float, char, void *); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  18. Calling a fixed-arity C function Call: j = f (i, x, w, c, p); Prototype: int f (int, double, float, char, void *); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  19. Calling a fixed-arity C function Call: j = f (i, x, w, c, p); Prototype: int f (int, double, float, char, void *); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  20. Calling a fixed-arity C function Call: j = f (i, x, w, c, p); Prototype: int f (int, double, float, char, void *); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  21. Calling a fixed-arity C function Call: j = f (i, x, w, c, p); Prototype: int f (int, double, float, char, void *); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  22. Calling a fixed-arity C function Call: j = f (i, x, w, c, p); Prototype: int f (int, double, float, char, void *); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  23. Calling a fixed-arity C function Call: j = f (i, x, w, c, p); Prototype: int f (int, double, float, char, void *); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  24. Calling a fixed-arity C function Call: j = f (i, x, w, c, p); Prototype: int f (int, double, float, char, void *); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  25. Calling a fixed-arity C function Call: j = f (i, x, w, c, p); Prototype: int f (int, double, float, char, void *); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  26. Calling a variadic function from C Call: j = f (i, x, w, c, p); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  27. Calling a variadic function from C Types: int i; double x; float w; char c; void *p; Call: j = f (i, x, w, c, p); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  28. Calling a variadic function from C Types: int i; double x; float w; char c; void *p; Call: j = f (i, x, w, c, p); implied Prototype : int f (int, double, double, int, void *); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  29. Calling a variadic function from C Types: int i; double x; float w; char c; void *p; Call: j = f (i, x, w, c, p); implied Prototype : int f (int, double, double, int, void *); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

  30. Calling a variadic function from C Types: int i; double x; float w; char c; void *p; Call: j = f (i, x, w, c, p); implied Prototype : int f (int, double, double, int, void *); r0 (sp) f0 f01 r1 (ra) f1 r2 f2 f23 r3 f3 M. Blume, M. Rainey, J. Reppy Calling Variadic Functions from a Strongly-Typed Language ML’08, Victoria BC, Sep 21, 2008

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend