*** empty log message ***
[chuck-blob.git] / v2 / chuck_type.h
blobbfc249f83c1d80c4a4d66a6b363044455a026ac7
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_type.h
27 // desc: chuck type-system / type-checker
29 // author: Ge Wang (gewang@cs.princeton.edu)
30 // Perry R. Cook (prc@cs.princeton.edu)
31 // date: Autumn 2002 - original
32 // Autumn 2004 - rewrite
33 //-----------------------------------------------------------------------------
34 #ifndef __CHUCK_TYPE_H__
35 #define __CHUCK_TYPE_H__
37 #include "chuck_def.h"
38 #include "chuck_absyn.h"
39 #include "chuck_oo.h"
40 #include "chuck_dl.h"
41 #include "chuck_errmsg.h"
45 //-----------------------------------------------------------------------------
46 // name: enum te_Type
47 // desc: basic, default ChucK types
48 //-----------------------------------------------------------------------------
49 typedef enum {
50 // general types
51 te_int, te_uint, te_single, te_float, te_double, te_time, te_dur,
52 te_complex, te_polar, te_string, te_thread, te_shred, te_class,
53 te_function, te_object, te_user, te_array, te_null, te_ugen, te_uana,
54 te_event, te_void, te_stdout, te_stderr, te_adc, te_dac, te_bunghole,
55 te_uanablob, te_io, te_fileio, te_multi
56 } te_Type;
61 //-----------------------------------------------------------------------------
62 // name: enum te_HowMuch
63 // desc: how much to scan/type check
64 //-----------------------------------------------------------------------------
65 typedef enum {
66 te_do_all = 0, te_do_classes_only, te_do_no_classes
67 } te_HowMuch;
72 //-----------------------------------------------------------------------------
73 // name: struct Chuck_Scope
74 // desc: scoping structure
75 //-----------------------------------------------------------------------------
76 template <class T>
77 struct Chuck_Scope
79 public:
80 // constructor
81 Chuck_Scope() { this->push(); }
82 // desctructor
83 ~Chuck_Scope() { this->pop(); }
85 // push scope
86 void push() { scope.push_back( new std::map<S_Symbol, Chuck_VM_Object *> ); }
88 // pop scope
89 void pop()
91 assert( scope.size() != 0 );
92 // TODO: release contents of scope.back()
93 delete scope.back(); scope.pop_back();
96 // reset the scope
97 void reset()
98 { scope.clear(); this->push(); }
100 // atomic commit
101 void commit()
103 assert( scope.size() != 0 );
104 std::map<S_Symbol, Chuck_VM_Object *>::iterator iter;
106 // go through buffer
107 for( iter = commit_map.begin(); iter != commit_map.end(); iter++ )
109 // add to front/where
110 (*scope.front())[(*iter).first] = (*iter).second;
113 // clear
114 commit_map.clear();
117 // roll back since last commit or beginning
118 void rollback()
120 assert( scope.size() != 0 );
121 std::map<S_Symbol, Chuck_VM_Object *>::iterator iter;
123 // go through buffer
124 for( iter = commit_map.begin(); iter != commit_map.end(); iter++ )
126 // release
127 (*iter).second->release();
130 // clear
131 commit_map.clear();
134 // add
135 void add( const std::string & xid, Chuck_VM_Object * value )
136 { this->add( insert_symbol(xid.c_str()), value ); }
137 void add( S_Symbol xid, Chuck_VM_Object * value )
139 assert( scope.size() != 0 );
140 // add if back is NOT front
141 if( scope.back() != scope.front() )
142 (*scope.back())[xid] = value;
143 // add for commit
144 else commit_map[xid] = value;
145 // add reference
146 SAFE_ADD_REF(value);
149 // lookup id
150 T operator []( const std::string & xid )
151 { return (T)this->lookup( xid ); }
152 T lookup( const std::string & xid, t_CKINT climb = 1 )
153 { return (T)this->lookup( insert_symbol(xid.c_str()), climb ); }
154 // -1 base, 0 current, 1 climb
155 T lookup( S_Symbol xid, t_CKINT climb = 1 )
157 Chuck_VM_Object * val = NULL; assert( scope.size() != 0 );
159 if( climb == 0 )
161 val = (*scope.back())[xid];
162 // look in commit buffer if the back is the front
163 if( !val && scope.back() == scope.front()
164 && (commit_map.find(xid) != commit_map.end()) )
165 val = commit_map[xid];
167 else if( climb > 0 )
169 for( t_CKUINT i = scope.size(); i > 0; i-- )
170 { if( val = (*scope[i-1])[xid] ) break; }
172 // look in commit buffer
173 if( !val && (commit_map.find(xid) != commit_map.end()) )
174 val = commit_map[xid];
176 else
178 val = (*scope.front())[xid];
179 // look in commit buffer
180 if( !val && (commit_map.find(xid) != commit_map.end()) )
181 val = commit_map[xid];
184 return (T)val;
187 // get list of top level
188 void get_toplevel( std::vector<Chuck_VM_Object *> & out )
190 assert( scope.size() != 0 );
191 std::map<S_Symbol, Chuck_VM_Object *>::iterator iter;
193 // clear the out
194 out.clear();
195 // get the front of the array
196 std::map<S_Symbol, Chuck_VM_Object *> * m = scope.front();
198 // go through map
199 for( iter = m->begin(); iter != m->end(); iter++ )
201 // add
202 out.push_back( (*iter).second );
206 protected:
207 std::vector<std::map<S_Symbol, Chuck_VM_Object *> *> scope;
208 std::map<S_Symbol, Chuck_VM_Object *> commit_map;
212 // forward reference
213 struct Chuck_Type;
214 struct Chuck_Value;
215 struct Chuck_Func;
216 struct Chuck_Multi;
217 struct Chuck_VM;
218 struct Chuck_VM_Code;
220 struct Chuck_DLL;
223 //-----------------------------------------------------------------------------
224 // name: struct Chuck_Namespace
225 // desc: Chuck Namespace containing semantic information
226 //-----------------------------------------------------------------------------
227 struct Chuck_Namespace : public Chuck_VM_Object
229 // maps
230 Chuck_Scope<Chuck_Type *> type;
231 Chuck_Scope<Chuck_Value *> value;
232 Chuck_Scope<Chuck_Func *> func;
234 // virtual table
235 Chuck_VTable obj_v_table;
236 // static data segment
237 t_CKBYTE * class_data;
238 // static data segment size
239 t_CKUINT class_data_size;
241 // name
242 std::string name;
243 // top-level code
244 Chuck_VM_Code * pre_ctor;
245 // destructor
246 Chuck_VM_Code * dtor;
247 // type that contains this
248 Chuck_Namespace * parent;
249 // address offset
250 t_CKUINT offset;
252 // constructor
253 Chuck_Namespace() { pre_ctor = NULL; dtor = NULL; parent = NULL; offset = 0;
254 class_data = NULL; class_data_size = 0; }
255 // destructor
256 virtual ~Chuck_Namespace() {
257 /* TODO: SAFE_RELEASE( this->parent ); */
258 /* TODO: SAFE_DELETE( pre_ctor ); */
259 /* TODO: SAFE_DELETE( dtor ); */
262 // look up type
263 Chuck_Type * lookup_type( const std::string & name, t_CKINT climb = 1 );
264 Chuck_Type * lookup_type( S_Symbol name, t_CKINT climb = 1 );
265 // look up value
266 Chuck_Value * lookup_value( const std::string & name, t_CKINT climb = 1 );
267 Chuck_Value * lookup_value( S_Symbol name, t_CKINT climb = 1 );
268 // look up func
269 Chuck_Func * lookup_func( const std::string & name, t_CKINT climb = 1 );
270 Chuck_Func * lookup_func( S_Symbol name, t_CKINT climb = 1 );
272 // commit the maps
273 void commit() {
274 EM_log( CK_LOG_FINER, "committing namespace: '%s'...", name.c_str() );
275 type.commit(); value.commit(); func.commit();
278 // rollback the maps
279 void rollback() {
280 EM_log( CK_LOG_FINER, "rolling back namespace: '%s'...", name.c_str() );
281 type.rollback(); value.rollback(); func.rollback();
284 // get top level types
285 void get_types( std::vector<Chuck_Type *> & out );
286 // get top level values
287 void get_values( std::vector<Chuck_Value *> & out );
288 // get top level functions
289 void get_funcs( std::vector<Chuck_Func *> & out );
295 //-----------------------------------------------------------------------------
296 // name: struct Chuck_Context
297 // desc: runtime type information pertaining to a file
298 //-----------------------------------------------------------------------------
299 struct Chuck_Context : public Chuck_VM_Object
301 // src_name
302 std::string filename;
303 // parse tree
304 a_Program parse_tree;
305 // context namespace
306 Chuck_Namespace * nspc;
307 // public class def if any
308 a_Class_Def public_class_def;
309 // error - means to free nspc too
310 t_CKBOOL has_error;
312 // progress
313 enum { P_NONE = 0, P_CLASSES_ONLY, P_ALL };
314 // progress in scan / type check / emit
315 t_CKUINT progress;
317 // things to release with the context
318 std::vector<Chuck_VM_Object *> new_types;
319 std::vector<Chuck_VM_Object *> new_values;
320 std::vector<Chuck_VM_Object *> new_funcs;
321 std::vector<Chuck_VM_Object *> new_nspc;
323 // commit map
324 std::map<Chuck_Namespace *, Chuck_Namespace *> commit_map;
325 // add for commit/rollback
326 void add_commit_candidate( Chuck_Namespace * nspc );
327 // commit
328 void commit();
329 // rollback
330 void rollback();
332 // constructor
333 Chuck_Context() { parse_tree = NULL; nspc = new Chuck_Namespace;
334 public_class_def = NULL; has_error = FALSE;
335 progress = P_NONE; }
336 // destructor
337 virtual ~Chuck_Context();
338 // get the top-level code
339 Chuck_VM_Code * code() { return nspc->pre_ctor; }
341 // special alloc
342 Chuck_Type * new_Chuck_Type();
343 Chuck_Value * new_Chuck_Value( Chuck_Type * t, const std::string & name );
344 Chuck_Func * new_Chuck_Func();
345 Chuck_Namespace * new_Chuck_Namespace();
351 //-----------------------------------------------------------------------------
352 // name: struct Chuck_Env
353 // desc: chuck env with type info
354 //-----------------------------------------------------------------------------
355 struct Chuck_Env : public Chuck_VM_Object
357 public:
358 static t_CKBOOL startup();
359 static Chuck_Env * instance();
360 static t_CKBOOL shutdown();
362 private:
363 static Chuck_Env * our_instance;
364 // constructor
365 Chuck_Env( )
367 // lock from being deleted
368 global_context.lock();
369 // make reference
370 context = &global_context; SAFE_ADD_REF(context);
371 // make name
372 context->filename = "@[global]";
373 // remember
374 global_nspc = global_context.nspc; SAFE_ADD_REF(global_nspc);
375 // deprecated stuff
376 deprecated.clear(); deprecate_level = 1;
377 // clear
378 this->reset();
381 protected:
382 // global namespace
383 Chuck_Namespace * global_nspc;
384 // global context
385 Chuck_Context global_context;
387 public:
388 // global namespace
389 Chuck_Namespace * global() { return global_nspc; }
390 // namespace stack
391 std::vector<Chuck_Namespace *> nspc_stack;
392 // expression namespace
393 Chuck_Namespace * curr;
394 // class stack
395 std::vector<Chuck_Type *> class_stack;
396 // current class definition
397 Chuck_Type * class_def;
398 // current function definition
399 Chuck_Func * func;
400 // how far nested in a class definition
401 t_CKUINT class_scope;
403 // current contexts in memory
404 std::vector<Chuck_Context *> contexts;
405 // current context
406 Chuck_Context * context;
408 // control scope (for break, continue)
409 std::vector<a_Stmt> breaks;
411 // reserved words
412 std::map<std::string, t_CKBOOL> key_words;
413 std::map<std::string, t_CKBOOL> key_types;
414 std::map<std::string, t_CKBOOL> key_values;
416 // deprecated types
417 std::map<std::string, std::string> deprecated;
418 // level - 0:stop, 1:warn, 2:ignore
419 t_CKINT deprecate_level;
421 // destructor
422 virtual ~Chuck_Env() { }
424 // reset
425 void reset( )
427 // TODO: release stack items?
428 nspc_stack.clear(); nspc_stack.push_back( this->global() );
429 // TODO: release stack items?
430 class_stack.clear(); class_stack.push_back( NULL );
431 // should be at top level
432 assert( context == &global_context );
433 // assign : TODO: release curr? class_def? func?
434 // TODO: need another function, since this is called from constructor
435 curr = this->global(); class_def = NULL; func = NULL;
436 // make sure this is 0
437 class_scope = 0;
440 // top
441 Chuck_Namespace * nspc_top( )
442 { assert( nspc_stack.size() > 0 ); return nspc_stack.back(); }
443 Chuck_Type * class_top( )
444 { assert( class_stack.size() > 0 ); return class_stack.back(); }
450 //-----------------------------------------------------------------------------
451 // name: struct Chuck_UGen_Info
452 // desc: ugen info stored with ugen types
453 //-----------------------------------------------------------------------------
454 struct Chuck_UGen_Info : public Chuck_VM_Object
456 // tick function pointer
457 f_tick tick;
458 // pmsg function pointer
459 f_pmsg pmsg;
460 // number of incoming channels
461 t_CKUINT num_ins;
462 // number of outgoing channels
463 t_CKUINT num_outs;
465 // for uana, NULL for ugen
466 f_tock tock;
467 // number of incoming ana channels
468 t_CKUINT num_ins_ana;
469 // number of outgoing channels
470 t_CKUINT num_outs_ana;
472 // constructor
473 Chuck_UGen_Info()
474 { tick = NULL; pmsg = NULL; num_ins = num_outs = 1;
475 tock = NULL; num_ins_ana = num_outs_ana = 1; }
481 //-----------------------------------------------------------------------------
482 // name: struct Chuck_Type
483 // desc: class containing information about a type
484 //-----------------------------------------------------------------------------_id
485 struct Chuck_Type : public Chuck_VM_Object
487 // type id
488 te_Type xid;
489 // type name
490 std::string name;
491 // type parent (could be NULL)
492 Chuck_Type * parent;
493 // size (in bytes)
494 t_CKUINT size;
495 // owner of the type
496 Chuck_Namespace * owner;
497 // array type
498 union { Chuck_Type * array_type; Chuck_Type * actual_type; };
499 // array size (equals 0 means not array, else dimension of array)
500 t_CKUINT array_depth;
501 // object size (size in memory)
502 t_CKUINT obj_size;
503 // type info
504 Chuck_Namespace * info;
505 // func info
506 Chuck_Func * func;
507 // def
508 a_Class_Def def;
509 // ugen
510 Chuck_UGen_Info * ugen_info;
511 // copy
512 t_CKBOOL is_copy;
513 // defined
514 t_CKBOOL is_complete;
515 // has pre constructor
516 t_CKBOOL has_constructor;
517 // has destructor
518 t_CKBOOL has_destructor;
520 public:
521 // constructor
522 Chuck_Type( te_Type _id = te_null, const std::string & _n = "",
523 Chuck_Type * _p = NULL, t_CKUINT _s = 0 )
525 xid = _id; name = _n; parent = _p; size = _s; owner = NULL;
526 array_type = NULL; array_depth = 0; obj_size = 0;
527 info = NULL; func = NULL; def = NULL; is_copy = FALSE;
528 ugen_info = NULL; is_complete = TRUE; has_constructor = FALSE;
529 has_destructor = FALSE;
532 // destructor
533 virtual ~Chuck_Type() { reset(); }
535 // reset
536 void reset()
538 // fprintf( stderr, "type: %s %i\n", c_name(), (t_CKUINT)this );
539 xid = te_void;
540 size = array_depth = obj_size = 0;
541 is_copy = FALSE;
543 // free only if not locked: to prevent garbage collection after exit
544 if( !this->m_locked )
546 // TODO: uncomment this, fix it to behave correctly
547 // release references
548 // SAFE_RELEASE(parent);
549 // SAFE_RELEASE(array_type);
550 SAFE_RELEASE(info);
551 // SAFE_RELEASE(owner);
552 // SAFE_RELEASE(func);
553 // SAFE_RELEASE(ugen_info);
557 // assignment - this does not touch the Chuck_VM_Object
558 const Chuck_Type & operator =( const Chuck_Type & rhs )
560 // release first
561 this->reset();
563 // copy
564 this->xid = rhs.xid;
565 this->name = rhs.name;
566 this->parent = rhs.parent;
567 this->obj_size = rhs.obj_size;
568 this->size = rhs.size;
569 this->def = rhs.def;
570 this->is_copy = TRUE;
571 this->array_depth = rhs.array_depth;
572 this->array_type = rhs.array_type;
573 // SAFE_ADD_REF(this->array_type);
574 this->func = rhs.func;
575 // SAFE_ADD_REF(this->func);
576 this->info = rhs.info;
577 SAFE_ADD_REF(this->info);
578 this->owner = rhs.owner;
579 // SAFE_ADD_REF(this->owner);
581 return *this;
584 // copy
585 Chuck_Type * copy( Chuck_Env * env ) const
586 { Chuck_Type * n = env->context->new_Chuck_Type();
587 *n = *this; return n; }
589 // to string
590 std::string ret;
591 const std::string & str()
592 { ret = name;
593 for( t_CKUINT i = 0; i < array_depth; i++ ) ret += std::string("[]");
594 return ret; }
595 // to c
596 const char * c_name()
597 { return str().c_str(); }
603 //-----------------------------------------------------------------------------
604 // name: struct Chuck_Value
605 // desc: a variable in scope
606 //-----------------------------------------------------------------------------
607 struct Chuck_Value : public Chuck_VM_Object
609 // type
610 Chuck_Type * type;
611 // name
612 std::string name;
613 // offset
614 t_CKUINT offset;
615 // addr
616 void * addr;
617 // const?
618 t_CKBOOL is_const;
619 // member?
620 t_CKBOOL is_member;
621 // static?
622 t_CKBOOL is_static; // do something
623 // is context-global?
624 t_CKBOOL is_context_global;
625 // is decl checked
626 t_CKBOOL is_decl_checked;
627 // 0 = public, 1 = protected, 2 = private
628 t_CKUINT access;
629 // owner
630 Chuck_Namespace * owner;
631 // owner (class)
632 Chuck_Type * owner_class;
633 // remember function pointer - if this is a function
634 Chuck_Func * func_ref;
635 // overloads
636 t_CKINT func_num_overloads;
638 // constructor
639 Chuck_Value( Chuck_Type * t, const std::string & n, void * a = NULL,
640 t_CKBOOL c = FALSE, t_CKBOOL acc = 0, Chuck_Namespace * o = NULL,
641 Chuck_Type * oc = NULL, t_CKUINT s = 0 )
642 { type = t; SAFE_ADD_REF(type); // add reference
643 name = n; offset = s;
644 is_const = c; access = acc;
645 owner = o; SAFE_ADD_REF(o); // add reference
646 owner_class = oc; SAFE_ADD_REF(oc); // add reference
647 addr = a; is_member = FALSE;
648 is_static = FALSE; is_context_global = FALSE;
649 is_decl_checked = TRUE; // only set to false in certain cases
650 func_ref = NULL; func_num_overloads = 0; }
652 // destructor
653 virtual ~Chuck_Value()
655 // release
656 // SAFE_RELEASE( type );
657 // SAFE_RELEASE( owner ):
658 // SAFE_RELEASE( owner_class );
659 // SAFE_RELEASE( func_ref );
666 //-----------------------------------------------------------------------------
667 // name: struct Chuck_Func
668 // desc: function definition
669 //-----------------------------------------------------------------------------
670 struct Chuck_Func : public Chuck_VM_Object
672 // name
673 std::string name;
674 // func def from parser
675 a_Func_Def def;
676 // code
677 Chuck_VM_Code * code;
678 // imported code
679 Chuck_DL_Func * dl_code;
680 // member
681 t_CKBOOL is_member;
682 // virtual table index
683 t_CKUINT vt_index;
684 // rember value
685 Chuck_Value * value_ref;
686 // for overloading
687 Chuck_Func * next;
688 // for overriding
689 Chuck_Value * up;
691 // constructor
692 Chuck_Func() { def = NULL; code = NULL; is_member = FALSE; vt_index = 0xffffffff;
693 value_ref = NULL; dl_code = NULL; next = NULL; up = NULL; }
695 // destructor
696 virtual ~Chuck_Func()
703 //-----------------------------------------------------------------------------
704 // primary chuck type checker interface
705 //-----------------------------------------------------------------------------
706 // initialize the type engine
707 Chuck_Env * type_engine_init( Chuck_VM * vm );
708 // shutdown the type engine
709 void type_engine_shutdown( Chuck_Env * env );
710 // load a context to be type-checked or emitted
711 t_CKBOOL type_engine_load_context( Chuck_Env * env, Chuck_Context * context );
712 // unload a context after being emitted
713 t_CKBOOL type_engine_unload_context( Chuck_Env * env );
715 // type check a program into the env
716 t_CKBOOL type_engine_check_prog( Chuck_Env * env, a_Program prog,
717 const std::string & filename );
718 // make a context
719 Chuck_Context * type_engine_make_context( a_Program prog,
720 const std::string & filename );
721 // type check a context into the env
722 t_CKBOOL type_engine_check_context( Chuck_Env * env,
723 Chuck_Context * context,
724 te_HowMuch how_much = te_do_all );
725 // type check a statement
726 t_CKBOOL type_engine_check_stmt( Chuck_Env * env, a_Stmt stmt );
727 // type check an expression
728 t_CKTYPE type_engine_check_exp( Chuck_Env * env, a_Exp exp );
729 // add an chuck dll into the env
730 t_CKBOOL type_engine_add_dll( Chuck_Env * env, Chuck_DLL * dll, const std::string & nspc );
731 // type equality
732 t_CKBOOL operator ==( const Chuck_Type & lhs, const Chuck_Type & rhs );
733 t_CKBOOL operator !=( const Chuck_Type & lhs, const Chuck_Type & rhs );
734 t_CKBOOL equals( Chuck_Type * lhs, Chuck_Type * rhs );
735 t_CKBOOL operator <=( const Chuck_Type & lhs, const Chuck_Type & rhs );
736 t_CKBOOL isa( Chuck_Type * lhs, Chuck_Type * rhs );
737 t_CKBOOL isprim( Chuck_Type * type );
738 t_CKBOOL isobj( Chuck_Type * type );
739 t_CKBOOL isfunc( Chuck_Type * type );
741 // import
742 Chuck_Type * type_engine_import_class_begin( Chuck_Env * env, Chuck_Type * type,
743 Chuck_Namespace * where, f_ctor pre_ctor, f_dtor dtor = NULL );
744 Chuck_Type * type_engine_import_class_begin( Chuck_Env * env, const char * name, const char * parent,
745 Chuck_Namespace * where, f_ctor pre_ctor, f_dtor dtor = NULL );
746 Chuck_Type * type_engine_import_ugen_begin( Chuck_Env * env, const char * name, const char * parent,
747 Chuck_Namespace * where, f_ctor pre_ctor, f_dtor dtor,
748 f_tick tick, f_pmsg pmsg,
749 t_CKUINT num_ins = 0xffffffff, t_CKUINT num_outs = 0xffffffff );
750 Chuck_Type * type_engine_import_uana_begin( Chuck_Env * env, const char * name, const char * parent,
751 Chuck_Namespace * where, f_ctor pre_ctor, f_dtor dtor,
752 f_tick tick, f_tock tock, f_pmsg pmsg,
753 t_CKUINT num_ins = 0xffffffff, t_CKUINT num_outs = 0xffffffff,
754 t_CKUINT num_ins_ana = 0xffffffff, t_CKUINT num_outs_ana = 0xffffffff );
755 t_CKBOOL type_engine_import_mfun( Chuck_Env * env, Chuck_DL_Func * mfun );
756 t_CKBOOL type_engine_import_sfun( Chuck_Env * env, Chuck_DL_Func * sfun );
757 t_CKUINT type_engine_import_mvar( Chuck_Env * env, const char * type,
758 const char * name, t_CKUINT is_const );
759 t_CKBOOL type_engine_import_svar( Chuck_Env * env, const char * type,
760 const char * name, t_CKUINT is_const,
761 t_CKUINT addr );
762 t_CKBOOL type_engine_import_ugen_ctrl( Chuck_Env * env, const char * type, const char * name,
763 f_ctrl ctrl, t_CKBOOL write, t_CKBOOL read );
764 t_CKBOOL type_engine_import_class_end( Chuck_Env * env );
765 t_CKBOOL type_engine_register_deprecate( Chuck_Env * env,
766 const std::string & former, const std::string & latter );
768 // helpers
769 t_CKBOOL type_engine_check_reserved( Chuck_Env * env, const std::string & xid, int pos );
770 t_CKBOOL type_engine_check_reserved( Chuck_Env * env, S_Symbol xid, int pos );
771 t_CKBOOL type_engine_check_primitive( Chuck_Type * type );
772 t_CKBOOL type_engine_compat_func( a_Func_Def lhs, a_Func_Def rhs, int pos, std::string & err, t_CKBOOL print = TRUE );
773 t_CKBOOL type_engine_get_deprecate( Chuck_Env * env, const std::string & from, std::string & to );
774 Chuck_Type * type_engine_find_common_anc( Chuck_Type * lhs, Chuck_Type * rhs );
775 Chuck_Type * type_engine_find_type( Chuck_Env * env, a_Id_List path );
776 Chuck_Value * type_engine_find_value( Chuck_Type * type, const std::string & xid );
777 Chuck_Value * type_engine_find_value( Chuck_Type * type, S_Symbol xid );
778 Chuck_Value * type_engine_find_value( Chuck_Env * env, const std::string & xid, t_CKBOOL climb, int linepos = 0 );
779 Chuck_Namespace * type_engine_find_nspc( Chuck_Env * env, a_Id_List path );
780 // array verify
781 t_CKBOOL verify_array( a_Array_Sub array );
782 // make array type
783 Chuck_Type * new_array_type( Chuck_Env * env, Chuck_Type * array_parent,
784 t_CKUINT depth, Chuck_Type * base_type,
785 Chuck_Namespace * owner_nspc );
786 // conversion
787 const char * type_path( a_Id_List path );
788 a_Id_List str2list( const std::string & path );
789 a_Id_List str2list( const std::string & path, t_CKBOOL & is_array );
790 const char * howmuch2str( te_HowMuch how_much );
791 t_CKBOOL escape_str( char * str_lit, int linepos );
793 // default types
794 extern Chuck_Type t_void;
795 extern Chuck_Type t_int;
796 extern Chuck_Type t_float;
797 extern Chuck_Type t_time;
798 extern Chuck_Type t_dur;
799 extern Chuck_Type t_complex;
800 extern Chuck_Type t_polar;
801 extern Chuck_Type t_object;
802 extern Chuck_Type t_null;
803 extern Chuck_Type t_string;
804 extern Chuck_Type t_array;
805 extern Chuck_Type t_shred;
806 extern Chuck_Type t_thread;
807 extern Chuck_Type t_function;
808 extern Chuck_Type t_class;
809 extern Chuck_Type t_event;
810 extern Chuck_Type t_io;
811 extern Chuck_Type t_fileio;
812 extern Chuck_Type t_ugen;
813 extern Chuck_Type t_uana;
814 extern Chuck_Type t_uanablob;
819 #endif