So this silly test case now works:

//------------------------------------------------------------------
// silly test of computed goto
proc fred () {
  println$ "Hello";
  var x = 10;
lab1:>
   println$ "Next";
   --x;
   var labvar = (label_address lab1);
   if x > 0 do
     goto-indirect labvar;
   done
}

fred;
//--------------------------------------------------------------

The syntax "label_address lab1" is a temporary hack.
I'm using "goto-indirect expr" for the computed goto.
Tested only with GCC (assembler labels).

This test relies on a number of things which are satisfied only by luck.
The generated C++ looks like this:


//PROCEDURE <36838:> _init_: Resume method
::flx::rtl::con_t *_init_::resume(){
  FLX_START_SWITCH(_init_)
      _i38392_v38392_x  = ::std::string("Hello"); //init
      _i38393_v38393_s  = stdout; //init
      _i38394_v38394_x  = _i38392_v38392_x; //init
      {
      _a10927t_44980 _tmp44994 = _i38394_v38394_x + ::std::string("\n") ;
      ::flx::rtl::ioutil::write(_i38393_v38393_s,_tmp44994);
      }
      _i38390_v38390_x = 10; //assign simple
    FLX_LABEL(44992,36838,_38388)
      _i38395_v38395_x  = ::std::string("Next"); //init
      s  = stdout; //init
      x  = _i38395_v38395_x; //init
      {
      _a10927t_44980 _tmp44995 = x + ::std::string("\n") ;
      ::flx::rtl::ioutil::write(s,_tmp44995);
      }
      {
      int* _tmp44996 = (int*)&_i38390_v38390_x;
      --*_tmp44996;
      }
      labvar = 
::flx::rtl::jump_address_t(this,FLX_FARTARGET(44992,36838,_38388)); //assign 
simple
      if(!((0 < _i38390_v38390_x))) goto _38389;
      FLX_DIRECT_LONG_JUMP(_init_, labvar)
    _38389:;
    FLX_RETURN
  FLX_END_SWITCH
}

One piece of luck: the argument #2 to the LONG_JUMP macro doesn't
contain any commas (macros can't handle that). I'll have to assign the 
expression
to a simple variable and use that instead.



--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to