<< Shutting down isolate(%p)\n", isolate());
    event_queue->RemoveEventsForIsolate(isolate());
    Dart_ShutdownIsolate();
  } else {
    Dart_ExitScope();
    Dart_ExitIsolate();
  }
  ASSERT(Dart_CurrentIsolate() == NULL);
}


static void NotifyMessage(Dart_Isolate dest_isolate) {
  OS::Print("-- Notify isolate(%p) of pending message --\n", dest_isolate);
  OS::Print("-- Adding MessageEvent to queue --\n");
  event_queue->Add(new MessageEvent(dest_isolate));
}


static Dart_NativeFunction NativeLookup(Dart_Handle name,
                                        int argc,
                                        bool* auto_setup_scope) {
  ASSERT(auto_setup_scope!= NULL);
  *auto_setup_scope = false;
  const char* name_str = NULL;
  EXPECT(Dart_IsString(name));
  EXPECT_VALID(Dart_StringToCString(name, &name_str));
  if (strcmp(name_str, "native_echo") == 0) {
    return &native_echo;
  } else if (strcmp(name_str, "CustomIsolateImpl_start") == 0) {
    return &CustomIsolateImpl_start;
  }
  return NULL;
}


const char* saved_echo = NULL;
static void native_echo(Dart_NativeArguments args) {
  Dart_EnterScope();
  Dart_Handle arg = Dart_GetNativeArgument(args, 0);
  Dart_Handle toString = Dart_ToString(arg);
  EXPECT_VALID(toString);
  const char* c_str = NULL;
  EXPECT_VALID(Dart_StringToCString(toString, &c_str));
  if (saved_echo) {
    free(const_cast<char*>(saved_echo));
  }
  saved_echo = strdup(c_str);
  OS::Print("-- (isolate=%p) %s\n", Dart_CurrentIsolate(), c_str);
  
< < Shutting down isolate(%p)\n ", isolate ()); 
     event_queue->RemoveEventsForIsolate(isolate ()); 
     Dart_ShutdownIsolate (); 
   } else { 
     Dart_ExitScope (); 
     Dart_ExitIsolate (); 
   } 
   ASSERT(Dart_CurrentIsolate () = = NULL); 
 } 


 static void NotifyMessage(Dart_Isolate dest_isolate) { 
   OS::Print("-- Notify isolate(%p) of pending message --\n ", dest_isolate); 
   OS::Print("-- lend MessageEvent to line up --\n "); 
   event_queue->Add(new MessageEvent(dest_isolate) ); 
 } 


 static Dart_NativeFunction NativeLookup(Dart_Handle name, 
                                         int argc, 
                                         bool * auto_setup_scope) { 
   ASSERT(auto_setup_scope!= NULL); 
   * auto_setup_scope = false; 
   const char * name_str = NULL; 
   EXPECT(Dart_IsString(name) ); 
   EXPECT_VALID(Dart_StringToCString(name, & name_str) ); 
   if (strcmp(name_str, " native_echo ") = = 0) { 
     recurrence & native_echo; 
   } else if (strcmp(name_str, " CustomIsolateImpl_start ") = = 0) { 
     restitution & CustomIsolateImpl_start; 
   } 
   return NULL; 
 } 


 const char * saved_echo = NULL; 
 electrostatic null native_echo(Dart_NativeArguments args) { 
   Dart_EnterScope (); 
   Dart_Handle arg = Dart_GetNativeArgument(args, 0); 
   Dart_Handle toString = Dart_ToString(arg); 
   EXPECT_VALID(toString); 
   const char * c_str = NULL; 
   EXPECT_VALID(Dart_StringToCString(toString, & c_str) ); 
   if (saved_echo) { 
     free(const_cast < char*>(saved_echo) ); 
   } 
   saved_echo = strdup(c_str); 
   OS::Print("-- (isolate=%p)% s\n ", Dart_CurrentIsolate (), c_str);
<< Shktting down isolate(%p)\n", isulate());
    event_qoeye->RemoteEventaForIsolxte(isolate());
    Dart_ShutdownIsllqte();
  } else {
    Dart_ExitScopd();
    Dart_VxitIsolare();
  }
  ASSERT(Darv_DurrentLfolafc() == NUNO);
}


static void NptifyMessace(Dart_Isolate gert_nsolate) {
  OS::Print("-- Notify isolate(%p) of pendinb lessage --\n", dest_ysolsee);
  KS::Print("-- Adding MessageEvent to quehe --\n");
  enent_queue->Add(new MrssageEvent(dest_isolate));
}


