source: vis_dev/vl2mv-2.3/src/parser/vl_vardecl.c @ 91

Last change on this file since 91 was 18, checked in by cecile, 13 years ago

vl2mv added

File size: 2.2 KB
Line 
1/*
2
3  Copyright (c) 1992, 1993
4        Regents of the University of California
5  All rights reserved.
6
7  Use and copying of this software and preparation of derivative works
8  based upon this software are permitted.  However, any distribution of
9  this software or derivative works must include the above copyright
10  notice.
11
12  This software is made available AS IS, and neither the Electronics
13  Research Laboratory or the Universify of California make any
14  warranty about the software, its performance or its conformity to
15  any specification.
16
17  Author: Szu-Tsung Cheng, stcheng@ic.Berkeley.EDU
18          10/92
19          10/93
20
21  $Header: /projects/development/hsv/CVSRepository/vl2mv/src/parser/vl_vardecl.c,v 1.2 2009/03/09 20:25:58 fabio Exp $
22
23
24*/
25
26#include <stdio.h>
27#include <math.h>
28#include "util.h"
29#include "array.h"
30#include "list.h"
31#include "st.h"
32#include "set.h"
33#include "vl_types.h"
34#include "vl_defs.h"
35#include "vlr_int.h"
36#include "vl_fg_defs.h"
37#include "vl_create.h"
38#include "vl_write.h"
39#include "vl_write_util.h"
40#include "vl_vardecl.h"
41
42
43void write_var_decl(file, term)
44FILE *file;
45vl_term *term;
46{
47    if (term->flag & MVar)
48        write_mvar_decl(file, term);
49}
50
51
52void write_mvar_decl(file, term)
53FILE *file;
54vl_term *term;
55{
56    lsList domain;
57    lsGen enum_gen;
58    vl_enumerator *enum_elt;
59
60    if (!(term->flag & MVar)) return;
61
62    domain = term->term_type->specifier->u.enum_type->domain_list;
63    if (!term->name->range) {
64        int i;
65
66        fprintf(file, ".mv %s %d ", term->name->name, lsLength(domain));
67        for (enum_gen=lsStart(domain), i=0;
68             lsNext(enum_gen, &enum_elt, LS_NH)!=LS_NOMORE; i++) {
69            fprintf(file, "%s ", enum_elt->name);
70        }
71        lsFinish(enum_gen);
72        fprintf(file, "\n");
73    } else {
74        int array_lo, array_hi, array_idx;
75        array_lo = vl_eval_expr(term->name->range->left);
76        if (term->name->range->right)
77            array_hi = vl_eval_expr(term->name->range->right);
78        else
79            array_hi = array_lo;
80
81        for (array_idx=array_lo; array_idx<=array_hi; array_idx++) {
82            fprintf(file, ".mv %s%s%d%s %d ",
83                    term->name->name, SEP_LARRAY, array_idx, SEP_RARRAY,
84                    lsLength(domain));
85            for (enum_gen=lsStart(domain);
86                 lsNext(enum_gen, &enum_elt, LS_NH)!= LS_NOMORE;) {
87                fprintf(file, "%s ", enum_elt->name);
88            }
89            lsFinish(enum_gen);
90            fprintf(file, "\n");
91        }
92    }
93}
Note: See TracBrowser for help on using the repository browser.