1 /*----------------------------------------------------------------------------
2 ChucK Concurrent, On-the-fly Audio Programming Language
3 Compiler and Virtual Machine
5 Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved.
6 http://chuck.cs.princeton.edu/
7 http://soundlab.cs.princeton.edu/
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 -----------------------------------------------------------------------------*/
25 //-----------------------------------------------------------------------------
26 // file: chuck_compile.h
27 // desc: chuck compile system unifying parser, type checker, and emitter
29 // author: Ge Wang (gewang@cs.princeton.edu)
30 // Perry R. Cook (prc@cs.princeton.edu)
31 // date: Autumn 2005 - original
32 //-----------------------------------------------------------------------------
33 #ifndef __CHUCK_COMPILE_H__
34 #define __CHUCK_COMPILE_H__
36 #include "chuck_def.h"
37 #include "chuck_parse.h"
38 #include "chuck_scan.h"
39 #include "chuck_type.h"
40 #include "chuck_emit.h"
46 //-----------------------------------------------------------------------------
47 // name: struct Chuck_Compiler
48 // desc: the sum of the components in compilation
49 //-----------------------------------------------------------------------------
53 // type-checking environment
56 Chuck_Emitter
* emitter
;
61 t_CKBOOL m_auto_depend
;
63 std::map
<std::string
, Chuck_Context
*> m_recent
;
69 virtual ~Chuck_Compiler();
72 t_CKBOOL
initialize( Chuck_VM
* vm
);
77 void set_auto_depend( t_CKBOOL v
);
78 // parse, type-check, and emit a program
79 t_CKBOOL
go( const std::string
& filename
, FILE * fd
= NULL
, const char * str_src
= NULL
);
80 // resolve a type automatically, if auto_depend is on
81 t_CKBOOL
resolve( const std::string
& type
);
82 // get the code generated from the last go()
83 Chuck_VM_Code
* output( );
85 protected: // internal
87 t_CKBOOL
do_entire_file( Chuck_Context
* context
);
88 // do just class definitions
89 t_CKBOOL
do_only_classes( Chuck_Context
* context
);
90 // do all excect classes
91 t_CKBOOL
do_all_except_classes( Chuck_Context
* context
);
93 t_CKBOOL
do_normal( const std::string
& path
, FILE * fd
= NULL
, const char * str_src
= NULL
);
95 Chuck_Context
* find_recent_path( const std::string
& path
);
97 Chuck_Context
* find_recent_type( const std::string
& type
);
99 t_CKBOOL
add_recent_path( const std::string
& path
, Chuck_Context
* context
);
103 // call this to detach all open files
104 extern "C" void all_detach();