Exemplo n.º 1
0
static void release_options(void) {  
g95_directorylist *m;

  g95_free(g95_option.module_dir); 
  while(g95_option.include_dirs != NULL) {     
    m = g95_option.include_dirs;          
    g95_option.include_dirs = g95_option.include_dirs->next;        
    g95_free(m->path);         
    g95_free(m);     
  }        
}
Exemplo n.º 2
0
static void free_case(g95_case *f) {  
  
  g95_free_expr(f->low);          
  if (f->high != f->low) g95_free_expr(f->high);       
       
  g95_free(f);          
}       
Exemplo n.º 3
0
static void free_case(g95_case *p) {

    g95_free_expr(p->low);

    if (p->high != p->low)
	g95_free_expr(p->high);

    g95_free(p);
}
Exemplo n.º 4
0
void g95_options_done(void) {
g95_warning_list *n;

    while(g95_option.nowarn != NULL) { 
	n = g95_option.nowarn->next;
	g95_free(g95_option.nowarn);

	g95_option.nowarn = n;
    }
}
Exemplo n.º 5
0
static void free_strings(void) {     
string_node *p, *m;          
int c;

  for(c=0; c<HASH_SIZE; c++) {         
    for(p=string_head[c]; p; p=m) {      
      m = p->next;     
      g95_free(p); 
    }     
  }          
} 
Exemplo n.º 6
0
void g95_expand_forall(g95_code *r) {     
g95_code *save, *old, *p, *g;          
g95_forall_iterator *w;   
   
  save = current_node;       
  current_node = r;   
   
  forall_preamble(r);

  for(p=r->block; p; p=g) {
    g = p->next;
    p->next = NULL;  
  
    forall_body(r->ext.forall_iterator, r->expr != NULL, p); 
  }

  /* Restore loop indeces.  Free the forall_iterator without getting
   * rid of the expression nodes which are now used elsewhere. */          
          
  for(w=r->ext.forall_iterator; w; w=w->next) {         
    old = g95_get_code();   
    old->type = EXEC_ASSIGN;         
    old->where = current_node->where;       
       
    old->expr  = g95_copy_expr(w->var);        
    old->expr2 = g95_get_variable_expr(w->save);         
    insert_post(old);         
         
    g95_free(w);          
  }   
   
  if (r->expr != NULL) {     
    p = g95_get_code();  
    p->type = EXEC_CALL;         
    p->where = current_node->where;    
    p->isym = &forall_done;        
    p->sub_name = PREFIX "forall_done";   
    insert_post(p);  
  } 
 
  r->type = EXEC_NOP;         
  r->block = NULL;        
  r->ext.forall_iterator = NULL;  
  r->expr = NULL;        
  r->where = current_node->where; 
  g95_free_forall_iterator(r->ext.forall_iterator);     
     
  current_node = save;     
}
Exemplo n.º 7
0
static int dump_code(g95_code *c) {
int m, n, list_size, *list, node[2];
g95_forall_iterator *f;
g95_filepos *filepos;
g95_inquire *inquire;
g95_close *close;
g95_flush *flush;
g95_alloc *alloc;
g95_open *open;
g95_wait *wait;
g95_case *sel;
g95_code *d;
g95_dt *dt;

    if (c == NULL)
	return 0;

    n = st_n++;
    list = NULL;
    list_size = 0;

    dumpf("%C = []\n", n);

    for(; c; c=c->next) {
	switch(c->type) {
	case EXEC_CONTINUE:
	case EXEC_NOP:
	case EXEC_DT_END:
	    dumpf("%C.append(st_nop(%L", n, &c->where);
	    break;

	case EXEC_ASSIGN:
	    dumpf("%C.append(st_assign(%L,", n, &c->where);
	    dump_expr(c->expr);
	    dump_char(',');
	    dump_expr(c->expr2);
	    break;

	case EXEC_POINTER_ASSIGN:
	    dumpf("%C.append(st_ptr_assign(%L,", n, &c->where);
	    dump_expr(c->expr);
	    dump_char(',');
	    dump_expr(c->expr2);
	    break;

	case EXEC_GOTO:
	    dumpf("%C.append(st_goto(%L, %d", n, &c->where, c->label->value);
	    break;

	case EXEC_PAUSE:
	    dumpf("%C.append(st_pause(%L", n, &c->where);
	    break;

	case EXEC_STOP:
	    dumpf("%C.append(st_stop(%L", n, &c->where);
	    break;

	case EXEC_RETURN:
	    dumpf("%C.append(st_return(%L", n, &c->where);
	    if (c->expr != NULL) {
		dumpf(",rc=");
		dump_expr(c->expr);
	    }

	    break;

	case EXEC_IF:
	    node[0] = dump_code(c->block);
	    node[1] = dump_code(c->ext.block);
	    list = node;
	    list_size = 2;

	    dumpf("%C.append(st_if(%L,", n, &c->where);
	    dump_expr(c->expr);
	    dumpf(",%C,%C", node[0], node[1]);
	    break;

	case EXEC_DO_WHILE:
	    node[0] = dump_code(c->block);
	    list = node;
	    list_size = 1;

	    dumpf("%C.append(st_do_while(%L,", n, &c->where, node[0]);
	    dump_expr(c->expr);

	    dumpf(",%C", node[0]);

	    if (c->sym != NULL)
		dumpf(",label='%s'", c->sym->name);

	    break;

	case EXEC_DO:
	    node[0] = dump_code(c->block);
	    list = node;
	    list_size = 1;

	    dumpf("%C.append(st_do(%L, ", n, &c->where);
	    dump_expr(c->ext.iterator->var);

	    dump_char(',');
	    dump_expr(c->ext.iterator->start);

	    dump_char(',');
	    dump_expr(c->ext.iterator->end);

	    dump_char(',');
	    dump_expr(c->ext.iterator->step);

	    dumpf(",%C", node[0]);

	    if (c->sym != NULL)
		dumpf(",label='%s'", c->sym->name);

	    break;

	case EXEC_OPEN:
	    open = c->ext.open;
	    dumpf("%C.append(st_open(%L", n, &c->where);

	    if (open->unit != NULL) {
		dumpf(",unit=");
		dump_expr(open->unit);
	    }

	    if (open->file != NULL) {
		dumpf(",file=");
		dump_expr(open->file);
	    }

	    if (open->status != NULL) {
		dumpf(",status=");
		dump_expr(open->status);
	    }

	    if (open->access != NULL) {
		dumpf(",access=");
		dump_expr(open->access);
	    }

	    if (open->form != NULL) {
		dumpf(",form=");
		dump_expr(open->form);
	    }

	    if (open->recl != NULL) {
		dumpf(",recl=");
		dump_expr(open->recl);
	    }

	    if (open->decimal != NULL) {
		dumpf(",decimal=");
		dump_expr(open->decimal);
	    }

	    if (open->blank != NULL) {
		dumpf(",blank=");
		dump_expr(open->position);
	    }

	    if (open->position != NULL) {
		dumpf(",position=");
		dump_expr(open->position);
	    }

	    if (open->action != NULL) {
		dumpf(",action=");
		dump_expr(open->action);
	    }

	    if (open->delim != NULL) {
		dumpf(",delim=");
		dump_expr(open->delim);
	    }

	    if (open->pad != NULL) {
		dumpf(",pad=");
		dump_expr(open->pad);
	    }

	    if (open->iostat != NULL) {
		dumpf(",iostat=");
		dump_expr(open->iostat);
	    }

	    if (open->err != NULL)
		dumpf(",err=%d", open->err->value);

	    break;

	case EXEC_CLOSE:
	    close = c->ext.close;
	    dumpf("%C.append(st_close(%L", n, &c->where);

	    if (close->unit != NULL) {
		dumpf(",unit=");
		dump_expr(close->unit);
	    }

	    if (close->status != NULL) {
		dumpf(",status=");
		dump_expr(close->status);
	    }

	    if (close->iostat != NULL) {
		dumpf(",iostat=");
		dump_expr(close->iostat);
	    }

	    if (close->err != NULL)
		dumpf(",err=%d", close->err->value);

	    break;

	case EXEC_BACKSPACE:
	    dumpf("%C.append(st_backspace(%L", n, &c->where);
	    goto show_filepos;

	case EXEC_ENDFILE:
	    dumpf("%C.append(st_endfile(%L", n, &c->where);
	    goto show_filepos;

	case EXEC_REWIND:
	    dumpf("%C.append(st_rewind(%L", n, &c->where);

	show_filepos:
	    filepos = c->ext.filepos;

	    if (filepos->unit != NULL) {
		dumpf(",unit=");
		dump_expr(filepos->unit);
	    }

	    if (filepos->iostat != NULL) {
		dumpf(",iostat=");
		dump_expr(filepos->iostat);
	    }

	    if (filepos->err != NULL)
		dumpf(",err=%d", filepos->err->value);

	    break;

	case EXEC_INQUIRE:
	    dumpf("%C.append(st_inquire(%L", n, &c->where);

	    inquire = c->ext.inquire;

	    if (inquire->unit != NULL) {
		dumpf(",unit=");
		dump_expr(inquire->unit);
	    }

	    if (inquire->file != NULL) {
		dumpf(",file=");
		dump_expr(inquire->file);
	    }

	    if (inquire->iostat != NULL) {
		dumpf(",iostat=");
		dump_expr(inquire->iostat);
	    }

	    if (inquire->exist != NULL) {
		dumpf(",exist=");
		dump_expr(inquire->exist);
	    }

	    if (inquire->opened != NULL) {
		dumpf(",opened=");
		dump_expr(inquire->opened);
	    }

	    if (inquire->number != NULL) {
		dumpf(",number=");
		dump_expr(inquire->number);
	    }

	    if (inquire->named != NULL) {
		dumpf(",named=");
		dump_expr(inquire->named);
	    }

	    if (inquire->name != NULL) {
		dumpf(",name=");
		dump_expr(inquire->name);
	    }

	    if (inquire->access != NULL) {
		dumpf(",access=");
		dump_expr(inquire->access);
	    }

	    if (inquire->sequential != NULL) {
		dumpf(",sequential=");
		dump_expr(inquire->sequential);
	    }

	    if (inquire->direct != NULL) {
		dumpf(",direct=");
		dump_expr(inquire->direct);
	    }

	    if (inquire->form != NULL) {
		dumpf(",form=");
		dump_expr(inquire->form);
	    }

	    if (inquire->formatted != NULL) {
		dumpf(",formatted=");
		dump_expr(inquire->formatted);
	    }

	    if (inquire->unformatted != NULL) {
		dumpf(",unformatted=");
		dump_expr(inquire->unformatted);
	    }

	    if (inquire->recl != NULL) {
		dumpf(",recl=");
		dump_expr(inquire->recl);
	    }

	    if (inquire->nextrec != NULL) {
		dumpf(",nextrec=");
		dump_expr(inquire->nextrec);
	    }

	    if (inquire->blank != NULL) {
		dumpf(",blank=");
		dump_expr(inquire->blank);
	    }

	    if (inquire->position != NULL) {
		dumpf(",position=");
		dump_expr(inquire->position);
	    }

	    if (inquire->action != NULL) {
		dumpf(",action=");
		dump_expr(inquire->action);
	    }

	    if (inquire->read != NULL) {
		dumpf(",read=");
		dump_expr(inquire->read);
	    }

	    if (inquire->write != NULL) {
		dumpf(",write=");
		dump_expr(inquire->write);
	    }

	    if (inquire->readwrite != NULL) {
		dumpf(",readwrite=");
		dump_expr(inquire->readwrite);
	    }

	    if (inquire->delim != NULL) {
		dumpf(",delim=");
		dump_expr(inquire->delim);
	    }

	    if (inquire->pad != NULL) {
		dumpf(",pad=");
		dump_expr(inquire->pad);
	    }

	    if (inquire->pos != NULL) {
		dumpf(",pos=");
		dump_expr(inquire->pos);
	    }

	    if (inquire->iolength != NULL) {
		dumpf(",iolength=");
		dump_expr(inquire->iolength);
	    }

	    if (inquire->size != NULL) {
		dumpf(",size=");
		dump_expr(inquire->size);
	    }

	    if (inquire->err != NULL)
		dumpf(",err=%d", inquire->err->value);

	    break;

	case EXEC_FLUSH:
	    dumpf("%C.append(st_flush(%L", n, &c->where);

	    flush = c->ext.flush;

	    if (flush->unit != NULL) {
		dumpf(",unit=");
		dump_expr(flush->unit);
	    }

	    if (flush->iostat != NULL) {
		dumpf(",iostat=");
		dump_expr(flush->iostat);
	    }

	    if (flush->iomsg != NULL) {
		dumpf(",iomsg=");
		dump_expr(flush->iomsg);
	    }

	    if (flush->err != NULL)
		dumpf(",err=%d", flush->err->value);

	    break;

	case EXEC_WAIT:
	    dumpf("%C.append(st_wait(%L", n, &c->where);

	    wait = c->ext.wait;

	    if (wait->unit != NULL) {
		dumpf(",unit=");
		dump_expr(wait->unit);
	    }

	    if (wait->id != NULL) {
		dumpf(",id=");
		dump_expr(wait->id);
	    }

	    if (wait->iostat != NULL) {
		dumpf(",iostat=");
		dump_expr(wait->iostat);
	    }

	    if (wait->iomsg != NULL) {
		dumpf(",iomsg=");
		dump_expr(wait->iomsg);
	    }

	    if (wait->err != NULL)
		dumpf(",err=%d", wait->err->value);

	    if (wait->end != NULL)
		dumpf(",end=%d", wait->end->value);

	    if (wait->eor != NULL)
		dumpf(",eof=%d", wait->eor->value);

	    break;

	case EXEC_IOLENGTH:
	    dumpf("%C.append(st_iolength(%L,", n, &c->where);
	    dump_expr(c->expr);
	    break;

	case EXEC_WRITE:
	    dumpf("%C.append(st_write(%L", n, &c->where);
	    goto show_dt;

	case EXEC_READ:
	    dumpf("%C.append(st_read(%L", n, &c->where);

	show_dt:
	    dt = c->ext.dt;

	    if (dt->io_unit->ts.type == BT_INTEGER)
		dumpf(",unit=");

	    else
		dumpf(",internal_unit=");

	    dump_expr(dt->io_unit);

	    if (dt->format_expr != NULL) {
		dumpf(",format_expr=");
		dump_expr(dt->format_expr);
	    }

	    if (dt->rec != NULL) {
		dumpf(",rec=");
		dump_expr(dt->rec);
	    }

	    if (dt->advance != NULL) {
		dumpf(",advance=");
		dump_expr(dt->advance);
	    }

	    if (dt->iostat != NULL) {
		dumpf(",iostat=");
		dump_expr(dt->iostat);
	    }

	    if (dt->size != NULL) {
		dumpf(",size=");
		dump_expr(dt->size);
	    }

	    if (dt->pos != NULL) {
		dumpf(",pos=");
		dump_expr(dt->pos);
	    }

	    if (dt->decimal != NULL) {
		dumpf(",decimal=");
		dump_expr(dt->decimal);
	    }

	    if (dt->namelist != NULL)
		dumpf(",namelist=(%S,%L)", dt->namelist->name,
		      &dt->namelist_where);

	    if (dt->format_label != NULL)
		dumpf(",format_label=%d", dt->format_label->value);

	    if (dt->err != NULL)
		dumpf(",err=%d", dt->err->value);

	    if (dt->end != NULL)
		dumpf(",end=%d", dt->end->value);

	    if (dt->eor != NULL)
		dumpf(",eof=%d", dt->eor->value);

	    break;

	case EXEC_TRANSFER:
	    dumpf("%C.append(st_transfer(%L,%d,", n, &c->expr->where,
		  c->ext.transfer == M_READ);
	    dump_expr(c->expr);
	    break;

	case EXEC_ALLOCATE:
	    dumpf("%C.append(st_allocate(%L,", n, &c->where);
	    goto show_alloc;

	case EXEC_DEALLOCATE:
	    dumpf("%C.append(st_deallocate(%L,", n, &c->where);

	show_alloc:
	    dumpf("[");
	    alloc = c->ext.alloc_list;

	    while(alloc != NULL) {
		dump_expr(alloc->expr);
		
		if (alloc->next != NULL)
		    dump_char(',');

		alloc = alloc->next;
	    }

	    dumpf("]");

	    if (c->expr != NULL) {
		dumpf(",stat=");
		dump_expr(c->expr);
	    }

	    break;

	case EXEC_ARITHMETIC_IF:
	    dumpf("%C.append(st_arith_if(%L,", n, &c->where);
	    dump_expr(c->expr);
	    dumpf(", %d, %d, %d", c->label->value, c->label2->value,
		  c->label3->value);
	    break;

	case EXEC_LABEL_ASSIGN:
	    dumpf("%C.append(st_label_assign(%L,", n, &c->where);
	    dump_expr(c->expr);
	    dumpf(", %d", c->label->value);
	    break;

	case EXEC_SELECT:
	    for(d=c->block; d; d=d->block)
		list_size++;

	    list = g95_getmem(list_size * sizeof(int));
	    m = 0;

	    for(d=c->block; d; d=d->block)
		list[m++] = dump_code(d->next);

	    dumpf("%C.append(st_select(%L, ", n, &c->where);

	    dump_expr(c->expr);
	    dumpf(",[");

	    m = 0;

	    for(d=c->block; d; d=d->next) {
		dumpf("[");

		for(sel=d->ext.case_list; sel; sel=sel->next) {
		    dump_char('(');

		    if (sel->low == NULL)
			dumpf("None");
		    else
			dump_expr(sel->low);

		    dumpf(",");

		    if (sel->high == NULL)
			dumpf("None");
		    else
			dump_expr(sel->high);
		}

		dumpf("],%C,", list[m++]);
	    }

	    dump_char(']');
	    break;

	case EXEC_CYCLE:
	    dumpf("%C.append(st_cycle(%L", n, &c->where);

	    if (c->sym != NULL)
		dumpf(",label=%p", c->sym);

	    break;

	case EXEC_EXIT:
	    dumpf("%C.append(st_exit(%L", n, &c->where);

	    if (c->sym != NULL)
		dumpf(",label=%p", c->sym);

	    break;

	case EXEC_ENTRY:
	    dumpf("%C.append(st_entry(%L,'%s',", n, &c->where, c->sym->name);
	    dump_formal(c->sym);
	    break;

	case EXEC_WHERE:
	    for(d=c->block; d; d=d->block)
		list_size++;

	    list = g95_getmem(list_size * sizeof(int));

	    m = 0;
	    for(d=c->block; d; d=d->block)
		list[m++] = dump_code(d->next);

	    dumpf("%C.append(st_where(%L, [", n, &c->where);

	    m = 0;
	    for(d=c->block; d; d=d->block) {
		dump_char('(');

		if (d->expr == NULL)
		    dumpf("None");
		else
		    dump_expr(d->expr);

		dumpf(",%C),", list[m++]);
	    }

	    dump_char(']');
	    break;

	case EXEC_FORALL:
	    node[0] = dump_code(c->block);
	    list = node;
	    list_size = 1;

	    dumpf("%C.append(st_forall(%L, [", n, &c->where);

	    for(f=c->ext.forall_iterator; f; f=f->next) {
		dump_char('(');
		dump_expr(f->var);
		dump_char(',');
		dump_expr(f->start);
		dump_char(',');
		dump_expr(f->end);
		dump_char(',');
		dump_expr(f->stride);
		dump_char(')');

		if (f->next != NULL)
		    dump_char(',');
	    }

	    dumpf("], %C", node[0]);

	    if (c->expr != NULL) {
		dumpf(", mask=");
		dump_expr(c->expr);
	    }

	    break;

	case EXEC_CALL:
	    dumpf("%C.append(st_call(%L,", n, &c->where);
	    dump_name(c->sym, c->ext.sub.isym);
	    dump_char(',');
	    dump_actual(c->ext.sub.actual);
	    break;

	default:
	    g95_internal_error("dump_code(): Bad code");
	    break;
	}

	if (c->here != NULL)
	    dumpf(",here=%d", c->here->value);

	dumpf("))\n");

	for(m=0; m<list_size; m++)
	    if (list[m] != 0)
		dumpf("del %C\n", list[m]);

	list_size = 0;

	if (list != NULL && list != node)
	    g95_free(list);
    }

    return n;
}