| 1 | /*---------------------------------------------------------------------------- |
| 2 | ChucK Strongly-timed Audio Programming Language |
| 3 | Compiler, Virtual Machine, and Synthesis Engine |
| 4 | |
| 5 | Copyright (c) 2003 Ge Wang and Perry R. Cook. All rights reserved. |
| 6 | http://chuck.stanford.edu/ |
| 7 | http://chuck.cs.princeton.edu/ |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or modify |
| 10 | it under the dual-license terms of EITHER the MIT License OR the GNU |
| 11 | General Public License (the latter as published by the Free Software |
| 12 | Foundation; either version 2 of the License or, at your option, any |
| 13 | later version). |
| 14 | |
| 15 | This program is distributed in the hope that it will be useful and/or |
| 16 | interesting, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 17 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | MIT Licence and/or the GNU General Public License for details. |
| 19 | |
| 20 | You should have received a copy of the MIT License and the GNU General |
| 21 | Public License (GPL) along with this program; a copy of the GPL can also |
| 22 | be obtained by writing to the Free Software Foundation, Inc., 59 Temple |
| 23 | Place, Suite 330, Boston, MA 02111-1307 U.S.A. |
| 24 | -----------------------------------------------------------------------------*/ |
| 25 | |
| 26 | //----------------------------------------------------------------------------- |
| 27 | // file: chuck_frame.h |
| 28 | // desc: chuck scope frame |
| 29 | // |
| 30 | // author: Ge Wang ([email protected] | [email protected]) |
| 31 | // date: Autumn 2002 |
| 32 | //----------------------------------------------------------------------------- |
| 33 | #ifndef __CHUCK_FRAME_H__ |
| 34 | #define __CHUCK_FRAME_H__ |
| 35 | |
| 36 | #include "chuck_def.h" |
| 37 | |
| 38 | #include <string> |
| 39 | #include <vector> |
| 40 | |
| 41 | |
| 42 | //----------------------------------------------------------------------------- |
| 43 | // name: struct Chuck_Local |
| 44 | // desc: ... |
| 45 | //----------------------------------------------------------------------------- |
| 46 | struct Chuck_Local |
| 47 | { |
| 48 | // name |
| 49 | std::string name; |
| 50 | // the size of the local |
| 51 | t_CKUINT size; |
| 52 | // is ref |
| 53 | t_CKBOOL is_ref; |
| 54 | // is an object type (added ge: 2012 april | added 1.3.0.0) |
| 55 | t_CKBOOL is_obj; |
| 56 | // REFACTOR-2017: is a global variable; global type |
| 57 | t_CKBOOL is_global; |
| 58 | // the offset |
| 59 | t_CKUINT offset; |
| 60 | |
| 61 | // constructor |
| 62 | Chuck_Local() |
| 63 | // (added 1.3.0.0 -- is_obj) |
| 64 | { size = 0; is_ref = FALSE; is_obj = FALSE; is_global = FALSE; offset = 0; } |
| 65 | }; |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | //----------------------------------------------------------------------------- |
| 71 | // name: struct Chuck_Frame |
| 72 | // desc: ... |
| 73 | //----------------------------------------------------------------------------- |
| 74 | struct Chuck_Frame |
| 75 | { |
| 76 | // yes |
| 77 | std::string name; |
| 78 | // the offset |
| 79 | t_CKUINT curr_offset; |
| 80 | // not sure |
| 81 | t_CKUINT num_access; |
| 82 | // offset stack |
| 83 | std::vector<Chuck_Local *> stack; |
| 84 | |
| 85 | public: |
| 86 | Chuck_Frame(); |
| 87 | ~Chuck_Frame() { } |
| 88 | |
| 89 | public: |
| 90 | // push scope |
| 91 | void push_scope(); |
| 92 | // add local (added 1.3.0.0 -- is_obj) |
| 93 | Chuck_Local * alloc_local( t_CKUINT size, const std::string & name, |
| 94 | t_CKBOOL is_ref, t_CKBOOL is_obj, t_CKBOOL is_global ); |
| 95 | // get the current scope (added 1.3.0.0) |
| 96 | void get_scope( std::vector<Chuck_Local *> & out, bool localOnly = true ) const; |
| 97 | // pop scope |
| 98 | void pop_scope( std::vector<Chuck_Local *> & out ); |
| 99 | }; |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | #endif |