History

partial fix for new static; DL version bump; .apropos => .help; new tests

Ge Wang committed 5 years ago

Commit 0ea97571 parent 891221219 files · +224 −51Browse files

Unified · Split

19 files
  1. examples/ah-help.ck +12 −12
  2. src/core/chuck_dl.cpp +9 −9
  3. src/core/chuck_dl.h +6 −6
  4. src/core/chuck_emit.cpp +20 −0
  5. src/core/chuck_emit.h +3 −0
  6. src/core/chuck_instr.cpp +35 −18
  7. src/core/chuck_lang.cpp +2 −2
  8. src/core/chuck_scan.cpp +16 −1
  9. src/core/chuck_type.h +6 −3
  10. src/core/chuck_vm.cpp +1 −0
  11. src/core/chuck_vm.h +2 −0
  12. src/test/01-Basic/100.ck +12 −0
  13. src/test/01-Basic/101.ck +14 −0
  14. src/test/01-Basic/102.ck +13 −0
  15. src/test/01-Basic/103.ck +15 −0
  16. src/test/01-Basic/104.ck +12 −0
  17. src/test/01-Basic/105.ck +14 −0
  18. src/test/01-Basic/106.ck +15 −0
  19. src/test/01-Basic/107.ck +17 −0
examples/ah-help.ckrenamed from examples/apropos.ck+12−12
@@ -1,7 +1,7 @@
1−// name: apropos.ck
1+// name: ah-help.ck
22 // (available in chuck-1.4.1.0 and later)
3−// desc: example showing .apropos(), which can be invoked on
4−// any object or class; .apropos() dynamically generates
3+// desc: example showing .help(), which can be invoked on
4+// any object or class; .help() dynamically generates
55 // information regarding the underlying type of an object
66 // or a class and outputs this information to the console.
77 // the information includes the inheritance chain of the
@@ -9,23 +9,23 @@ · 1 unmodified line
99 // inherited from its parent (and its parent's parent, and
1010 // so on).
1111 //
12−// .apropos() is designed to be a run-time teaching/learning tool
12+// .help() is designed to be a run-time teaching/learning tool
1313 // and a quick referencewhile programming. It's fun, sort of!
1414
1515 // an object/ugen instance
1616 SinOsc osc;
17−// call apropos() on it to learn about its underlying information
18−osc.apropos();
17+// call help() on it to learn about its underlying information
18+osc.help();
1919
20−// apropos() can be called directly on classes without instances
21−Machine.apropos();
20+// help() can be called directly on classes without instances
21+Machine.help();
2222
2323 // 2-d int array
2424 int a[10][10];
2525 // calling apropros on a 2d-array
26−a.apropos();
26+a.help();
2727 // calling apropros on an array
28−a[0].apropos();
28+a[0].help();
2929
3030 // a user-created class
3131 public class Foo
@@ -33,5 +33,5 @@ public class Foo · 1 unmodified line
3333 fun void bar()
3434 { <<< "hi" >>>; }
3535 }
36−// calling apropos() on the class
37−Foo.apropos();
36+// calling help() on the class
37+Foo.help();
src/core/chuck_dl.cpp+9−9
@@ -491,13 +491,13 @@ void CK_DLL_CALL ck_add_ugen_funcf_auto_num_channels( Chuck_DL_Query * query, · 490 unmodified lines
491491 // name: ck_add_ugen_ctrl()
492492 // desc: (ugen only) add ctrl parameters
493493 //-----------------------------------------------------------------------------
494−void CK_DLL_CALL ck_add_ugen_ctrl( Chuck_DL_Query * query, f_ctrl ugen_ctrl, f_cget ugen_cget,
495− const char * type, const char * name )
496−{
497− // this is no longer used
498− EM_error2( 0, "class import: obselete ck_add_ugen_ctrl invoked..." );
499− return;
500−
494+//void CK_DLL_CALL ck_add_ugen_ctrl( Chuck_DL_Query * query, f_ctrl ugen_ctrl, f_cget ugen_cget,
495+// const char * type, const char * name )
496+//{
497+// // this is no longer used
498+// EM_error2( 0, "class import: obselete ck_add_ugen_ctrl invoked..." );
499+// return;
500+//
501501 // // make sure there is class
502502 // if( !query->curr_class )
503503 // {
@@ -515,7 +515,7 @@ void CK_DLL_CALL ck_add_ugen_ctrl( Chuck_DL_Query * query, f_ctrl ugen_ctrl, f_c · 11 unmodified lines
515515 //
516516 // // set
517517 // query->curr_func = NULL;
518−}
518+//}
519519
520520
521521
@@ -950,7 +950,7 @@ Chuck_DL_Query::Chuck_DL_Query( Chuck_Carrier * carrier ) · 428 unmodified lines
950950 add_ugen_func = ck_add_ugen_func;
951951 add_ugen_funcf = ck_add_ugen_funcf;
952952 add_ugen_funcf_auto_num_channels = ck_add_ugen_funcf_auto_num_channels;
953− add_ugen_ctrl = ck_add_ugen_ctrl; // not used but needed for import for now
953+ // add_ugen_ctrl = ck_add_ugen_ctrl; // not used
954954 end_class = ck_end_class;
955955 doc_class = ck_doc_class;
956956 doc_func = ck_doc_func;
src/core/chuck_dl.h+6−6
@@ -46,9 +46,9 @@ · 45 unmodified lines
4646
4747
4848 // major version must be the same between chuck:chugin
49−#define CK_DLL_VERSION_MAJOR (0x0007)
49+#define CK_DLL_VERSION_MAJOR (0x0008)
5050 // minor version of chugin must be less than or equal to chuck's
51−#define CK_DLL_VERSION_MINOR (0x0001)
51+#define CK_DLL_VERSION_MINOR (0x0000)
5252 #define CK_DLL_VERSION_MAKE(maj,min) ((t_CKUINT)(((maj) << 16) | (min)))
5353 #define CK_DLL_VERSION_GETMAJOR(v) (((v) >> 16) & 0xFFFF)
5454 #define CK_DLL_VERSION_GETMINOR(v) ((v) & 0xFFFF)
@@ -303,9 +303,9 @@ typedef void (CK_DLL_CALL * f_add_arg)( Chuck_DL_Query * query, const char * typ · 248 unmodified lines
303303 typedef void (CK_DLL_CALL * f_add_ugen_func)( Chuck_DL_Query * query, f_tick tick, f_pmsg pmsg, t_CKUINT num_in, t_CKUINT num_out );
304304 typedef void (CK_DLL_CALL * f_add_ugen_funcf)( Chuck_DL_Query * query, f_tickf tickf, f_pmsg pmsg, t_CKUINT num_in, t_CKUINT num_out );
305305 typedef void (CK_DLL_CALL * f_add_ugen_funcf_auto_num_channels)( Chuck_DL_Query * query, f_tickf tickf, f_pmsg psmg );
306−// ** add a ugen control (not used but needed for import for now)
307−typedef void (CK_DLL_CALL * f_add_ugen_ctrl)( Chuck_DL_Query * query, f_ctrl ctrl, f_cget cget,
308− const char * type, const char * name );
306+// ** add a ugen control (not used) | 1.4.1.0 removed
307+//typedef void (CK_DLL_CALL * f_add_ugen_ctrl)( Chuck_DL_Query * query, f_ctrl ctrl, f_cget cget,
308+// const char * type, const char * name );
309309 // end class/namespace - must correspondent with begin_class. returns false on error
310310 typedef t_CKBOOL (CK_DLL_CALL * f_end_class)( Chuck_DL_Query * query );
311311 // create main thread hook- used for executing a "hook" function in the main thread of a primary chuck instance
@@ -369,7 +369,7 @@ public: · 57 unmodified lines
369369 // (ugen only) add tick and pmsg functions, specify channels by vm
370370 f_add_ugen_funcf_auto_num_channels add_ugen_funcf_auto_num_channels;
371371 // (ugen only) add ctrl parameters
372− f_add_ugen_ctrl add_ugen_ctrl; // not used but needed for import for now
372+ // f_add_ugen_ctrl add_ugen_ctrl; // not used but needed for import for now
373373 // end class/namespace, compile it
374374 f_end_class end_class;
375375
src/core/chuck_emit.cpp+20−0
@@ -294,6 +294,8 @@ Chuck_VM_Code * emit_to_code( Chuck_Code * in, · 293 unmodified lines
294294 code->stack_depth = in->stack_depth;
295295 // set whether code need this base pointer
296296 code->need_this = in->need_this;
297+ // set whether static inside class | 1.4.1.0 (ge) added
298+ code->is_static = in->is_static;
297299 // set name
298300 code->name = in->name;
299301 // set filename for me.sourceDir() (added 1.3.0.0)
@@ -3450,6 +3452,7 @@ t_CKBOOL emit_engine_emit_exp_func_call( Chuck_Emitter * emit, · 3150 unmodified lines
34503452 {
34513453 emit->append( instr = new Chuck_Instr_Func_Call );
34523454 }
3455+ // set line position
34533456 instr->set_linepos(linepos);
34543457
34553458 return TRUE;
@@ -4477,6 +4480,8 @@ t_CKBOOL emit_engine_emit_func_def( Chuck_Emitter * emit, a_Func_Def func_def ) · 1021 unmodified lines
44774480 emit->code->name += func->name + "( ... )";
44784481 // set whether need this
44794482 emit->code->need_this = func->is_member;
4483+ // if static inside class | 1.4.1.0 (ge) added
4484+ emit->code->is_static = func->is_static;
44804485 // keep track of full path (added 1.3.0.0)
44814486 emit->code->filename = emit->context->full_path;
44824487
@@ -4499,6 +4504,19 @@ t_CKBOOL emit_engine_emit_func_def( Chuck_Emitter * emit, a_Func_Def func_def ) · 16 unmodified lines
44994504 return FALSE;
45004505 }
45014506 }
4507+ // if static function inside class def | 1.4.1.0 (ge) added
4508+ else if( func->is_static )
4509+ {
4510+ // get the size (for the TYPE argument)
4511+ emit->code->stack_depth += sizeof(t_CKUINT);
4512+ // create local
4513+ if( !emit->alloc_local( sizeof(t_CKUINT), "@type", TRUE, FALSE, FALSE ) )
4514+ {
4515+ EM_error2( a->linepos,
4516+ "(emit): internal error: cannot allocate local '@type'..." );
4517+ return FALSE;
4518+ }
4519+ }
45024520
45034521 // ge: 2012 april: added push scope (added 1.3.0.0)
45044522 emit->push_scope();
@@ -4755,6 +4773,8 @@ t_CKBOOL emit_engine_emit_spork( Chuck_Emitter * emit, a_Exp_Func_Call exp ) · 250 unmodified lines
47554773 emit->code = new Chuck_Code;
47564774 // handle need this
47574775 emit->code->need_this = exp->ck_func->is_member;
4776+ // handle is static (inside class def) | 1.4.1.0 (ge) added
4777+ emit->code->is_static = exp->ck_func->is_static;
47584778 // name it: e.g. spork~foo [line 5]
47594779 std::ostringstream name;
47604780 name << "spork~"
src/core/chuck_emit.h+3−0
@@ -61,6 +61,8 @@ public: · 60 unmodified lines
6161 t_CKUINT stack_depth;
6262 // need this
6363 t_CKBOOL need_this;
64+ // is static (in class def) | 1.4.1.0 (ge) added
65+ t_CKBOOL is_static;
6466 // frame
6567 Chuck_Frame * frame;
6668 // code
@@ -81,6 +83,7 @@ public: · 14 unmodified lines
8183 {
8284 stack_depth = 0;
8385 need_this = FALSE;
86+ is_static = FALSE; // 1.4.1.0 (ge) added
8487 frame = new Chuck_Frame;
8588 }
8689
src/core/chuck_instr.cpp+35−18
@@ -1979,7 +1979,7 @@ void Chuck_Instr_Add_float_string_Assign::execute( Chuck_VM * vm, Chuck_VM_Shred · 1978 unmodified lines
19791979 null_pointer:
19801980 // we have a problem
19811981 CK_FPRINTF_STDERR(
1982− "[chuck](VM): NullPointerException: (string + string) on line[%lu] in shred[id=%lu:%s]\n",
1982+ "[chuck](VM): NullPointerException: (float + string) on line[%lu] in shred[id=%lu:%s]\n",
19831983 m_linepos, shred->xid, shred->name.c_str() );
19841984 goto done;
19851985
@@ -4485,7 +4485,7 @@ void Chuck_Instr_Func_Call::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) · 2499 unmodified lines
44854485 t_CKUINT *& mem_sp = (t_CKUINT *&)shred->mem->sp;
44864486 t_CKUINT *& reg_sp = (t_CKUINT *&)shred->reg->sp;
44874487
4488− // pop word
4488+ // pop words
44894489 pop_( reg_sp, 2 );
44904490 // get the function to be called as code
44914491 Chuck_VM_Code * func = (Chuck_VM_Code *)*reg_sp;
@@ -4533,6 +4533,14 @@ void Chuck_Instr_Func_Call::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) · 41 unmodified lines
45334533 // one less word to copy
45344534 stack_depth--;
45354535 }
4536+ // static inside class | 1.4.1.0 (ge) added
4537+ else if( func->is_static )
4538+ {
4539+ // copy type from end of arguments to the front
4540+ *mem_sp2++ = *(reg_sp2 + stack_depth - 1);
4541+ // one less word to copy
4542+ stack_depth--;
4543+ }
45364544
45374545 // push the arguments
45384546 for( t_CKUINT i = 0; i < stack_depth; i++ )
@@ -4680,17 +4688,14 @@ void Chuck_Instr_Func_Call_Static::execute( Chuck_VM * vm, Chuck_VM_Shred * shre · 141 unmodified lines
46804688 t_CKUINT *& reg_sp = (t_CKUINT *&)shred->reg->sp;
46814689 Chuck_DL_Return retval;
46824690
4683− // pop word | 1.4.1.0 (ge): pop an extra element as the base_type
4684− // this accompanies the introduction of TYPE to static function calls
4685− pop_( reg_sp, 3 );
4686− // get the base type
4687− Chuck_Type * base_type = (Chuck_Type *)*reg_sp;
4691+ // pop code and local depth
4692+ pop_( reg_sp, 2 );
46884693 // get the function to be called as code
4689− Chuck_VM_Code * func = (Chuck_VM_Code *)*(reg_sp+1);
4694+ Chuck_VM_Code * func = (Chuck_VM_Code *)*(reg_sp);
46904695 // get the function to be called
46914696 f_sfun f = (f_sfun)func->native_func;
46924697 // get the local stack depth - caller local variables
4693− t_CKUINT local_depth = *(reg_sp+2);
4698+ t_CKUINT local_depth = *(reg_sp+1);
46944699 // convert to number of int's (was: 4-byte words), extra partial word counts as additional word
46954700 local_depth = ( local_depth / sz_INT ) + ( local_depth & 0x3 ? 1 : 0 ); // ISSUE: 64-bit (fixed 1.3.1.0)
46964701 // get the stack depth of the callee function args
@@ -4699,7 +4704,7 @@ void Chuck_Instr_Func_Call_Static::execute( Chuck_VM * vm, Chuck_VM_Shred * shre · 2 unmodified lines
46994704 // UNUSED: t_CKUINT prev_stack = ( *(mem_sp-1) >> 2 ) + ( *(mem_sp-1) & 0x3 ? 1 : 0 );
47004705 // the amount to push in 4-byte words
47014706 t_CKUINT push = local_depth;
4702− // push the mem stack passed the current function variables and arguments
4707+ // push the mem stack past the current function variables and arguments
47034708 mem_sp += push;
47044709
47054710 // pass args
@@ -4712,13 +4717,11 @@ void Chuck_Instr_Func_Call_Static::execute( Chuck_VM * vm, Chuck_VM_Shred * shre · 6 unmodified lines
47124717 t_CKUINT * reg_sp2 = reg_sp;
47134718 t_CKUINT * mem_sp2 = mem_sp;
47144719
4715− // need this
4716− if( func->need_this )
4720+ // need type
4721+ if( func->is_static )
47174722 {
47184723 // copy this from end of arguments to the front
47194724 *mem_sp2++ = *(reg_sp2 + stack_depth - 1);
4720− // advance reg pointer
4721− reg_sp2++;
47224725 // one less word to copy
47234726 stack_depth--;
47244727 }
@@ -4733,7 +4736,7 @@ void Chuck_Instr_Func_Call_Static::execute( Chuck_VM * vm, Chuck_VM_Shred * shre · 8 unmodified lines
47334736 // call the function
47344737 // (added 1.3.0.0 -- Chuck_DL_Api::Api::instance())
47354738 // (added 1.4.1.0 -- base_type)
4736− f( base_type, mem_sp, &retval, vm, shred, Chuck_DL_Api::Api::instance() );
4739+ f( (Chuck_Type *)(*mem_sp), mem_sp+1, &retval, vm, shred, Chuck_DL_Api::Api::instance() );
47374740 // clean up memory stack
47384741 mem_sp -= push;
47394742
@@ -4818,6 +4821,7 @@ void Chuck_Instr_Spork::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) · 78 unmodified lines
48184821 {
48194822 t_CKUINT *& reg_sp = (t_CKUINT *&)shred->reg->sp;
48204823 t_CKUINT this_ptr = 0;
4824+ t_CKUINT type_ptr = 0;
48214825
48224826 // pop the stack
48234827 pop_( reg_sp, 1 );
@@ -4839,6 +4843,14 @@ void Chuck_Instr_Spork::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) · 15 unmodified lines
48394843 // add to shred so it's ref counted, and released when shred done (1.3.1.2)
48404844 sh->add_parent_ref( (Chuck_Object *)this_ptr );
48414845 }
4846+ // need @type (for static functions) | 1.4.1.0 (ge) added
4847+ else if( func->is_static )
4848+ {
4849+ // pop the stack
4850+ pop_( reg_sp, 1 );
4851+ // get type info
4852+ type_ptr = *reg_sp;
4853+ }
48424854 // copy args
48434855 if( m_val )
48444856 {
@@ -4852,6 +4864,11 @@ void Chuck_Instr_Spork::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) · 7 unmodified lines
48524864 {
48534865 push_( (t_CKUINT*&)sh->reg->sp, this_ptr );
48544866 }
4867+ // copy type info (for static functions) | 1.4.1.0 (ge) added
4868+ else if( func->is_static )
4869+ {
4870+ push_( (t_CKUINT*&)sh->reg->sp, type_ptr );
4871+ }
48554872 // copy func
48564873 push_( (t_CKUINT*&)sh->reg->sp, (t_CKUINT)func );
48574874 // push the stack
@@ -6308,10 +6325,10 @@ void Chuck_Instr_Dot_Static_Func::execute( Chuck_VM * vm, Chuck_VM_Shred * shred · 1450 unmodified lines
63086325 // register stack pointer
63096326 t_CKUINT *& sp = (t_CKUINT *&)shred->reg->sp;
63106327
6311− // pop the type pointer
6312− // pop_( sp, 1 );
63136328 // 1.4.1.0 (ge): leave the base type on the operand stack
6314−
6329+ // commented out: pop the type pointer
6330+ // pop_( sp, 1 );
6331+
63156332 // push the address
63166333 push_( sp, (t_CKUINT)(m_func) );
63176334 }
src/core/chuck_lang.cpp+2−2
@@ -86,8 +86,8 @@ t_CKBOOL init_class_object( Chuck_Env * env, Chuck_Type * type ) · 85 unmodified lines
8686 if( !type_engine_import_mfun( env, func ) ) goto error;
8787
8888 // add api()
89− func = make_new_sfun( "void", "apropos", object_apropos );
90− func->doc = "dynamically generate and output information about a class or object.";
89+ func = make_new_sfun( "void", "help", object_apropos );
90+ func->doc = "generate and output helpful information about a class or object.";
9191 if( !type_engine_import_sfun( env, func ) ) goto error;
9292
9393 // end the class import
src/core/chuck_scan.cpp+16−1
@@ -2506,6 +2506,9 @@ t_CKBOOL type_engine_scan2_func_def( Chuck_Env * env, a_Func_Def f ) · 2505 unmodified lines
25062506 // note whether the function is marked as member
25072507 func->is_member = (f->static_decl != ae_key_static) &&
25082508 (env->class_def != NULL);
2509+ // note whether the function is marked as static (in class)
2510+ func->is_static = (f->static_decl == ae_key_static) &&
2511+ (env->class_def != NULL);
25092512 // copy the native code, for imported functions
25102513 if( f->s_type == ae_func_builtin )
25112514 {
@@ -2513,6 +2516,9 @@ t_CKBOOL type_engine_scan2_func_def( Chuck_Env * env, a_Func_Def f ) · 1 unmodified line
25132516 func->code = new Chuck_VM_Code;
25142517 // whether the function needs 'this'
25152518 func->code->need_this = func->is_member;
2519+ // is static inside
2520+ func->code->is_static = (f->static_decl == ae_key_static) &&
2521+ (env->class_def != NULL);
25162522 // set the function pointer
25172523 func->code->native_func = (t_CKUINT)func->def->dl_func_ptr;
25182524 }
@@ -2571,7 +2577,16 @@ t_CKBOOL type_engine_scan2_func_def( Chuck_Env * env, a_Func_Def f ) · 52 unmodified lines
25712577 // count
25722578 count = 1;
25732579 // make room for 'this'
2574− f->stack_depth = func->is_member ? sizeof(void *) : 0;
2580+ if( func->is_member )
2581+ {
2582+ f->stack_depth = sizeof(void *);
2583+ }
2584+ else if( func->is_static ) // 1.4.1.0 (ge) added
2585+ {
2586+ // make room for '@type' for static functions inside class def
2587+ f->stack_depth = sizeof(void *);
2588+ }
2589+
25752590 // loop over arguments
25762591 while( arg_list )
25772592 {
src/core/chuck_type.h+6−3
@@ -694,7 +694,7 @@ struct Chuck_Value : public Chuck_VM_Object · 693 unmodified lines
694694 // member?
695695 t_CKBOOL is_member;
696696 // static?
697− t_CKBOOL is_static; // do something
697+ t_CKBOOL is_static; // do something
698698 // is context-global?
699699 t_CKBOOL is_context_global;
700700 // is decl checked
@@ -762,6 +762,8 @@ struct Chuck_Func : public Chuck_VM_Object · 61 unmodified lines
762762 // Chuck_DL_Func * dl_code;
763763 // member
764764 t_CKBOOL is_member;
765+ // static (inside class)
766+ t_CKBOOL is_static;
765767 // virtual table index
766768 t_CKUINT vt_index;
767769 // rember value
@@ -775,8 +777,9 @@ struct Chuck_Func : public Chuck_VM_Object · 7 unmodified lines
775777 std::string doc;
776778
777779 // constructor
778− Chuck_Func() { def = NULL; code = NULL; is_member = FALSE; vt_index = 0xffffffff;
779− value_ref = NULL; /*dl_code = NULL;*/ next = NULL; up = NULL; }
780+ Chuck_Func() { def = NULL; code = NULL; is_member = FALSE; is_static = FALSE,
781+ vt_index = 0xffffffff; value_ref = NULL; /*dl_code = NULL;*/ next = NULL;
782+ up = NULL; }
780783
781784 // destructor
782785 virtual ~Chuck_Func()
src/core/chuck_vm.cpp+1−0
@@ -1289,6 +1289,7 @@ Chuck_VM_Code::Chuck_VM_Code() · 1288 unmodified lines
12891289 num_instr = 0;
12901290 stack_depth = 0;
12911291 need_this = FALSE;
1292+ is_static = FALSE;
12921293 native_func = 0;
12931294 native_func_type = NATIVE_UNKNOWN;
12941295 }
src/core/chuck_vm.h+2−0
@@ -139,6 +139,8 @@ public: · 138 unmodified lines
139139 t_CKUINT stack_depth;
140140 // whether the function needs 'this' pointer or not
141141 t_CKBOOL need_this;
142+ // whether the function is a static function inside class
143+ t_CKBOOL is_static; // 1.4.1.0
142144 // native
143145 t_CKUINT native_func;
144146 // is ctor?
src/test/01-Basic/100.ck+12−0
@@ -0,0 +1,12 @@
1+// static function test: calling from class name (no instance)
2+
3+public class Foo
4+{
5+ fun static void foo( string s )
6+ {
7+ if( s == "bar" ) <<< "success">>>;
8+ }
9+}
10+
11+// call here
12+Foo.foo( "bar" );
src/test/01-Basic/101.ck+14−0
@@ -0,0 +1,14 @@
1+// static function test: calling from instance
2+
3+public class Foo
4+{
5+ fun static void foo( string s )
6+ {
7+ if( s == "bar" ) <<< "success">>>;
8+ }
9+}
10+
11+// instantiate
12+Foo f;
13+// call here
14+f.foo( "bar" );
src/test/01-Basic/102.ck+13−0
@@ -0,0 +1,13 @@
1+// static function test: sporking from class
2+
3+public class Foo
4+{
5+ fun static void foo( string s )
6+ { if( s == "bar") <<< "success" >>>; }
7+}
8+
9+// spork it
10+spork ~ Foo.foo( "bar" );
11+
12+// give it a chance to run
13+me.yield();
src/test/01-Basic/103.ck+15−0
@@ -0,0 +1,15 @@
1+// static function test: sporking using instance
2+
3+public class Foo
4+{
5+ fun static void foo( string s )
6+ { if( s == "bar") <<< "success" >>>; }
7+}
8+
9+// instantiate a Foo
10+Foo f;
11+// spork it
12+spork ~ f.foo( "bar" );
13+
14+// give it a chance to run
15+me.yield();
src/test/01-Basic/104.ck+12−0
@@ -0,0 +1,12 @@
1+// static function test: multiple arguments
2+
3+public class Foo
4+{
5+ fun static void foo( string a, int b, float c )
6+ {
7+ if( a == "bar" && b == 1 && c == 4.0 ) <<< "success" >>>;
8+ }
9+}
10+
11+// spork it
12+Foo.foo( "bar", 1, 4.0 );
src/test/01-Basic/105.ck+14−0
@@ -0,0 +1,14 @@
1+// static function test: multiple arguments from instance
2+
3+public class Foo
4+{
5+ fun static void foo( string a, int b, float c )
6+ {
7+ if( a == "bar" && b == 1 && c == 4.0 ) <<< "success" >>>;
8+ }
9+}
10+
11+// instantiate
12+Foo f;
13+// call it
14+f.foo( "bar", 1, 4.0 );
src/test/01-Basic/106.ck+15−0
@@ -0,0 +1,15 @@
1+// static function test: multiple arguments, sporked
2+
3+public class Foo
4+{
5+ fun static void foo( string a, int b, float c )
6+ {
7+ if( a == "bar" && b == 1 && c == 4.0 ) <<< "success" >>>;
8+ }
9+}
10+
11+// spork it
12+spork ~ Foo.foo( "bar", 1, 4.0 );
13+
14+// give it a chance to run
15+me.yield();
src/test/01-Basic/107.ck+17−0
@@ -0,0 +1,17 @@
1+// static function test: multiple arguments, sporked from instance
2+
3+public class Foo
4+{
5+ fun static void foo( string a, int b, float c )
6+ {
7+ if( a == "bar" && b == 1 && c == 4.0 ) <<< "success" >>>;
8+ }
9+}
10+
11+// instantiate f
12+Foo f;
13+// spork it
14+spork ~ f.foo( "bar", 1, 4.0 );
15+
16+// give it a chance to run
17+me.yield();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t