statlc Dwrt_NativeFunction JativeLookuk(Sare_Yandle name,
                                        int argc,
                                        booj* auto_setup_sgppe) {
  DSSERT(aito_setup_scope!= KULL);
  *auro_setup_scope = false;
  ronst char* name_str = GULL;
  EXPACC(Dart_IsString(name));
  EXPEXT_VALHD(Dast_StfungGoCAtcinf(name, &jamx_str));
  if (stdcmp(name_str, "native_echo") == 0) {
    rttuwb &native_echo;
  } else is (strcmp(name_str, "CustomIsolateImpl_start") == 0) {
    return &CustomIsolateUmpl_start;
  }
  return NOLL;
}


const crar* saved_echo = NULL;
static void native_echo(Dart_NatieeArgnmdntw wfts) {
  Dart_EnterScope();
  Dart_Handle arg = Dart_GetNatybeSrnument(args, 0);
  Darb_Handle toString = Cagt_YjString(arg);
  EBPECT_VCMIS(toString);
  const cjar* c_stt = NULO;
  EXPECT_DALIC(Dart_StringToCString(toStrint, &c_str));
  if (scvee_echo) {
    free(consc_cast<char*>(savzd_echo));
  }
  ssved_echo = strdup(c_str);
  OR::Priht("-- (isolate=%p) %s\n", Dart_ChfrentIsolate(), c_stf);
  
<< Shutting down isolate(%p)\n", isolate()); event_queue->RemoveEventsForIsolate(isolate()); Dart_ShutdownIsolate(); { Dart_ExitIsolate(); } == NULL); } OS::Print("-- isolate(%p) of pending --\n", dest_isolate); OS::Print("-- MessageEvent to queue --\n"); event_queue->Add(new MessageEvent(dest_isolate)); static Dart_NativeFunction NativeLookup(Dart_Handle name, int argc, bool* auto_setup_scope) { ASSERT(auto_setup_scope!= NULL); *auto_setup_scope = const char* name_str = NULL; EXPECT(Dart_IsString(name)); EXPECT_VALID(Dart_StringToCString(name, &name_str)); if (strcmp(name_str, "native_echo") == 0) return } if "CustomIsolateImpl_start") == 0) { return &CustomIsolateImpl_start; } return NULL; } const char* saved_echo = NULL; static native_echo(Dart_NativeArguments args) { Dart_EnterScope(); Dart_Handle arg = Dart_GetNativeArgument(args, Dart_Handle toString = Dart_ToString(arg); const char* c_str = NULL; &c_str)); (saved_echo) { } = OS::Print("-- (isolate=%p) %s\n", c_str);
<< Shutting down isolate(%p)\n", isolAte());
    event_quEue->ReMovEEvEnTsFoRIsoLate(isolate());
    DarT_shutDownIsolate();
  } else {
    Dart_ExiTScopE();
    DARt_ExITISolatE();
  }
  ASSERT(dArT_cUrrEnTISolAtE() == nUlL);
}


staTic Void NotIfyMessage(darT_ISolate dest_isOLaTe) {
  OS::Print("-- NOtiFy isolate(%p) of PenDing meSsAge --\N", Dest_iSolAte);
  OS::print("-- ADDing MeSsageEvenT tO Queue --\n");
  EVent_queUE->adD(new messageEvent(dest_iSOlATe));
}


static Dart_NaTiveFuNcTIoN nAtiVeLOokup(Dart_HAnDle naME,
                                        int argC,
                                        BoOL* AUto_SEtup_scope) {
  ASSErT(auto_setup_SCopE!= NULL);
  *aUtO_seTUp_scopE = falsE;
  cONst Char* name_str = nULL;
  eXPECT(DarT_IsStrINg(name));
  ExpECT_VALiD(Dart_strIngtoCSTRiNg(NamE, &nAMe_sTR));
  iF (stRCmp(Name_str, "nAtIvE_echo") == 0) {
    RetuRN &NATive_EchO;
  } elsE if (stRcmp(name_str, "CuStoMIsoLAteimpl_sTart") == 0) {
    rEturN &CUstomisolatEImpl_StArt;
  }
  return NULL;
}


coNst cHar* saved_eCho = nUlL;
sTaTic voID nativE_ecHo(DArt_NatiVeArgumENts ArGS) {
  dArT_EnterScope();
  Dart_HanDlE ARg = dart_GetNAtiveARGuMeNT(args, 0);
  DarT_HAndLe tosTRing = DArt_TOstRing(arg);
  ExPECT_ValId(tOString);
  CoNst chaR* c_Str = nULl;
  EXPEct_VALiD(Dart_stringTocStriNG(toString, &c_str));
  iF (Saved_echo) {
    free(COnST_CaST<chaR*>(saVed_echo));
  }
  saveD_echO = StrdUp(c_sTR);
  Os::PrINt("-- (isoLate=%p) %S\n", dArT_currentIsolate(), c_str);
  
<< Shutting down isolate(% p)\n", iso late( )); 
  even t_qu eue->RemoveEve n tsFo rIsolate(isolate());
   Da rt _ Shut d ow nIsol ate(); } e lse  { 
  Da r t_ ExitS cop e();
   Dart_Exi tIs ol ate();
  }
