コード例 #1
0
ファイル: UilSrcSrc.c プロジェクト: fjardon/motif
void
src_initialize_source(void)
{
    /* initialize source data structures */

    src_az_current_source_buffer = NULL;
    src_az_avail_source_buffer = NULL;
    src_l_last_source_file_number = -1;
    src_az_first_source_record = NULL;
    src_az_current_source_record =
	(src_source_record_type *) &src_az_first_source_record;

    /*  Initialize Own storage    */

    main_fcb = NULL;
    include_dir = NULL;
    main_dir_len = 0;


    /* open the source file */
    if ( Uil_cmd_z_command.ac_source_file == NULL )
	diag_issue_diagnostic (d_src_open,
			       diag_k_no_source, diag_k_no_column,
			       "<null file name>");

    src_open_file ( Uil_cmd_z_command.ac_source_file, NULL );

    /* fixes initial filename is NULL bug in callable UIL */
    Uil_current_file = Uil_cmd_z_command.ac_source_file;

    return;
}
コード例 #2
0
ファイル: UilMain.c プロジェクト: juddy/edcde
static void	common_main()
{
#ifndef NO_MESSAGE_CATALOG
  if (uil_catd == NULL)
    uil_catd = catopen("Uil", NL_CAT_LOCALE);
#endif

  /* Initialize the X toolkit. */
  XtToolkitInitialize(); 
  
    /* use the user supplied data base instead */
    if (Uil_cmd_z_command.v_database)
	db_incorporate();

    /* initialize the diagnostic system */
    diag_initialize_diagnostics();

    /* initialize the symbol table */
    sym_initialize_storage();

    /* initialize the source */
    src_initialize_source();

    /* open listing file if requested */
    if (Uil_cmd_z_command.v_listing_file)
	lst_open_listing();

    /* initialize the lexical analyzer */
    lex_initialize_analyzer();

    /* initialize the keyword table */
    key_initialize();

    /* initialize the sar data structures */
    sar_initialize();

    /* call YACC to parse the source file */
    /* return 0 for success, 1 for failure */
    /* Make sure the root entry sections pointer is filled in */
    if (yyparse() != 0)
    	diag_issue_diagnostic
	    (d_inv_module, diag_k_no_source, diag_k_no_column);
    sym_az_root_entry->sections = sym_az_current_section_entry;

    /* call forward reference resolver */
    sem_resolve_forward_refs();

    /* call semantic validation */
    sem_validation ();

    /* call the output phase if requested */
    if (Uil_cmd_z_command.v_resource_file)
	sem_output_uid_file();

    /* call symbol table dumper - if requested */
#if debug_version
    if (uil_v_dump_symbols == TRUE)
	sym_dump_symbols();
#endif


    /* write compilation summary */
    diag_issue_summary();


    /* write listing file if requested */
    if (Uil_cmd_z_command.v_listing_file)
	lst_output_listing();

    /* Storage is not cleaned up, since we will exit */
    uil_exit( uil_l_compile_status );

}
コード例 #3
0
ファイル: UilSarProc.c プロジェクト: juddy/edcde
sym_entry_type
*sem_ref_name(yystype     *id_frame, 
              XmConst int tag)
{
    sym_name_entry_type	    *name_entry;
    sym_entry_type	    *symbol_entry;

    _assert( id_frame->b_tag == sar_k_token_frame, "arg1 not id frame" );

    /* 
    ** The id frame may hold a name or the keyword for a font name, color
    ** name, reason name etc.  If it is one of these special name, then
    ** we must see if the symbol table holds a name for the special type.
    */

    if (id_frame->b_type != NAME)
    {
	name_entry = 
	    sym_find_name
		( id_frame->value.az_keyword_entry->b_length,
		  id_frame->value.az_keyword_entry->at_name );

	if (name_entry == NULL)
	{
	    diag_issue_diagnostic
		( d_undefined,
		  _sar_source_position( id_frame ),
		  diag_tag_text( sym_k_proc_def_entry ),
		  id_frame->value.az_keyword_entry->at_name );

	    return NULL;
	}

    }
    else
	name_entry =
		(sym_name_entry_type *) id_frame->value.az_symbol_entry;

    /*
    ** If the name entry already has no object linked from it, we are
    ** referencing an undefined object.
    */

    symbol_entry = name_entry->az_object;

    if (symbol_entry == NULL )
	{
	id_frame->b_flags |= sym_m_forward_ref;
	return NULL;
	}
    /*
    ** If the name entry has the wrong type of object, this is also
    ** an error.
    */

    if (symbol_entry->header.b_tag != tag )
    {
	diag_issue_diagnostic
	    ( d_ctx_req,
	      _sar_source_position( id_frame ),
	      diag_tag_text( tag ),
	      diag_tag_text( symbol_entry->header.b_tag ) );

	return NULL;
    }

    return symbol_entry;

}
コード例 #4
0
ファイル: UilSrcSrc.c プロジェクト: fjardon/motif
status
src_get_source_line(void)
{
    uil_fcb_type	    *az_fcb;
    src_source_record_type  *az_source_record;
    status		    l_read_status;

    /* Return if already at the end of file */

    if (src_az_current_source_buffer == NULL)
	return src_k_end_source;

    /* Find the current fcb */

    az_fcb = src_az_source_file_table
		[ (int)src_az_current_source_buffer->b_file_number ];

    /* Read the next record */

    l_read_status = get_line( az_fcb );

    /* Increment lines processed count, and update current file */
    Uil_lines_processed++;
    Uil_current_file = az_fcb->expanded_name;

    if ( (l_read_status == src_k_read_normal) ||
	 (l_read_status == src_k_read_truncated) )
    {
	/* Read was successful
	 * Set position to the start of the record */

	src_az_current_source_buffer->w_current_position = 0;

	/* Allocate and initialize a source record */
	
	az_source_record = 
	    (src_source_record_type *)
		_get_memory( sizeof( src_source_record_type ) );

	az_source_record->az_next_source_record = NULL;
	az_source_record->w_line_number = 
	    ++src_az_current_source_buffer->w_current_line_number;
	az_source_record->b_file_number = 
	    src_az_current_source_buffer->b_file_number;
	az_source_record->az_message_list = NULL;
	az_source_record->az_machine_code_list = NULL;
	az_source_record->w_machine_code_cnt = 0;
	az_source_record->z_access_key = az_fcb->last_key;

	/* was uninitialized; fixes listing problem on HP  (RAP) */
        az_source_record->b_flags = 0;

	/* Link the source record to the end of source record list */

	src_az_current_source_record->az_next_source_record =
	    az_source_record;
	src_az_current_source_record = az_source_record;

	if (l_read_status == src_k_read_truncated)
	    diag_issue_diagnostic( d_src_truncate,
			      	   src_az_current_source_record,
			      	   diag_k_no_column,
				   src_k_max_source_line_length );
    
	return src_k_read_normal;
    }

    /* Check for end of file */

    if (l_read_status == src_k_end_source)
    {
	src_source_buffer_type	*az_prior_source_buffer;
	
	/* get prior source buffer */

	az_prior_source_buffer = 
	    src_az_current_source_buffer->az_prior_source_buffer;

	/* place current source buffer on the available list */

	src_az_current_source_buffer->az_prior_source_buffer =
	    src_az_avail_source_buffer;
	src_az_avail_source_buffer = src_az_current_source_buffer;

	/* if there is no prior source buffer - return end of source */

	if (az_prior_source_buffer == NULL)
	    return src_k_end_source;

	/* restore the prior buffer as current */

	src_az_current_source_buffer = az_prior_source_buffer;

	return src_k_read_normal;
    }

    /* must have been an error */

    diag_issue_diagnostic( d_src_read,
		      	   src_az_current_source_record,
		      	   diag_k_no_column,
			   az_fcb->expanded_name );

    _assert( FALSE, "read past source error" );
	return(src_k_read_error);
}
コード例 #5
0
ファイル: UilSrcSrc.c プロジェクト: fjardon/motif
void
src_open_file (XmConst char *c_file_name,
               char         *full_file_name)
{
    uil_fcb_type		*az_fcb;	    /* file control block ptr */
    status			l_open_status;	    /* status variable */
    src_source_buffer_type	*az_source_buffer;  /* source buffer ptr */

    /* allocate fcb and source buffer */

    az_fcb = (uil_fcb_type *) _get_memory (sizeof (uil_fcb_type));

    if (src_az_avail_source_buffer != NULL) {
	az_source_buffer = src_az_avail_source_buffer;
	src_az_avail_source_buffer = 
		src_az_avail_source_buffer->az_prior_source_buffer;
    } else {
	az_source_buffer =
	    (src_source_buffer_type *)
			_get_memory (sizeof (src_source_buffer_type));
    }

    /* Call the OS-specific open file procedure */

    l_open_status = open_source_file (
			c_file_name,
			az_fcb,
			az_source_buffer );

    /*	If the file is not found, a fatal error is generated.	*/

    if ( l_open_status == src_k_open_error ) {
	diag_issue_diagnostic( d_src_open,
			       diag_k_no_source, diag_k_no_column,
			       c_file_name );
    }

    /* put fcb in the file table */

    src_l_last_source_file_number++;

    if (src_l_last_source_file_number >= src_k_max_source_files) {
	diag_issue_diagnostic (
		d_src_limit,
		src_az_current_source_record,
		src_az_current_source_buffer -> w_current_position - 1,
		az_fcb->expanded_name );
    }

    src_az_source_file_table[ src_l_last_source_file_number ] = az_fcb;

    /* Complete the OS-independent initialization. Get the size of the file
    ** for %complete info then initialize a source
    ** buffer placing a null in the buffer will cause the lexical analyzer
    ** to start by reading the first line of the file
    */

    /* %COMPLETE */
    if (stat(az_fcb->expanded_name, &stbuf) == -1) {
	diag_issue_diagnostic( d_src_open,
			       diag_k_no_source, diag_k_no_column,
			       az_fcb->expanded_name );
    }

    Uil_file_size = stbuf.st_size;

    if (full_file_name != NULL)
	strcpy (full_file_name, az_fcb->expanded_name);

    az_fcb->v_position_before_get = FALSE;

    az_source_buffer->w_current_line_number = 0;
    az_source_buffer->b_file_number = src_l_last_source_file_number;
    az_source_buffer->w_current_position = 0;
    az_source_buffer->c_text[ 0 ] = 0;

    /* make the source buffer current */

    az_source_buffer->az_prior_source_buffer =
				src_az_current_source_buffer;
    src_az_current_source_buffer = az_source_buffer;

    return;
}
コード例 #6
0
ファイル: UilSrcSrc.c プロジェクト: fjardon/motif
void
Uil_src_cleanup_source(void)
{

    int				i;		    /* index over fcbs */
    src_source_buffer_type	*buffer_to_free;   
    src_source_record_type	*record_to_free;
    src_machine_code_type	*first_code_item; 
    src_machine_code_type	*code_item_to_free; 
    status			l_close_status;

    /*
    **  Loop through all open files freeing their fcbs
    */
    for (i = 0; i <= src_l_last_source_file_number; i++)
	{
	/* it is possible to get an error before the files are open,
	   so check and see if table is NULL before opening */
	if (src_az_source_file_table[i] == NULL)
		continue;
	l_close_status = close_source_file (src_az_source_file_table[i]);
	if ( l_close_status == src_k_close_error )
	    {
	    diag_issue_diagnostic (d_src_close,
				   diag_k_no_source, diag_k_no_column,
				   src_az_source_file_table[i]->expanded_name);
	    }
	_free_memory ((char*)src_az_source_file_table [i]);
	src_az_source_file_table[i] = NULL;
	}

    /*
    **  Loop through list of current source buffers, freeing them
    */
    while (src_az_current_source_buffer != NULL)
	{
    	buffer_to_free = src_az_current_source_buffer;
    	src_az_current_source_buffer = 
	    src_az_current_source_buffer->az_prior_source_buffer;
	_free_memory ((char*)buffer_to_free);
	}

    /*
    **  Loop through list of source records, freeing them
    */
    while (src_az_first_source_record != NULL)
	{
	record_to_free = src_az_first_source_record;
	first_code_item = record_to_free->az_machine_code_list;
	
	while (first_code_item != NULL)
	  {
	    code_item_to_free = first_code_item;
	    first_code_item = first_code_item->az_next_machine_code;
	    _free_memory((char *)code_item_to_free);
	  }
	
	src_az_first_source_record =
	    src_az_first_source_record->az_next_source_record;
	_free_memory ((char*)record_to_free);
	}

    /*
    **  Free Own storage
    */
/* BEGIN OSF FIX pir 2240 */
    /* Memory pointed to by main_fcb already freed. */
/* END OSF FIX pir 2240 */
    _free_memory (include_dir);

    return;
}