/* generated by Id 1.1 at ,$ */ /* with the command: -I../stage1/ -I../st80 -c StringIO.st -o ../stage2/StringIO.o.c */ #include static struct __libid *_libid= 0; #ifdef ID_DEBUG # define _enter(info) void *__id_debug= _libid->enter(info) # define _line(lno) _libid->line(lno) # define _leave() _libid->leave(__id_debug) # define _backtrace() _libid->backtrace() #else # define _enter(info) (void)info # define _line(lno) # define _leave() # define _backtrace() "(no debugging information)\n" #endif #define _return _leave(); return #define _sendv(MSG, N, RCV, ARG...) ({ \ struct __send _s= { (MSG), (N), (RCV) }; \ ((_imp_t)(_libid->bindv(&_s)))(&_s, _s.receiver, _s.receiver, ##ARG); \ }) #define _superv(TYP, MSG, N, RCV, ARG...) ({ \ struct __send _s= { (MSG), (N), (TYP) }; \ _imp_t _imp= _libid->bindv(&_s); \ _s.receiver= (RCV); \ _imp(&_s, _s.receiver, _s.receiver, ##ARG); \ }) static oop s_new_5f_= 0; static oop s_new_= 0; static oop s__2a= 0; static oop s_contents= 0; static oop s_baseName= 0; static oop s_value_5f_= 0; static oop s__5fimport_= 0; static oop s_on_= 0; static oop s_do_= 0; static oop s_last= 0; static oop s_ifTrue_= 0; static oop s_flattened= 0; static oop s__2c= 0; static oop s_size= 0; static oop s_first= 0; static oop s__3d_3d= 0; static oop s_removeLast= 0; static oop s_nextPut_= 0; static oop s__5fclone= 0; static oop s__5fcString= 0; static oop s_isEmpty= 0; static oop s_size_5f_value_5f_= 0; static oop s_ifTrue_ifFalse_= 0; static oop s_directoryName= 0; static oop s_absolutePathName= 0; static oop s_isReadableFile= 0; static oop s_findFileSearching_withSuffixes_ifError_= 0; static oop s_function_5f_arity_5f_outer_state_nlr_5f_= 0; static oop s_findFileSearching_withSuffixes_= 0; static oop s_delimited_= 0; static oop s_osErrorString= 0; static oop s_readFromFileNamed_ifError_= 0; static oop s_readFromFileNamed_= 0; static oop s_fileContents= 0; static oop s_writeToFileNamed_ifError_= 0; static oop s_writeToFileNamed_= 0; static oop s_strftimeNow= 0; static oop s_strftimeZulu= 0; static oop s_dateStamp= 0; static oop s_timeStamp= 0; static oop s_dateAndTimeStamp= 0; static oop s_error_= 0; static oop s_value= 0; static oop s_dateAndTimeZoneStamp= 0; static oop s_dateAndTimeZuluStamp= 0; static oop s_tokenized_= 0; static oop s_escaped= 0; static struct _Selector { const char *name; oop *addr; } _Selectors[]= { { "new_:", &s_new_5f_ }, { "new:", &s_new_ }, { "*", &s__2a }, { "contents", &s_contents }, { "baseName", &s_baseName }, { "value_:", &s_value_5f_ }, { "_import:", &s__5fimport_ }, { "on:", &s_on_ }, { "do:", &s_do_ }, { "last", &s_last }, { "ifTrue:", &s_ifTrue_ }, { "flattened", &s_flattened }, { ",", &s__2c }, { "size", &s_size }, { "first", &s_first }, { "==", &s__3d_3d }, { "removeLast", &s_removeLast }, { "nextPut:", &s_nextPut_ }, { "_clone", &s__5fclone }, { "_cString", &s__5fcString }, { "isEmpty", &s_isEmpty }, { "size_:value_:", &s_size_5f_value_5f_ }, { "ifTrue:ifFalse:", &s_ifTrue_ifFalse_ }, { "directoryName", &s_directoryName }, { "absolutePathName", &s_absolutePathName }, { "isReadableFile", &s_isReadableFile }, { "findFileSearching:withSuffixes:ifError:", &s_findFileSearching_withSuffixes_ifError_ }, { "function_:arity_:outer:state:nlr_:", &s_function_5f_arity_5f_outer_state_nlr_5f_ }, { "findFileSearching:withSuffixes:", &s_findFileSearching_withSuffixes_ }, { "delimited:", &s_delimited_ }, { "osErrorString", &s_osErrorString }, { "readFromFileNamed:ifError:", &s_readFromFileNamed_ifError_ }, { "readFromFileNamed:", &s_readFromFileNamed_ }, { "fileContents", &s_fileContents }, { "writeToFileNamed:ifError:", &s_writeToFileNamed_ifError_ }, { "writeToFileNamed:", &s_writeToFileNamed_ }, { "strftimeNow", &s_strftimeNow }, { "strftimeZulu", &s_strftimeZulu }, { "dateStamp", &s_dateStamp }, { "timeStamp", &s_timeStamp }, { "dateAndTimeStamp", &s_dateAndTimeStamp }, { "error:", &s_error_ }, { "value", &s_value }, { "dateAndTimeZoneStamp", &s_dateAndTimeZoneStamp }, { "dateAndTimeZuluStamp", &s_dateAndTimeZuluStamp }, { "tokenized:", &s_tokenized_ }, { "escaped", &s_escaped }, { 0, 0 } }; struct t__object { struct _vtable *_vtable[0]; }; struct t__selector { struct _vtable *_vtable[0]; oop v__size; oop v__elements; }; struct t__assoc { struct _vtable *_vtable[0]; oop v_key; oop v_value; }; struct t__closure { struct _vtable *_vtable[0]; oop v__method; oop v_data; }; struct t__vector { struct _vtable *_vtable[0]; oop v__size; }; struct t__vtable { struct _vtable *_vtable[0]; oop v__tally; oop v_bindings; oop v_delegate; }; struct t_Object { struct _vtable *_vtable[0]; }; struct t_UndefinedObject { struct _vtable *_vtable[0]; }; struct t_StaticBlockClosure { struct _vtable *_vtable[0]; oop v__function; oop v__arity; }; struct t_BlockClosure { struct _vtable *_vtable[0]; oop v__function; oop v__arity; oop v_outer; oop v_state; oop v__nlr; }; struct t_Magnitude { struct _vtable *_vtable[0]; }; struct t_Character { struct _vtable *_vtable[0]; oop v_value; }; struct t_Number { struct _vtable *_vtable[0]; }; struct t_Fraction { struct _vtable *_vtable[0]; oop v_numerator; oop v_denominator; }; struct t_Float { struct _vtable *_vtable[0]; }; struct t_Integer { struct _vtable *_vtable[0]; }; struct t_SmallInteger { struct _vtable *_vtable[0]; }; struct t_LargePositiveInteger { struct _vtable *_vtable[0]; oop v_bytes; }; struct t_LargeNegativeInteger { struct _vtable *_vtable[0]; oop v_bytes; }; struct t_Collection { struct _vtable *_vtable[0]; }; struct t_SequenceableCollection { struct _vtable *_vtable[0]; }; struct t_ArrayedCollection { struct _vtable *_vtable[0]; oop v_size; }; struct t_Array { struct _vtable *_vtable[0]; oop v_size; oop v__pointers; }; struct t_ImmutableArray { struct _vtable *_vtable[0]; oop v_size; oop v__pointers; }; struct t_WordArray { struct _vtable *_vtable[0]; oop v_size; oop v__words; }; struct t_ImmutableWordArray { struct _vtable *_vtable[0]; oop v_size; oop v__words; }; struct t_ByteArray { struct _vtable *_vtable[0]; oop v_size; oop v__bytes; }; struct t_ImmutableByteArray { struct _vtable *_vtable[0]; oop v_size; oop v__bytes; }; struct t_String { struct _vtable *_vtable[0]; oop v_size; oop v__bytes; }; struct t_ImmutableString { struct _vtable *_vtable[0]; oop v_size; oop v__bytes; }; struct t_Symbol { struct _vtable *_vtable[0]; oop v_size; oop v__bytes; }; struct t_nil { struct _vtable *_vtable[0]; }; struct t_true { struct _vtable *_vtable[0]; }; struct t_false { struct _vtable *_vtable[0]; }; struct t_CharacterTable { struct _vtable *_vtable[0]; oop v_size; oop v__pointers; }; struct t_Smalltalk { struct _vtable *_vtable[0]; oop v_argumentCount; oop v_argumentVector; }; struct t_OrderedCollection { struct _vtable *_vtable[0]; oop v_array; oop v_firstIndex; oop v_lastIndex; }; struct t_Stream { struct _vtable *_vtable[0]; }; struct t_PositionableStream { struct _vtable *_vtable[0]; oop v_collection; oop v_position; oop v_readLimit; }; struct t_WriteStream { struct _vtable *_vtable[0]; oop v_collection; oop v_position; oop v_readLimit; oop v_writeLimit; }; static oop l_3= 0; static oop l_4= 0; static oop l_6= 0; static oop l_10= 0; static oop l_11= 0; static oop l_12= 0; static oop l_15= 0; static oop l_18= 0; static oop l_22= 0; static oop l_27= 0; static oop l_31= 0; static oop l_33= 0; static oop l_35= 0; static oop l_37= 0; static oop l_39= 0; static oop l_41= 0; static oop l_43= 0; static oop v__object= 0; static oop v__vector= 0; static oop v_Object= 0; static oop v_UndefinedObject= 0; static oop v_StaticBlockClosure= 0; static oop v_BlockClosure= 0; static oop v_Magnitude= 0; static oop v_Character= 0; static oop v_Number= 0; static oop v_Integer= 0; static oop v_SmallInteger= 0; static oop v_LargePositiveInteger= 0; static oop v_Collection= 0; static oop v_SequenceableCollection= 0; static oop v_ArrayedCollection= 0; static oop v_Array= 0; static oop v_ImmutableArray= 0; static oop v_WordArray= 0; static oop v_ByteArray= 0; static oop v_String= 0; static oop v_ImmutableString= 0; static oop v_true= 0; static oop v_false= 0; static oop v_Smalltalk= 0; static oop v_Stream= 0; static oop v_PositionableStream= 0; static oop v_WriteStream= 0; static oop al_12[1]= { (oop)&l_11 }; static struct __methodinfo __info1= { "_cString", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 27, 36, 0 }; static oop String___5fcString(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info1); oop _1= 0; _line(27); { # define self ((struct t_String *)v_self) int len= (long)self->v_size >> 1; char *cString= (char *)_libid->balloc(len + 1); memcpy(cString, self->v__bytes, len); cString[len]= '\0'; return (oop)cString; # undef self } _1= 0; _1= v_self; _leave(); return _1; _leave(); } static struct __methodinfo __info2= { "directoryName", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 36, 47, &__info1 }; static oop String__directoryName(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info2); oop v_dirName= 0; oop _1= 0; oop _2= 0; (void)v_dirName; _line(36); _1= v_self; _2= l_3; _line(41); _1=_sendv(s_tokenized_, 2, _1, _2); v_dirName= _1; _line(41); _1=_sendv(s_removeLast, 1, _1); /* ifTrue:ifFalse: */ _1= v_dirName; _line(42); _1=_sendv(s_isEmpty, 1, _1); if (!_1) goto _l1; { _1= l_4; } goto _l2; _l1:; { _1= v_dirName; _2= l_3; _line(44); _1=_sendv(s_delimited_, 2, _1, _2); _line(44); _1=_sendv(s_flattened, 1, _1); } _l2:; _leave(); return _1; _leave(); } static struct __methodinfo __info5= { "baseName", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 47, 54, &__info2 }; static oop String__baseName(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info5); oop _1= 0; oop _2= 0; _line(47); _1= v_self; _2= l_6; _line(51); _1=_sendv(s_tokenized_, 2, _1, _2); _line(51); _1=_sendv(s_last, 1, _1); _leave(); return _1; _leave(); } static struct __methodinfo __info7= { "absolutePathName", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 54, 74, &__info5 }; static oop String__absolutePathName(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info7); oop v_cPath= 0; oop _1= 0; oop _2= 0; (void)v_cPath; _line(54); _1= v_self; _line(60); _1=_sendv(s__5fcString, 1, _1); v_cPath= _1; { # define self ((struct t_String *)v_self) { char *path= (char *)v_cPath; static char buf[PATH_MAX]; # if defined(WIN32) if (!_fullpath(buf, path, PATH_MAX)) return 0; # else if (!realpath(path, buf)) return 0; # endif v_cPath= (oop)buf; } # undef self } _1= 0; _1= v_String; _2= v_cPath; _line(71); _1=_sendv(s_value_5f_, 2, _1, _2); _leave(); return _1; _leave(); } static struct __methodinfo __info8= { "isReadableFile", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 74, 88, &__info7 }; static oop String__isReadableFile(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info8); oop v_cPath= 0; oop _1= 0; (void)v_cPath; _line(74); _1= v_self; _line(78); _1=_sendv(s__5fcString, 1, _1); v_cPath= _1; { # define self ((struct t_String *)v_self) { char *path= (char *)v_cPath; struct stat sb; if (-1 == stat(path, &sb)) return 0; if (S_IFREG != (sb.st_mode & S_IFMT)) return 0; if (-1 == access(path, R_OK)) return 0; } # undef self } _1= 0; _1= v_self; _leave(); return _1; _leave(); } static struct __methodinfo __info14= { "[] findFileSearching:withSuffixes:ifError:", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 88, 103, &__info8 }; static oop b_14(oop v__closure, oop v__self, oop v_suffix) { _enter(&__info14); oop _1= 0; oop _2= 0; oop _3= 0; _line(97); /* ifTrue: */ _1= 0; _2= ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_state))[1]; /* dir */ _3= l_15; _line(98); _2=_sendv(s__2c, 2, _2, _3); _3= ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_outer)->v_state))[2]; /* self */ _line(98); _2=_sendv(s__2c, 2, _2, _3); _3= v_suffix; _line(98); _2=_sendv(s__2c, 2, _2, _3); ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_outer)->v_state))[4]= _2; /* path */ _line(98); _2=_sendv(s_isReadableFile, 1, _2); if (!_2) goto _l3; { _1= ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_outer)->v_state))[4]; /* path */ _line(99); _1=_sendv(s_absolutePathName, 1, _1); _leave(); return _libid->nlreturn(((struct t_BlockClosure *)v__self)->v__nlr, _1); } _l3:; _leave(); return _1; _leave(); } static struct __methodinfo __info13= { "[] findFileSearching:withSuffixes:ifError:", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 88, 103, &__info14 }; static oop b_13(oop v__closure, oop v__self, oop v_dir) { _enter(&__info13); oop _state2= _sendv(s_new_5f_, 2, v__vector, 2); oop _1= 0; oop _2= 0; ((oop *)_state2)[1]= v_dir; _line(96); _1= ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_state))[1]; /* suffixes */ /* Scope('suffix'->ArgumentVariableNode) */ /* Scope('dir'->ArgumentVariableNode) */ /* Object */ /* 3 */ /* 2 */ _2= _sendv(s_function_5f_arity_5f_outer_state_nlr_5f_, 6, v_BlockClosure, (oop)b_14, 1, v__self, ((oop *)_state2), ((struct t_BlockClosure *)v__self)->v__nlr); _line(97); _1=_sendv(s_do_, 2, _1, _2); _leave(); return _1; _leave(); } static struct __methodinfo __info9= { "findFileSearching:withSuffixes:ifError:", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 88, 103, &__info13 }; static oop String__findFileSearching_withSuffixes_ifError_(oop v__closure, oop v_stateful_self, oop v_self, oop v_searchPaths, oop v_suffixes, oop v_errorBlock) { _enter(&__info9); oop _state1= _sendv(s_new_5f_, 2, v__vector, 7); oop v_dirs= 0; oop _1= 0; oop _2= 0; jmp_buf __nlr; oop _nlr; (void)v_dirs; ((oop *)_state1)[3]= v_stateful_self; ((oop *)_state1)[2]= v_self; ((oop *)_state1)[1]= v_suffixes; _nlr= (oop)&__nlr; if (setjmp(__nlr)) { return _libid->nlresult(); } _line(88); /* ifTrue:ifFalse: */ _1= ((oop *)_state1)[2]; /* self */ _line(95); _1=_sendv(s_first, 1, _1); _2= l_10; _1= (_1 == _2) ? v_true : v_false; if (!_1) goto _l4; { _1= l_12; } goto _l5; _l4:; { _1= v_searchPaths; } _l5:; v_dirs= _1; _1= v_dirs; /* Scope('dir'->ArgumentVariableNode) */ /* Scope('path'->TemporaryVariableNode 'searchPaths'->ArgumentVariableNode 'dirs'->TemporaryVariableNode 'stateful_self'->ArgumentVariableNode 'size'->SlotVariableNode 'self'->ArgumentVariableNode 'errorBlock'->ArgumentVariableNode 'suffixes'->ArgumentVariableNode '_bytes'->SlotVariableNode) */ /* nil */ /* 2 */ /* 1 */ _2= _sendv(s_function_5f_arity_5f_outer_state_nlr_5f_, 6, v_BlockClosure, (oop)b_13, 1, 0, ((oop *)_state1), _nlr); _line(96); _1=_sendv(s_do_, 2, _1, _2); _1= v_errorBlock; _line(100); _1=_sendv(s_value, 1, _1); _leave(); return _1; _leave(); } static struct __methodinfo __info17= { "[] findFileSearching:withSuffixes:", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 103, 111, &__info9 }; static oop b_17(oop v__closure, oop v__self) { _enter(&__info17); oop _1= 0; oop _2= 0; oop _3= 0; _line(107); _1= ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_state))[1]; /* self */ _2= ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_state))[1]; /* self */ _3= l_18; _line(107); _2=_sendv(s__2c, 2, _2, _3); _3= v_Smalltalk; _line(107); _3=_sendv(s_osErrorString, 1, _3); _line(107); _2=_sendv(s__2c, 2, _2, _3); _line(107); _1=_sendv(s_error_, 2, _1, _2); _leave(); return _1; _leave(); } static struct __methodinfo __info16= { "findFileSearching:withSuffixes:", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 103, 111, &__info17 }; static oop String__findFileSearching_withSuffixes_(oop v__closure, oop v_stateful_self, oop v_self, oop v_searchPaths, oop v_suffixes) { _enter(&__info16); oop _state1= _sendv(s_new_5f_, 2, v__vector, 5); oop _1= 0; oop _2= 0; oop _3= 0; oop _4= 0; ((oop *)_state1)[2]= v_stateful_self; ((oop *)_state1)[1]= v_self; _line(103); _1= ((oop *)_state1)[1]; /* self */ _2= v_searchPaths; _3= v_suffixes; /* Scope() */ /* Scope('_bytes'->SlotVariableNode 'size'->SlotVariableNode 'self'->ArgumentVariableNode 'suffixes'->ArgumentVariableNode 'searchPaths'->ArgumentVariableNode 'stateful_self'->ArgumentVariableNode) */ /* nil */ /* 2 */ /* 1 */ _4= _sendv(s_function_5f_arity_5f_outer_state_nlr_5f_, 6, v_BlockClosure, (oop)b_17, 0, 0, ((oop *)_state1), 0); _line(105); _1=_sendv(s_findFileSearching_withSuffixes_ifError_, 4, _1, _2, _3, _4); _leave(); return _1; _leave(); } static struct __methodinfo __info19= { "readFromFileNamed:ifError:", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 111, 149, &__info16 }; static oop String__readFromFileNamed_ifError_(oop v__closure, oop v_stateful_self, oop v_self, oop v_path, oop v_errorBlock) { _enter(&__info19); oop v_cPath= 0; oop _1= 0; (void)v_cPath; _line(111); _1= v_self; _line(117); _1=_sendv(s__5fclone, 1, _1); v_self= _1; v_stateful_self= _1; _1= v_path; _line(118); _1=_sendv(s__5fcString, 1, _1); v_cPath= _1; { # define self ((struct t_String *)v_self) { char *path= (char *)v_cPath; int fd= open(path, O_RDONLY | O_BINARY); if (fd >= 0) { int position= 0; int remaining= 0; struct stat sb; fstat(fd, &sb); remaining= sb.st_size; self->v__bytes= _libid->balloc(remaining); while (remaining) { int count= read(fd, (char *)self->v__bytes + position, remaining); if (count < 1) break; position += count; remaining -= count; } close(fd); if (!remaining) { self->v_size= (oop)(((long)position << 1) | 1); return v_self; } } } # undef self } _1= 0; _1= v_errorBlock; _line(146); _1=_sendv(s_value, 1, _1); _leave(); return _1; _leave(); } static struct __methodinfo __info21= { "[] readFromFileNamed:", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 149, 154, &__info19 }; static oop b_21(oop v__closure, oop v__self) { _enter(&__info21); oop _1= 0; oop _2= 0; oop _3= 0; _line(151); _1= ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_state))[1]; /* self */ _2= ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_state))[3]; /* path */ _3= l_22; _line(151); _2=_sendv(s__2c, 2, _2, _3); _3= v_Smalltalk; _line(151); _3=_sendv(s_osErrorString, 1, _3); _line(151); _2=_sendv(s__2c, 2, _2, _3); _line(151); _1=_sendv(s_error_, 2, _1, _2); _leave(); return _1; _leave(); } static struct __methodinfo __info20= { "readFromFileNamed:", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 149, 154, &__info21 }; static oop String__readFromFileNamed_(oop v__closure, oop v_stateful_self, oop v_self, oop v_path) { _enter(&__info20); oop _state1= _sendv(s_new_5f_, 2, v__vector, 6); oop _1= 0; oop _2= 0; oop _3= 0; ((oop *)_state1)[2]= v_stateful_self; ((oop *)_state1)[1]= v_self; ((oop *)_state1)[3]= v_path; _line(149); _1= ((oop *)_state1)[1]; /* self */ _2= ((oop *)_state1)[3]; /* path */ /* Scope() */ /* Scope('size'->SlotVariableNode 'self'->ArgumentVariableNode 'path'->ArgumentVariableNode '_bytes'->SlotVariableNode 'stateful_self'->ArgumentVariableNode) */ /* nil */ /* 2 */ /* 1 */ _3= _sendv(s_function_5f_arity_5f_outer_state_nlr_5f_, 6, v_BlockClosure, (oop)b_21, 0, 0, ((oop *)_state1), 0); _line(151); _1=_sendv(s_readFromFileNamed_ifError_, 3, _1, _2, _3); _leave(); return _1; _leave(); } static struct __methodinfo __info23= { "fileContents", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 154, 160, &__info20 }; static oop String__fileContents(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info23); oop _1= 0; oop _2= 0; _line(154); _1= v_self; _2= v_self; _line(157); _1=_sendv(s_readFromFileNamed_, 2, _1, _2); _leave(); return _1; _leave(); } static struct __methodinfo __info24= { "writeToFileNamed:ifError:", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 160, 189, &__info23 }; static oop String__writeToFileNamed_ifError_(oop v__closure, oop v_stateful_self, oop v_self, oop v_path, oop v_errorBlock) { _enter(&__info24); oop v_cPath= 0; oop _1= 0; (void)v_cPath; _line(160); _1= v_path; _line(165); _1=_sendv(s__5fcString, 1, _1); v_cPath= _1; { # define self ((struct t_String *)v_self) { char *path= (char *)v_cPath; int fd= open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); if (fd >= 0) { int position= 0; int remaining= (long)self->v_size >> 1; while (remaining) { int count= write(fd, (char *)self->v__bytes + position, remaining); if (count < 1) break; position += count; remaining -= count; } close(fd); if (!remaining) return v_self; } } # undef self } _1= 0; _1= v_errorBlock; _line(186); _1=_sendv(s_value, 1, _1); _leave(); return _1; _leave(); } static struct __methodinfo __info26= { "[] writeToFileNamed:", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 189, 196, &__info24 }; static oop b_26(oop v__closure, oop v__self) { _enter(&__info26); oop _1= 0; oop _2= 0; oop _3= 0; _line(191); _1= ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_state))[1]; /* self */ _2= ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_state))[3]; /* path */ _3= l_27; _line(191); _2=_sendv(s__2c, 2, _2, _3); _3= v_Smalltalk; _line(191); _3=_sendv(s_osErrorString, 1, _3); _line(191); _2=_sendv(s__2c, 2, _2, _3); _line(191); _1=_sendv(s_error_, 2, _1, _2); _leave(); return _1; _leave(); } static struct __methodinfo __info25= { "writeToFileNamed:", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 189, 196, &__info26 }; static oop String__writeToFileNamed_(oop v__closure, oop v_stateful_self, oop v_self, oop v_path) { _enter(&__info25); oop _state1= _sendv(s_new_5f_, 2, v__vector, 6); oop _1= 0; oop _2= 0; oop _3= 0; ((oop *)_state1)[2]= v_stateful_self; ((oop *)_state1)[1]= v_self; ((oop *)_state1)[3]= v_path; _line(189); _1= ((oop *)_state1)[1]; /* self */ _2= ((oop *)_state1)[3]; /* path */ /* Scope() */ /* Scope('size'->SlotVariableNode 'self'->ArgumentVariableNode 'path'->ArgumentVariableNode '_bytes'->SlotVariableNode 'stateful_self'->ArgumentVariableNode) */ /* nil */ /* 2 */ /* 1 */ _3= _sendv(s_function_5f_arity_5f_outer_state_nlr_5f_, 6, v_BlockClosure, (oop)b_26, 0, 0, ((oop *)_state1), 0); _line(191); _1=_sendv(s_writeToFileNamed_ifError_, 3, _1, _2, _3); _leave(); return _1; _leave(); } static struct __methodinfo __info28= { "strftimeNow", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 196, 209, &__info25 }; static oop String__strftimeNow(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info28); oop v__format= 0; oop v__buf= 0; oop _1= 0; oop _2= 0; (void)v__format; (void)v__buf; _line(196); _1= v_self; _line(199); _1=_sendv(s__5fcString, 1, _1); v__format= _1; { # define self ((struct t_String *)v_self) char buf[32]; time_t clock= time(0); strftime(buf, sizeof(buf), (const char *)v__format, localtime(&clock)); v__buf= (oop)buf; # undef self } _1= 0; _1= v_String; _2= v__buf; _line(206); _1=_sendv(s_value_5f_, 2, _1, _2); _leave(); return _1; _leave(); } static struct __methodinfo __info29= { "strftimeZulu", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 209, 222, &__info28 }; static oop String__strftimeZulu(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info29); oop v__format= 0; oop v__buf= 0; oop _1= 0; oop _2= 0; (void)v__format; (void)v__buf; _line(209); _1= v_self; _line(212); _1=_sendv(s__5fcString, 1, _1); v__format= _1; { # define self ((struct t_String *)v_self) char buf[32]; time_t clock= time(0); strftime(buf, sizeof(buf), (const char *)v__format, gmtime(&clock)); v__buf= (oop)buf; # undef self } _1= 0; _1= v_String; _2= v__buf; _line(219); _1=_sendv(s_value_5f_, 2, _1, _2); _leave(); return _1; _leave(); } static struct __methodinfo __info30= { "dateStamp", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 222, 223, &__info29 }; static oop String__dateStamp(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info30); oop _1= 0; _line(222); _1= l_31; _line(222); _1=_sendv(s_strftimeNow, 1, _1); _leave(); return _1; _leave(); } static struct __methodinfo __info32= { "timeStamp", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 223, 224, &__info30 }; static oop String__timeStamp(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info32); oop _1= 0; _line(223); _1= l_33; _line(223); _1=_sendv(s_strftimeNow, 1, _1); _leave(); return _1; _leave(); } static struct __methodinfo __info34= { "dateAndTimeStamp", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 224, 225, &__info32 }; static oop String__dateAndTimeStamp(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info34); oop _1= 0; _line(224); _1= l_35; _line(224); _1=_sendv(s_strftimeNow, 1, _1); _leave(); return _1; _leave(); } static struct __methodinfo __info36= { "dateAndTimeZoneStamp", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 225, 226, &__info34 }; static oop String__dateAndTimeZoneStamp(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info36); oop _1= 0; _line(225); _1= l_37; _line(225); _1=_sendv(s_strftimeNow, 1, _1); _leave(); return _1; _leave(); } static struct __methodinfo __info38= { "dateAndTimeZuluStamp", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 226, 228, &__info36 }; static oop String__dateAndTimeZuluStamp(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info38); oop _1= 0; _line(226); _1= l_39; _line(226); _1=_sendv(s_strftimeZulu, 1, _1); _leave(); return _1; _leave(); } static struct __methodinfo __info42= { "[] escaped", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 228, 237, &__info38 }; static oop b_42(oop v__closure, oop v__self, oop v_c) { _enter(&__info42); oop _1= 0; oop _2= 0; oop _3= 0; _line(232); /* ifTrue: */ _1= 0; _2= v_c; _3= l_43; _2= (_2 == _3) ? v_true : v_false; if (!_2) goto _l6; { _1= ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_state))[1]; /* answer */ _2= v_c; _line(233); _1=_sendv(s_nextPut_, 2, _1, _2); } _l6:; _1= ((oop *)((struct t_BlockClosure *)((struct t_BlockClosure *)v__self)->v_state))[1]; /* answer */ _2= v_c; _line(234); _1=_sendv(s_nextPut_, 2, _1, _2); _leave(); return _1; _leave(); } static struct __methodinfo __info40= { "escaped", "String", "/Users/piumarta/src/idst/object/idc/StringIO.st", 0, 228, 237, &__info42 }; static oop String__escaped(oop v__closure, oop v_stateful_self, oop v_self) { _enter(&__info40); oop _state1= _sendv(s_new_5f_, 2, v__vector, 2); oop _1= 0; oop _2= 0; oop _3= 0; oop _4= 0; _line(228); _1= v_WriteStream; _2= v_String; _3= v_self; _line(231); _3=_sendv(s_size, 1, _3); _4= l_41; { int _l= (long)_3 >> 1; int _r= (long)_4 >> 1; int _s= (_l * _r); if ((1 & (long)_3) && ((_r == 0) || (_s / _r == _l)) && ((_s ^ (_s << 1)) >= 0)) _3= (oop)(long)(_s << 1 | 1); else _3= _sendv(s__2a, 2, _3, _4); } _line(231); _2=_sendv(s_new_, 2, _2, _3); _line(231); _1=_sendv(s_on_, 2, _1, _2); ((oop *)_state1)[1]= _1; /* answer */ _1= v_self; /* Scope('c'->ArgumentVariableNode) */ /* Scope('size'->SlotVariableNode 'self'->ArgumentVariableNode 'answer'->TemporaryVariableNode '_bytes'->SlotVariableNode 'stateful_self'->ArgumentVariableNode) */ /* nil */ /* 2 */ /* 1 */ _2= _sendv(s_function_5f_arity_5f_outer_state_nlr_5f_, 6, v_BlockClosure, (oop)b_42, 1, 0, ((oop *)_state1), 0); _line(232); _1=_sendv(s_do_, 2, _1, _2); _1= ((oop *)_state1)[1]; /* answer */ _line(235); _1=_sendv(s_contents, 1, _1); _leave(); return _1; _leave(); } static struct __methodinfo __info= { "__id__init__", "", "StringIO.st", 0, 0, 0, &__info40 }; void __id__init__StringIO(struct __libid *__libid) { if (_libid) return; if (!(_libid= __libid)) { fprintf(stderr, "init _libid %p\n", __libid); abort(); } # define GC_add_roots _libid->gc_addRoots GC_INIT(); { struct _Selector *s= 0; for (s= _Selectors; s->name; ++s) *s->addr= _libid->intern(s->name); } _enter(&__info); _libid->infos(&__info, &__info1); _sendv(s__5fimport_, 3, _libid->_object, "String", "__id__init__String"); v__object= _libid->import("_object"); v__vector= _libid->import("_vector"); v_Object= _libid->import("Object"); v_UndefinedObject= _libid->import("UndefinedObject"); v_StaticBlockClosure= _libid->import("StaticBlockClosure"); v_BlockClosure= _libid->import("BlockClosure"); v_Magnitude= _libid->import("Magnitude"); v_Character= _libid->import("Character"); v_Number= _libid->import("Number"); v_Integer= _libid->import("Integer"); v_SmallInteger= _libid->import("SmallInteger"); v_LargePositiveInteger= _libid->import("LargePositiveInteger"); v_Collection= _libid->import("Collection"); v_SequenceableCollection= _libid->import("SequenceableCollection"); v_ArrayedCollection= _libid->import("ArrayedCollection"); v_Array= _libid->import("Array"); v_ImmutableArray= _libid->import("ImmutableArray"); v_WordArray= _libid->import("WordArray"); v_ByteArray= _libid->import("ByteArray"); v_String= _libid->import("String"); v_ImmutableString= _libid->import("ImmutableString"); v_true= _libid->import("true"); v_false= _libid->import("false"); _sendv(s__5fimport_, 3, _libid->_object, "Smalltalk", "__id__init__Smalltalk"); v_Smalltalk= _libid->import("Smalltalk"); _sendv(s__5fimport_, 3, _libid->_object, "WriteStream", "__id__init__WriteStream"); v_Stream= _libid->import("Stream"); v_PositionableStream= _libid->import("PositionableStream"); v_WriteStream= _libid->import("WriteStream"); _libid->method(v_String, s__5fcString, (_imp_t)String___5fcString); l_3= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 1, "/"); l_4= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 1, "."); _libid->method(v_String, s_directoryName, (_imp_t)String__directoryName); l_6= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 1, "/"); _libid->method(v_String, s_baseName, (_imp_t)String__baseName); _libid->method(v_String, s_absolutePathName, (_imp_t)String__absolutePathName); _libid->method(v_String, s_isReadableFile, (_imp_t)String__isReadableFile); l_10= _sendv(s_value_5f_, 2, v_Character, 47); l_11= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 0, ""); l_12= _sendv(s_size_5f_value_5f_, 3, v_ImmutableArray, 1, al_12); l_15= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 1, "/"); _libid->method(v_String, s_findFileSearching_withSuffixes_ifError_, (_imp_t)String__findFileSearching_withSuffixes_ifError_); l_18= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 2, ": "); _libid->method(v_String, s_findFileSearching_withSuffixes_, (_imp_t)String__findFileSearching_withSuffixes_); _libid->method(v_String, s_readFromFileNamed_ifError_, (_imp_t)String__readFromFileNamed_ifError_); l_22= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 2, ": "); _libid->method(v_String, s_readFromFileNamed_, (_imp_t)String__readFromFileNamed_); _libid->method(v_String, s_fileContents, (_imp_t)String__fileContents); _libid->method(v_String, s_writeToFileNamed_ifError_, (_imp_t)String__writeToFileNamed_ifError_); l_27= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 2, ": "); _libid->method(v_String, s_writeToFileNamed_, (_imp_t)String__writeToFileNamed_); _libid->method(v_String, s_strftimeNow, (_imp_t)String__strftimeNow); _libid->method(v_String, s_strftimeZulu, (_imp_t)String__strftimeZulu); l_31= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 8, "%Y-%m-%d"); _libid->method(v_String, s_dateStamp, (_imp_t)String__dateStamp); l_33= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 8, "%H:%M:%S"); _libid->method(v_String, s_timeStamp, (_imp_t)String__timeStamp); l_35= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 17, "%Y-%m-%d %H:%M:%S"); _libid->method(v_String, s_dateAndTimeStamp, (_imp_t)String__dateAndTimeStamp); l_37= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 20, "%Y-%m-%d %H:%M:%S %Z"); _libid->method(v_String, s_dateAndTimeZoneStamp, (_imp_t)String__dateAndTimeZoneStamp); l_39= _sendv(s_size_5f_value_5f_, 3, v_ImmutableString, 19, "%Y-%m-%d %H:%M:%S Z"); _libid->method(v_String, s_dateAndTimeZuluStamp, (_imp_t)String__dateAndTimeZuluStamp); l_41= _sendv(s_value_5f_, 2, v_SmallInteger, 2); l_43= _sendv(s_value_5f_, 2, v_Character, 92); _libid->method(v_String, s_escaped, (_imp_t)String__escaped); _leave(); }