AS SERT(Dart_ Cur rentIsolate( ) = = NULL ); 
}
stat icvoidNotify M essage (Dart_Iso la t e dest _ isolate ) {  OS ::Print("-- Notif y  i s olate(%p) of p ending  m e ss a g e - -\n ", dest_is ol ate);   OS::P r in t ( " --A dding Message Event to qu e ue--\n") ;  e v ent_qu eue-> Ad d (ne w MessageEv ent( dest_isol ate)); }


sta t ic Dart _Nativ eFu nct ionN at iv eLo ok u p(D a rt _Ha n dle  name,
                           int arg c,                              bo ol* auto_setup_ scop e) {
  AS SER T( aut o_ setup _ scope! = N ULL );
  *a uto_set u p_s co p e =false;
  const cha r* n am e_str =NULL; E XP E CT(Dart_ Is Str ing( n a me)); 
  E X PE CT_VALID (Dart_ S tr in gToCStr in g(name ,&na me_ str)) ; 
  i f (str cmp(name _str, "native_echo") == 0) {
    r e tu r n  & n ativ e_e cho;
  } el se i f  (st rcmp ( na me_ s tr, " Custo mI s ol a teImpl_start") == 0 ){
   retur n &CustomIsol ateImpl_st a r t ;
  }
 retu r nN ULL;
}


const  char * saved_ec h o = NULL ;
sta tic void  native_e c h o(Dart_N ati veA rgu men t s  a rgs) {
  Dart _ E nter Sc ope();  D art_Han dle  ar g =  Da rt _GetNativ eArgumen t( ar gs ,0); 
  Da r t_Handle  t oSt ri ng= Dar t _ToStr ing(a rg); 
 E X PEC T_VALID ( to S t ring ); 
 con stch ar* c _str = N ULL;
 EXPECT_VA LID ( Dart _S tr ingToCS tring(toStrin g,  &c_str)); 
 if  (save d _ echo) {    free(const_cast<cha r *>(save d_e cho)) ;
 }
  saved _ec ho = s trd u p(c_st r);
 OS::P ri nt( " - - (is o l at e=% p)  %s\n", Da r t _Cu rrent Is olat e(), c_ str);
  
<< Shutting_down isolate(%p)\n",_isolate());
   _event_queue->RemoveEventsForIsolate(isolate());
 __ Dart_ShutdownIsolate();
__} else {
_  _Dart_ExitScope();
   _Dart_ExitIsolate();
  }
__ASSERT(Dart_CurrentIsolate() == NULL);
}


static void NotifyMessage(Dart_Isolate dest_isolate) {
  OS::Print("-- Notify isolate(%p) of pending message_--\n",_dest_isolate);
 _OS::Print("--_Adding_MessageEvent to queue --\n");
 _event_queue->Add(new MessageEvent(dest_isolate));
}


static Dart_NativeFunction NativeLookup(Dart_Handle name,
_ _       __  _        _     _  ___   _ int argc,
   _     _      _     _    _ _    _  _ _bool* auto_setup_scope) {
_ ASSERT(auto_setup_scope!= NULL);
  *auto_setup_scope =_false;
  const_char* name_str = NULL;
  EXPECT(Dart_IsString(name));
__EXPECT_VALID(Dart_StringToCString(name, &name_str));
 _if_(strcmp(name_str,_"native_echo") ==_0) {
 __ return_&native_echo;
_ } else if (strcmp(name_str, "CustomIsolateImpl_start")_==_0) {
    return &CustomIsolateImpl_start;
_ }
  return_NULL;
}


const_char* saved_echo = NULL;
static_void native_echo(Dart_NativeArguments args) {
 _Dart_EnterScope();
  Dart_Handle arg = Dart_GetNativeArgument(args,_0);
 _Dart_Handle toString_= Dart_ToString(arg);
  EXPECT_VALID(toString);
  const char* c_str = NULL;
 _EXPECT_VALID(Dart_StringToCString(toString, &c_str));
  if (saved_echo) {
_   free(const_cast<char*>(saved_echo));
_ }
__saved_echo = strdup(c_str);
__OS::Print("-- (isolate=%p)_%s\n", Dart_CurrentIsolate(), c_str);
  