A CIL Tutorial - Department of Computer Science - ETH Zürich

A CIL Tutorial - Department of Computer Science - ETH Zürich A CIL Tutorial - Department of Computer Science - ETH Zürich

29.01.2014 Views

Copyright c○2013 Zachary Anderson This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/. The source code snippets listed in this work are licensed under the BSD 3-Clause license, whose details can be found in the LICENSE le of the source code repository at http://bitbucket.org/zanderso/cil-template/.

Contents Preface 4 Introduction 5 0 Overview and Organization 8 0.1 Source le to AST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 0.2 tut0.ml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1 The AST 11 1.1 tut1.ml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.2 Printing the AST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.3 test/tut1.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2 Visiting the AST 16 2.1 tut2.ml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.2 test/tut2.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3 Dataow Analysis 21 3.1 tut3.ml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.2 test/tut3.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 3.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 3.4 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 4 Instrumentation 36 4.1 tut4.ml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 4.2 tut4.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 4.3 test/tut4.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 4.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 5 Interpreted Constructors 42 5.1 tut5.ml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 5.2 test/tut5.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 1

Copyright c○2013 Zachary Anderson<br />

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0<br />

Unported License. To view a copy <strong>of</strong> this license, visit<br />

http://creativecommons.org/licenses/by-nc-sa/3.0/.<br />

The source code snippets listed in this work are licensed under the BSD 3-Clause license, whose details<br />

can be found in the LICENSE le <strong>of</strong> the source code repository at<br />

http://bitbucket.org/zanderso/cil-template/.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!