Mercurial > octave
comparison src/pt-fcn.cc @ 2124:97a566037a75
[project @ 1996-05-12 07:16:36 by jwe]
author | jwe |
---|---|
date | Sun, 12 May 1996 07:16:36 +0000 |
parents | 36903d507b0e |
children | bad1dffb5264 |
comparison
equal
deleted
inserted
replaced
2123:ee55d81f585a | 2124:97a566037a75 |
---|---|
39 #include "toplev.h" | 39 #include "toplev.h" |
40 #include "pt-const.h" | 40 #include "pt-const.h" |
41 #include "pt-exp.h" | 41 #include "pt-exp.h" |
42 #include "pt-fcn.h" | 42 #include "pt-fcn.h" |
43 #include "pt-misc.h" | 43 #include "pt-misc.h" |
44 #include "pt-pr-code.h" | |
45 #include "pt-walk.h" | |
44 #include "unwind-prot.h" | 46 #include "unwind-prot.h" |
45 #include "user-prefs.h" | 47 #include "user-prefs.h" |
46 #include "utils.h" | 48 #include "utils.h" |
47 #include "variables.h" | 49 #include "variables.h" |
48 | 50 |
394 fcn_name.c_str (), file_name.c_str ()); | 396 fcn_name.c_str (), file_name.c_str ()); |
395 } | 397 } |
396 } | 398 } |
397 | 399 |
398 void | 400 void |
399 tree_function::print_code (ostream& os) | |
400 { | |
401 print_code_reset (); | |
402 | |
403 print_code_function_header (os); | |
404 | |
405 if (cmd_list) | |
406 { | |
407 increment_indent_level (); | |
408 cmd_list->print_code (os); | |
409 decrement_indent_level (); | |
410 } | |
411 | |
412 print_code_function_trailer (os); | |
413 } | |
414 | |
415 void | |
416 tree_function::print_code_function_header (void) | 401 tree_function::print_code_function_header (void) |
417 { | 402 { |
418 print_code_function_header (octave_stdout); | 403 tree_print_code tpc (octave_stdout); |
419 } | 404 |
420 | 405 tpc.visit_function_header (*this); |
421 void | |
422 tree_function::print_code_function_header (ostream& os) | |
423 { | |
424 print_code_indent (os); | |
425 | |
426 os << "function "; | |
427 | |
428 if (ret_list) | |
429 { | |
430 int len = ret_list->length (); | |
431 | |
432 if (len > 1) | |
433 os << "["; | |
434 | |
435 ret_list->print_code (os); | |
436 | |
437 if (len > 1) | |
438 os << "]"; | |
439 | |
440 os << " = "; | |
441 } | |
442 | |
443 os << (fcn_name.empty () ? string ("(empty)") : fcn_name) << " "; | |
444 | |
445 if (param_list) | |
446 { | |
447 int len = param_list->length (); | |
448 if (len > 0) | |
449 os << "("; | |
450 | |
451 param_list->print_code (os); | |
452 | |
453 if (len > 0) | |
454 { | |
455 os << ")"; | |
456 print_code_new_line (os); | |
457 } | |
458 } | |
459 else | |
460 { | |
461 os << "()"; | |
462 print_code_new_line (os); | |
463 } | |
464 } | 406 } |
465 | 407 |
466 void | 408 void |
467 tree_function::print_code_function_trailer (void) | 409 tree_function::print_code_function_trailer (void) |
468 { | 410 { |
469 print_code_function_trailer (octave_stdout); | 411 tree_print_code tpc (octave_stdout); |
470 } | 412 |
471 | 413 tpc.visit_function_trailer (*this); |
472 void | 414 } |
473 tree_function::print_code_function_trailer (ostream& os) | 415 |
474 { | 416 void |
475 print_code_indent (os); | 417 tree_function::accept (tree_walker& tw) |
476 | 418 { |
477 os << "endfunction"; | 419 tw.visit_function (*this); |
478 | |
479 print_code_new_line (os); | |
480 } | 420 } |
481 | 421 |
482 DEFUN (va_arg, args, , | 422 DEFUN (va_arg, args, , |
483 "va_arg (): return next argument in a function that takes a\n\ | 423 "va_arg (): return next argument in a function that takes a\n\ |
484 variable number of parameters") | 424 variable number of parameters") |