*** empty log message ***
[chuck-blob.git] / v2 / chuck_compile.h
blobec68fa5d1ea622e43622b26302b43072748a7d35
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
22 U.S.A.
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"
41 #include "chuck_vm.h"
46 //-----------------------------------------------------------------------------
47 // name: struct Chuck_Compiler
48 // desc: the sum of the components in compilation
49 //-----------------------------------------------------------------------------
50 struct Chuck_Compiler
52 public: // data
53 // type-checking environment
54 Chuck_Env * env;
55 // emitter
56 Chuck_Emitter * emitter;
57 // generated code
58 Chuck_VM_Code * code;
60 // auto-depend flag
61 t_CKBOOL m_auto_depend;
62 // recent map
63 std::map<std::string, Chuck_Context *> m_recent;
65 public: // to all
66 // contructor
67 Chuck_Compiler();
68 // destructor
69 virtual ~Chuck_Compiler();
71 // initialize
72 t_CKBOOL initialize( Chuck_VM * vm );
73 // shutdown
74 void shutdown();
76 // set auto depend
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
86 // do entire file
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 );
92 // do normal compile
93 t_CKBOOL do_normal( const std::string & path, FILE * fd = NULL, const char * str_src = NULL );
94 // look up in recent
95 Chuck_Context * find_recent_path( const std::string & path );
96 // look up in recent
97 Chuck_Context * find_recent_type( const std::string & type );
98 // add to recent
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();
109 #endif