📄 data.c
字号:
ptr1 = ((char *) ptr1) + siz; ptr2 = ((char *) ptr2) + siz; } /* If done accreting for this storage area, establish as initialized. */ if (ffestorag_accretes (mst) == 0) { ffestorag_set_init (mst, accter); ffestorag_set_accretion (mst, NULL); ffebit_kill (ffebld_accter_bits (ffestorag_init (mst))); ffebld_set_op (ffestorag_init (mst), FFEBLD_opARRTER); ffebld_set_arrter (ffestorag_init (mst), ffebld_accter (ffestorag_init (mst))); ffebld_arrter_set_size (ffestorag_init (mst), ffedata_storage_size_); ffebld_arrter_set_pad (ffestorag_init (mst), 0); ffecom_notify_init_storage (mst); } return; default: assert ("bad init op in gather_" == NULL); return; }}/* ffedata_pop_ -- Pop an impdo stack entry ffedata_pop_(); */static voidffedata_pop_ (){ ffedataImpdo_ victim = ffedata_stack_; assert (victim != NULL); ffedata_stack_ = ffedata_stack_->outer; malloc_kill_ks (ffe_pool_program_unit (), victim, sizeof (*victim));}/* ffedata_push_ -- Push an impdo stack entry ffedata_push_(); */static voidffedata_push_ (){ ffedataImpdo_ baby; baby = malloc_new_ks (ffe_pool_program_unit (), "ffedataImpdo_", sizeof (*baby)); baby->outer = ffedata_stack_; ffedata_stack_ = baby;}/* ffedata_value_ -- Provide an initial value ffebld value; ffelexToken t; // Points to the value. if (ffedata_value(value,t)) // Everything's ok Makes sure the value is ok, then remembers it according to the list provided to ffedata_begin. */static boolffedata_value_ (ffebld value, ffelexToken token){ /* If already reported an error, don't do anything. */ if (ffedata_reported_error_) return FALSE; /* If the value is an error marker, remember we've seen one and do nothing else. */ if ((value != NULL) && (ffebld_op (value) == FFEBLD_opANY)) { ffedata_reported_error_ = TRUE; return FALSE; } /* If too many values (no more targets), complain. */ if (ffedata_symbol_ == NULL) { ffebad_start (FFEBAD_DATA_TOOMANY); ffebad_here (0, ffelex_token_where_line (token), ffelex_token_where_column (token)); ffebad_finish (); ffedata_reported_error_ = TRUE; return FALSE; } /* If ffedata_advance_ wanted to register a complaint, do it now that we have the token to point at instead of just the start of the whole statement. */ if (ffedata_reinit_) { ffebad_start (FFEBAD_DATA_REINIT); ffebad_here (0, ffelex_token_where_line (token), ffelex_token_where_column (token)); ffebad_string (ffesymbol_text (ffedata_symbol_)); ffebad_finish (); ffedata_reported_error_ = TRUE; return FALSE; }#if FFEGLOBAL_ENABLED if (ffesymbol_common (ffedata_symbol_) != NULL) ffeglobal_init_common (ffesymbol_common (ffedata_symbol_), token);#endif /* Convert value to desired type. */ if (value != NULL) { if (ffedata_convert_cache_use_ == -1) value = ffeexpr_convert (value, token, NULL, ffedata_basictype_, ffedata_kindtype_, 0, (ffedata_basictype_ == FFEINFO_basictypeCHARACTER) ? ffedata_charexpected_ : FFETARGET_charactersizeNONE, FFEEXPR_contextDATA); else /* Use the cache. */ value = ffedata_convert_ (value, token, NULL, ffedata_basictype_, ffedata_kindtype_, 0, (ffedata_basictype_ == FFEINFO_basictypeCHARACTER) ? ffedata_charexpected_ : FFETARGET_charactersizeNONE); } /* If we couldn't, bug out. */ if ((value != NULL) && (ffebld_op (value) == FFEBLD_opANY)) { ffedata_reported_error_ = TRUE; return FALSE; } /* Handle the case where initializes go to a parent's storage area. */ if (ffedata_storage_ != NULL) { ffetargetOffset offset; ffetargetOffset units_expected; ffebitCount actual; ffebldConstantArray array; ffebld accter; ffetargetCopyfunc fn; void *ptr1; void *ptr2; size_t size; ffeinfoBasictype ign_bt; ffeinfoKindtype ign_kt; ffetargetAlign units; /* Make sure we haven't fully accreted during an array init. */ if (ffestorag_init (ffedata_storage_) != NULL) { ffebad_start (FFEBAD_DATA_MULTIPLE); ffebad_here (0, ffelex_token_where_line (token), ffelex_token_where_column (token)); ffebad_string (ffesymbol_text (ffedata_symbol_)); ffebad_finish (); ffedata_reported_error_ = TRUE; return FALSE; } /* Calculate offset. */ offset = ffedata_offset_ * ffedata_size_ + ffedata_charoffset_; /* Is offset within range? If not, whine, but don't do anything else. */ if (offset + ffedata_charexpected_ - 1 > ffedata_symbolsize_) { ffebad_start (FFEBAD_DATA_RANGE); ffest_ffebad_here_current_stmt (0); ffebad_string (ffesymbol_text (ffedata_symbol_)); ffebad_finish (); ffedata_reported_error_ = TRUE; return FALSE; } /* Now calculate offset for aggregate area. */ ffetarget_aggregate_info (&ign_bt, &ign_kt, &units, ffedata_basictype_, ffedata_kindtype_); /* Find out unit size of source datum. */ assert (units % ffedata_storage_units_ == 0); units_expected = ffedata_charexpected_ * units / ffedata_storage_units_; offset *= units / ffedata_storage_units_; offset += (ffestorag_offset (ffesymbol_storage (ffedata_symbol_)) - ffestorag_offset (ffedata_storage_)) / ffedata_storage_units_; assert (offset + units_expected - 1 <= ffedata_storage_size_); /* Does an accretion array exist? If not, create it. */ if (value != NULL) { if (ffestorag_accretion (ffedata_storage_) == NULL) {#if FFEDATA_sizeTOO_BIG_INIT_ != 0 if (ffedata_storage_size_ >= FFEDATA_sizeTOO_BIG_INIT_) { char bignum[40]; sprintf (&bignum[0], "%ld", (long) ffedata_storage_size_); ffebad_start (FFEBAD_TOO_BIG_INIT); ffebad_here (0, ffelex_token_where_line (token), ffelex_token_where_column (token)); ffebad_string (ffesymbol_text (ffedata_symbol_)); ffebad_string (bignum); ffebad_finish (); }#endif array = ffebld_constantarray_new (ffedata_storage_bt_, ffedata_storage_kt_, ffedata_storage_size_); accter = ffebld_new_accter (array, ffebit_new (ffe_pool_program_unit (), ffedata_storage_size_)); ffebld_set_info (accter, ffeinfo_new (ffedata_storage_bt_, ffedata_storage_kt_, 1, FFEINFO_kindENTITY, FFEINFO_whereCONSTANT, (ffedata_basictype_ == FFEINFO_basictypeCHARACTER) ? 1 : FFETARGET_charactersizeNONE)); ffestorag_set_accretion (ffedata_storage_, accter); ffestorag_set_accretes (ffedata_storage_, ffedata_storage_size_); } else { accter = ffestorag_accretion (ffedata_storage_); assert (ffedata_storage_size_ == (ffetargetOffset) ffebld_accter_size (accter)); array = ffebld_accter (accter); } /* Put value in accretion array at desired offset. */ fn = ffetarget_aggregate_ptr_memcpy (ffedata_storage_bt_, ffedata_storage_kt_, ffedata_basictype_, ffedata_kindtype_); ffebld_constantarray_prepare (&ptr1, &ptr2, &size, array, ffedata_storage_bt_, ffedata_storage_kt_, offset, ffebld_constant_ptr_to_union (ffebld_conter (value)), ffedata_basictype_, ffedata_kindtype_); (*fn) (ptr1, ptr2, size); /* Does the appropriate memcpy-like operation. */ ffebit_count (ffebld_accter_bits (accter), offset, FALSE, units_expected, &actual); /* How many FALSE? */ if (units_expected != (ffetargetOffset) actual) { ffebad_start (FFEBAD_DATA_MULTIPLE); ffebad_here (0, ffelex_token_where_line (token), ffelex_token_where_column (token)); ffebad_string (ffesymbol_text (ffedata_symbol_)); ffebad_finish (); } ffestorag_set_accretes (ffedata_storage_, ffestorag_accretes (ffedata_storage_) - actual); /* Decrement # of values actually accreted. */ ffebit_set (ffebld_accter_bits (accter), offset, 1, units_expected); /* If done accreting for this storage area, establish as initialized. */ if (ffestorag_accretes (ffedata_storage_) == 0) { ffestorag_set_init (ffedata_storage_, accter); ffestorag_set_accretion (ffedata_storage_, NULL); ffebit_kill (ffebld_accter_bits (ffestorag_init (ffedata_storage_))); ffebld_set_op (ffestorag_init (ffedata_storage_), FFEBLD_opARRTER); ffebld_set_arrter (ffestorag_init (ffedata_storage_), ffebld_accter (ffestorag_init (ffedata_storage_))); ffebld_arrter_set_size (ffestorag_init (ffedata_storage_), ffedata_storage_size_); ffebld_arrter_set_pad (ffestorag_init (ffedata_storage_), 0); ffecom_notify_init_storage (ffedata_storage_); } } /* If still accreting, adjust specs accordingly and return. */ if (++ffedata_number_ < ffedata_expected_) { ++ffedata_offset_; return TRUE; } return ffedata_advance_ (); } /* Figure out where the value goes -- in an accretion array or directly into the final initial-value slot for the symbol. */ if ((ffedata_number_ != 0) || (ffedata_arraysize_ > 1) || (ffedata_charnumber_ != 0) || (ffedata_size_ > ffedata_charexpected_)) { /* Accrete this value. */ ffetargetOffset offset; ffebitCount actual; ffebldConstantArray array; ffebld accter = NULL; /* Calculate offset. */ offset = ffedata_offset_ * ffedata_size_ + ffedata_charoffset_; /* Is offset within range? If not, whine, but don't do anything else. */ if (offset + ffedata_charexpected_ - 1 > ffedata_symbolsize_) { ffebad_start (FFEBAD_DATA_RANGE); ffest_ffebad_here_current_stmt (0); ffebad_string (ffesymbol_text (ffedata_symbol_)); ffebad_finish (); ffedata_reported_error_ = TRUE; return FALSE; } /* Does an accretion array exist? If not, create it. */ if (value != NULL) { if (ffesymbol_accretion (ffedata_symbol_) == NULL) {#if FFEDATA_sizeTOO_BIG_INIT_ != 0 if (ffedata_symbolsize_ >= FFEDATA_sizeTOO_BIG_INIT_ ) { char bignum[40]; sprintf (&bignum[0], "%ld", (long) ffedata_symbolsize_); ffebad_start (FFEBAD_TOO_BIG_INIT); ffebad_here (0, ffelex_token_where_line (token), ffelex_token_where_column (token)); ffebad_string (ffesymbol_text (ffedata_symbol_)); ffebad_string (bignum); ffebad_finish (); }#endif array = ffebld_constantarray_new (ffedata_basictype_, ffedata_kindtype_, ffedata_symbolsize_); accter = ffebld_new_accter (array, ffebit_new (ffe_pool_program_unit (), ffedata_symbolsize_)); ffebld_set_info (accter, ffeinfo_new (ffedata_basictype_, ffedata_kindtype_, 1, FFEINFO_kindENTITY, FFEINFO_whereCONSTANT, (ffedata_basictype_ == FFEINFO_basictypeCHARACTER) ? 1 : FFETARGET_charactersizeNONE)); ffesymbol_set_accretion (ffedata_symbol_, accter); ffesymbol_set_accretes (ffedata_symbol_, ffedata_symbolsize_); } else { accter = ffesymbol_accretion (ffedata_symbol_); assert (ffedata_symbolsize_ == (ffetargetOffset) ffebld_accter_size (accter)); array = ffebld_accter (accter); } /* Put value in accretion array at desired offset. */ ffebld_constantarray_put (array, ffedata_basictype_, ffedata_kindtype_, offset, ffebld_constant_union (ffebld_conter (value))); ffebit_count (ffebld_accter_bits (accter), offset, FALSE, ffedata_charexpected_, &actual); /* How many FALSE? */ if (actual != (unsigned long int) ffedata_charexpected_) { ffebad_start (FFEBAD_DATA_MULTIPLE); ffebad_here (0, ffelex_token_where_line (token), ffelex_token_where_column (token)); ffebad_string (ffesymbol_text (ffedata_symbol_)); ffebad_finish (); } ffesymbol_set_accretes (ffedata_symbol_, ffesymbol_accretes (ffedata_symbol_) - actual); /* Decrement # of values actually accreted. */ ffebit_set (ffebld_accter_bits (accter), offset, 1, ffedata_charexpected_); ffesymbol_signal_unreported (ffedata_symbol_); } /* If still accreting, adjust specs accordingly and return. */ if (++ffedata_number_ < ffedata_expected_) { ++ffedata_offset_; return TRUE; } /* Else, if done accreting for this symbol, establish as initialized. */ if ((value != NULL) && (ffesymbol_accretes (ffedata_symbol_) == 0)) { ffesymbol_set_init (ffedata_symbol_, accter); ffesymbol_set_accretion (ffedata_symbol_, NULL); ffebit_kill (ffebld_accter_bits (ffesymbol_init (ffedata_symbol_))); ffebld_set_op (ffesymbol_init (ffedata_symbol_), FFEBLD_opARRTER); ffebld_set_arrter (ffesymbol_init (ffedata_symbol_), ffebld_accter (ffesymbol_init (ffedata_symbol_))); ffebld_arrter_set_size (ffesymbol_init (ffedata_symbol_), ffedata_symbolsize_); ffebld_arrter_set_pad (ffestorag_init (ffedata_symbol_), 0); ffecom_notify_init_symbol (ffedata_symbol_); } } else if (value != NULL) { /* Simple, direct, one-shot assignment. */ ffesymbol_set_init (ffedata_symbol_, value); ffecom_notify_init_symbol (ffedata_symbol_); } /* Call on advance function to get next target in list. */ return ffedata_advance_ ();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -