<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <title>src/comet2.c</title> <meta name='robots' content='noindex,nofollow' /> <meta name='generator' content='GLOBAL-6.6.5' /> <meta http-equiv='Content-Style-Type' content='text/css' /> <link rel='stylesheet' type='text/css' href='../style.css' /> </head> <body> <a id='TOP' name='TOP'></a><h2 class='header'><a href='../mains.html'>root</a>/<a href='../files/2932.html'>src</a>/comet2.c</h2> <em class='comment'>/* [<][>]<a href='#L30'>[^]</a>[v][top]<a href='#BOTTOM'>[bottom]</a><a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</em> <hr /> <h2 class='header'>DEFINITIONS</h2> This source file includes following definitions. <ol> <li><a href='#L30' title='Defined at 30.'>main</a></li> </ol> <hr /> <pre> <a id='L1' name='L1'></a> 1 <em class='sharp'>#include</em> "<a href='2418.html'>package.h</a>" <a id='L2' name='L2'></a> 2 <em class='sharp'>#include</em> "<a href='2420.html'>exec.h</a>" <a id='L3' name='L3'></a> 3 <em class='sharp'>#include</em> "<a href='2416.html'>load.h</a>" <a id='L4' name='L4'></a> 4 <a id='L5' name='L5'></a> 5 <em class='comment'>/**</em> <a id='L6' name='L6'></a> 6 <em class='comment'> * comet2コマンドのオプション</em> <a id='L7' name='L7'></a> 7 <em class='comment'> */</em> <a id='L8' name='L8'></a> 8 <strong class='reserved'>static</strong> <strong class='reserved'>struct</strong> <a href='../Y/169.html' title='Multiple used in 5 places.'>option</a> <a href='../Y/138.html' title='Multiple used in 10 places.'>longopts</a>[] = <em class='brace'>{</em> <a id='L9' name='L9'></a> 9 <em class='brace'>{</em>"trace", <a href='../Y/156.html' title='Multiple used in 27 places.'>no_argument</a>, <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>, 't'<em class='brace'>}</em>, <a id='L10' name='L10'></a> 10 <em class='brace'>{</em>"tracearithmetic", <a href='../Y/156.html' title='Multiple used in 27 places.'>no_argument</a>, <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>, 't'<em class='brace'>}</em>, <a id='L11' name='L11'></a> 11 <em class='brace'>{</em>"tracelogical", <a href='../Y/156.html' title='Multiple used in 27 places.'>no_argument</a>, <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>, 'T'<em class='brace'>}</em>, <a id='L12' name='L12'></a> 12 <em class='brace'>{</em>"dump", <a href='../Y/156.html' title='Multiple used in 27 places.'>no_argument</a>, <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>, 'd'<em class='brace'>}</em>, <a id='L13' name='L13'></a> 13 <em class='brace'>{</em>"monitor", <a href='../Y/156.html' title='Multiple used in 27 places.'>no_argument</a>, <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>, 'm'<em class='brace'>}</em>, <a id='L14' name='L14'></a> 14 <em class='brace'>{</em>"memorysize", <a href='../Y/186.html' title='Multiple used in 6 places.'>required_argument</a>, <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>, 'M'<em class='brace'>}</em>, <a id='L15' name='L15'></a> 15 <em class='brace'>{</em>"clocks", <a href='../Y/186.html' title='Multiple used in 6 places.'>required_argument</a>, <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>, 'C'<em class='brace'>}</em>, <a id='L16' name='L16'></a> 16 <em class='brace'>{</em>"version", <a href='../Y/156.html' title='Multiple used in 27 places.'>no_argument</a>, <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>, 'v' <em class='brace'>}</em>, <a id='L17' name='L17'></a> 17 <em class='brace'>{</em>"help", <a href='../Y/156.html' title='Multiple used in 27 places.'>no_argument</a>, <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>, 'h'<em class='brace'>}</em>, <a id='L18' name='L18'></a> 18 <em class='brace'>{</em>0, 0, 0, 0<em class='brace'>}</em>, <a id='L19' name='L19'></a> 19 <em class='brace'>}</em>; <a id='L20' name='L20'></a> 20 <a id='L21' name='L21'></a> 21 <a id='L22' name='L22'></a> 22 <em class='comment'>/**</em> <a id='L23' name='L23'></a> 23 <em class='comment'> * @brief comet2コマンドのメイン</em> <a id='L24' name='L24'></a> 24 <em class='comment'> *</em> <a id='L25' name='L25'></a> 25 <em class='comment'> * @return 正常終了時は0、異常終了時は1</em> <a id='L26' name='L26'></a> 26 <em class='comment'> *</em> <a id='L27' name='L27'></a> 27 <em class='comment'> * @param argc コマンドライン引数の数</em> <a id='L28' name='L28'></a> 28 <em class='comment'> * @param *argv[] コマンドライン引数の配列</em> <a id='L29' name='L29'></a> 29 <em class='comment'> */</em> <a id='L30' name='L30'></a> 30 <strong class='reserved'>int</strong> main(<strong class='reserved'>int</strong> <a href='../Y/8.html' title='Multiple used in 38 places.'>argc</a>, <strong class='reserved'>char</strong> *<a href='../Y/10.html' title='Multiple used in 63 places.'>argv</a>[]) <a id='L31' name='L31'></a> 31 <em class='brace'>{</em> <a id='L32' name='L32'></a> 32 <strong class='reserved'>int</strong> <a href='../Y/146.html' title='Multiple used in 30 places.'>memsize</a> = <a href='../S/2417.html#L19' title='Defined at 19 in include/struct.h.'>DEFAULT_MEMSIZE</a>; <a id='L33' name='L33'></a> 33 <strong class='reserved'>int</strong> <a href='../Y/58.html' title='Multiple used in 15 places.'>clocks</a> = <a href='../S/2417.html#L20' title='Defined at 20 in include/struct.h.'>DEFAULT_CLOCKS</a>; <a id='L34' name='L34'></a> 34 <strong class='reserved'>int</strong> <a href='../Y/166.html' title='Multiple used in 15 places.'>opt</a> = 0; <a id='L35' name='L35'></a> 35 <strong class='reserved'>int</strong> <a href='../Y/197.html' title='Multiple used in 34 places.'>stat</a> = 0; <a id='L36' name='L36'></a> 36 <strong class='reserved'>const</strong> <strong class='reserved'>char</strong> *<a href='../Y/234.html' title='Multiple used in 10 places.'>version</a> = <a href='../D/55.html' title='Multiple defined in 2 places.'>PACKAGE_VERSION</a>; <a id='L37' name='L37'></a> 37 <strong class='reserved'>const</strong> <strong class='reserved'>char</strong> *<a href='../Y/67.html' title='Multiple used in 10 places.'>cmdversion</a> = "comet2 of YACASL2 version %s\n"; <a id='L38' name='L38'></a> 38 <strong class='reserved'>const</strong> <strong class='reserved'>char</strong> *<a href='../Y/231.html' title='Multiple used in 16 places.'>usage</a> = "Usage: %s [-tTdmvh] [-M <MEMORYSIZE>] [-C <CLOCKS>] FILE\n"; <a id='L39' name='L39'></a> 39 <a id='L40' name='L40'></a> 40 <em class='comment'>/* エラーの定義 */</em> <a id='L41' name='L41'></a> 41 <a href='../S/2845.html#L3' title='Defined at 3 in src/cerr.c.'>cerr_init</a>(); <a id='L42' name='L42'></a> 42 <a href='../S/2852.html#L22' title='Defined at 22 in src/load.c.'>addcerrlist_load</a>(); <a id='L43' name='L43'></a> 43 <a href='../S/2812.html#L213' title='Defined at 213 in src/exec.c.'>addcerrlist_exec</a>(); <a id='L44' name='L44'></a> 44 <a id='L45' name='L45'></a> 45 <em class='comment'>/* オプションの処理 */</em> <a id='L46' name='L46'></a> 46 <strong class='reserved'>while</strong>((<a href='../Y/166.html' title='Multiple used in 15 places.'>opt</a> = <a href='../Y/112.html' title='Multiple used in 5 places.'>getopt_long</a>(<a href='../Y/8.html' title='Multiple used in 38 places.'>argc</a>, <a href='../Y/10.html' title='Multiple used in 63 places.'>argv</a>, "tTdmM:C:vh", <a href='../Y/138.html' title='Multiple used in 10 places.'>longopts</a>, <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>)) != -1) <em class='brace'>{</em> <a id='L47' name='L47'></a> 47 <strong class='reserved'>switch</strong>(<a href='../Y/166.html' title='Multiple used in 15 places.'>opt</a>) <em class='brace'>{</em> <a id='L48' name='L48'></a> 48 <strong class='reserved'>case</strong> 't': <a id='L49' name='L49'></a> 49 <a href='../Y/88.html' title='Multiple used in 35 places.'>execmode</a>.<a href='../Y/227.html' title='Multiple used in 13 places.'>trace</a> = <a href='../Y/228.html' title='Multiple used in 79 places.'>true</a>; <a id='L50' name='L50'></a> 50 <strong class='reserved'>break</strong>; <a id='L51' name='L51'></a> 51 <strong class='reserved'>case</strong> 'T': <a id='L52' name='L52'></a> 52 <a href='../Y/88.html' title='Multiple used in 35 places.'>execmode</a>.<a href='../Y/227.html' title='Multiple used in 13 places.'>trace</a> = <a href='../Y/228.html' title='Multiple used in 79 places.'>true</a>; <a id='L53' name='L53'></a> 53 <a href='../Y/88.html' title='Multiple used in 35 places.'>execmode</a>.<a href='../Y/136.html' title='Multiple used in 6 places.'>logical</a> = <a href='../Y/228.html' title='Multiple used in 79 places.'>true</a>; <a id='L54' name='L54'></a> 54 <strong class='reserved'>break</strong>; <a id='L55' name='L55'></a> 55 <strong class='reserved'>case</strong> 'd': <a id='L56' name='L56'></a> 56 <a href='../Y/88.html' title='Multiple used in 35 places.'>execmode</a>.<a href='../Y/81.html' title='Multiple used in 8 places.'>dump</a> = <a href='../Y/228.html' title='Multiple used in 79 places.'>true</a>; <a id='L57' name='L57'></a> 57 <strong class='reserved'>break</strong>; <a id='L58' name='L58'></a> 58 <strong class='reserved'>case</strong> 'm': <a id='L59' name='L59'></a> 59 <a href='../Y/88.html' title='Multiple used in 35 places.'>execmode</a>.<a href='../S/2804.html#L389' title='Defined at 389 in src/monitor.c.'>monitor</a> = <a href='../Y/228.html' title='Multiple used in 79 places.'>true</a>; <a id='L60' name='L60'></a> 60 <strong class='reserved'>break</strong>; <a id='L61' name='L61'></a> 61 <strong class='reserved'>case</strong> 'M': <a id='L62' name='L62'></a> 62 <a href='../Y/146.html' title='Multiple used in 30 places.'>memsize</a> = <a href='../Y/21.html' title='Multiple used in 7 places.'>atoi</a>(<a href='../Y/167.html' title='Multiple used in 8 places.'>optarg</a>); <a id='L63' name='L63'></a> 63 <strong class='reserved'>break</strong>; <a id='L64' name='L64'></a> 64 <strong class='reserved'>case</strong> 'C': <a id='L65' name='L65'></a> 65 <a href='../Y/58.html' title='Multiple used in 15 places.'>clocks</a> = <a href='../Y/21.html' title='Multiple used in 7 places.'>atoi</a>(<a href='../Y/167.html' title='Multiple used in 8 places.'>optarg</a>); <a id='L66' name='L66'></a> 66 <strong class='reserved'>break</strong>; <a id='L67' name='L67'></a> 67 <strong class='reserved'>case</strong> 'v': <a id='L68' name='L68'></a> 68 <a href='../Y/102.html' title='Multiple used in 115 places.'>fprintf</a>(<a href='../Y/200.html' title='Multiple used in 93 places.'>stdout</a>, <a href='../Y/67.html' title='Multiple used in 10 places.'>cmdversion</a>, <a href='../Y/234.html' title='Multiple used in 10 places.'>version</a>); <a id='L69' name='L69'></a> 69 <strong class='reserved'>goto</strong> <a href='../Y/75.html' title='Multiple used in 5 places.'>comet2fin</a>; <a id='L70' name='L70'></a> 70 <strong class='reserved'>case</strong> 'h': <a id='L71' name='L71'></a> 71 <a href='../Y/102.html' title='Multiple used in 115 places.'>fprintf</a>(<a href='../Y/200.html' title='Multiple used in 93 places.'>stdout</a>, <a href='../Y/231.html' title='Multiple used in 16 places.'>usage</a>, <a href='../Y/10.html' title='Multiple used in 63 places.'>argv</a>[0]); <a id='L72' name='L72'></a> 72 <strong class='reserved'>goto</strong> <a href='../Y/75.html' title='Multiple used in 5 places.'>comet2fin</a>; <a id='L73' name='L73'></a> 73 <strong class='reserved'>case</strong> '?': <a id='L74' name='L74'></a> 74 <a href='../Y/102.html' title='Multiple used in 115 places.'>fprintf</a>(<a href='../Y/198.html' title='Multiple used in 23 places.'>stderr</a>, <a href='../Y/231.html' title='Multiple used in 16 places.'>usage</a>, <a href='../Y/10.html' title='Multiple used in 63 places.'>argv</a>[0]); <a id='L75' name='L75'></a> 75 <a href='../S/2845.html#L45' title='Defined at 45 in src/cerr.c.'>setcerr</a>(212, ""); <em class='comment'>/* invalid option */</em> <a id='L76' name='L76'></a> 76 <strong class='reserved'>goto</strong> <a href='../Y/75.html' title='Multiple used in 5 places.'>comet2fin</a>; <a id='L77' name='L77'></a> 77 <em class='brace'>}</em> <a id='L78' name='L78'></a> 78 <em class='brace'>}</em> <a id='L79' name='L79'></a> 79 <strong class='reserved'>if</strong>(<a href='../Y/10.html' title='Multiple used in 63 places.'>argv</a>[<a href='../Y/168.html' title='Multiple used in 10 places.'>optind</a>] == <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>) <em class='brace'>{</em> <a id='L80' name='L80'></a> 80 <a href='../S/2845.html#L45' title='Defined at 45 in src/cerr.c.'>setcerr</a>(211, ""); <em class='comment'>/* object file not specified */</em> <a id='L81' name='L81'></a> 81 <a href='../Y/102.html' title='Multiple used in 115 places.'>fprintf</a>(<a href='../Y/198.html' title='Multiple used in 23 places.'>stderr</a>, "comet2 error - %d: %s\n", <a href='../Y/32.html' title='Multiple used in 59 places.'>cerr</a>-><a href='../Y/157.html' title='Multiple used in 57 places.'>num</a>, <a href='../Y/32.html' title='Multiple used in 59 places.'>cerr</a>-><a href='../Y/151.html' title='Multiple used in 23 places.'>msg</a>); <a id='L82' name='L82'></a> 82 <strong class='reserved'>goto</strong> <a href='../Y/75.html' title='Multiple used in 5 places.'>comet2fin</a>; <a id='L83' name='L83'></a> 83 <em class='brace'>}</em> <a id='L84' name='L84'></a> 84 <a href='../S/2856.html#L253' title='Defined at 253 in src/struct.c.'>reset</a>(<a href='../Y/146.html' title='Multiple used in 30 places.'>memsize</a>, <a href='../Y/58.html' title='Multiple used in 15 places.'>clocks</a>); <em class='comment'>/* COMET II仮想マシンのリセット */</em> <a id='L85' name='L85'></a> 85 <a href='../Y/89.html' title='Multiple used in 25 places.'>execptr</a>-><a href='../Y/196.html' title='Multiple used in 19 places.'>start</a> = 0; <a id='L86' name='L86'></a> 86 <a href='../Y/89.html' title='Multiple used in 25 places.'>execptr</a>-><a href='../Y/85.html' title='Multiple used in 25 places.'>end</a> = <a href='../S/2852.html#L27' title='Defined at 27 in src/load.c.'>loadassemble</a>(<a href='../Y/10.html' title='Multiple used in 63 places.'>argv</a>[<a href='../Y/168.html' title='Multiple used in 10 places.'>optind</a>], <a href='../Y/89.html' title='Multiple used in 25 places.'>execptr</a>-><a href='../Y/196.html' title='Multiple used in 19 places.'>start</a>); <a id='L87' name='L87'></a> 87 <strong class='reserved'>if</strong>(<a href='../Y/89.html' title='Multiple used in 25 places.'>execptr</a>-><a href='../Y/85.html' title='Multiple used in 25 places.'>end</a> > 0 && <a href='../Y/32.html' title='Multiple used in 59 places.'>cerr</a>-><a href='../Y/157.html' title='Multiple used in 57 places.'>num</a> == 0) <em class='brace'>{</em> <a id='L88' name='L88'></a> 88 <a href='../S/2812.html#L676' title='Defined at 676 in src/exec.c.'>exec</a>(); <em class='comment'>/* プログラム実行 */</em> <a id='L89' name='L89'></a> 89 <em class='brace'>}</em> <a id='L90' name='L90'></a> 90 <a href='../S/2856.html#L278' title='Defined at 278 in src/struct.c.'>shutdown</a>(); <em class='comment'>/* COMET II仮想マシンのシャットダウン */</em> <a id='L91' name='L91'></a> 91 <a href='../Y/75.html' title='Multiple used in 5 places.'>comet2fin</a>: <a id='L92' name='L92'></a> 92 <strong class='reserved'>if</strong>(<a href='../Y/32.html' title='Multiple used in 59 places.'>cerr</a>-><a href='../Y/157.html' title='Multiple used in 57 places.'>num</a> > 0) <em class='brace'>{</em> <a id='L93' name='L93'></a> 93 <a href='../Y/197.html' title='Multiple used in 34 places.'>stat</a> = 1; <a id='L94' name='L94'></a> 94 <em class='brace'>}</em> <a id='L95' name='L95'></a> 95 <a href='../S/2845.html#L72' title='Defined at 72 in src/cerr.c.'>freecerr</a>(); <em class='comment'>/* エラーの解放 */</em> <a id='L96' name='L96'></a> 96 <strong class='reserved'>return</strong> <a href='../Y/197.html' title='Multiple used in 34 places.'>stat</a>; <a id='L97' name='L97'></a> 97 <em class='brace'>}</em> </pre> <hr /> <a id='BOTTOM' name='BOTTOM'></a> <em class='comment'>/* [<][>][^]<a href='#L30'>[v]</a><a href='#TOP'>[top]</a>[bottom]<a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</em> </body> </html>