⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trafo.c

📁 linux 下的源代码分析阅读器 red hat公司新版
💻 C
📖 第 1 页 / 共 5 页
字号:
/*Copyright (c) 2000, Red Hat, Inc.This file is part of Source-Navigator.Source-Navigator is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public License as publishedby the Free Software Foundation; either version 2, or (at your option)any later version.Source-Navigator is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public License alongwith Source-Navigator; see the file COPYING.  If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330, Boston,MA 02111-1307, USA.*/#include "Trafo.h"#ifdef __cplusplusextern "C" {#include "General.h"#include "rSystem.h"}#else#include "General.h"#include "rSystem.h"#endif#include <stdio.h>#include "Tree.h"#define yyInline#ifndef NULL#define NULL 0L#endif#ifndef rfalse#define rfalse 0#endif#ifndef rtrue#define rtrue 1#endif#ifdef yyInline#define yyALLOC(tree, free, start, alloc, type, make, ptr, kind, init) \  ptr = (free -= yyAlignedSize (sizeof (type))) >= start ? \   (tree) free : alloc (sizeof (type)); \  init (ptr, kind);#else#define yyALLOC(tree, free, start, alloc, type, make, ptr, kind, init) \  ptr = make (kind);#endif/* line 5 "tcl.puma" */#include "Reuse.h"#include "Position.h"#include "StringM.h"#include "Idents.h"#include "Parser.h"#include "sn.h"#define null	(char *) NULL#define scope_type(cur_class) cur_class ? PAF_MBR_FUNC_DEF : PAF_FUNC_DEFextern	FILE *	cross_ref_fp	;extern	int	report_local_vars;static	char	buffer [1024]	;static	char	args_buffer [1500];static	int	length		;static	rbool	need_pass_2	;static	rbool	in_string	;static	tTree	genv		;static	char *	p		;static	char *	current_ident	;static	char *	current_class	;static	char *	cur_proc_ptr	= NULL;static	char *	cur_class_ptr	= NULL;static	char *	cur_arg_types_ptr = NULL;#ifndef yyWrite#define yyWrite(s) (void) fputs (s, yyf)#endif#ifndef yyWriteNl#define yyWriteNl (void) fputc ('\n', yyf)#endif#include "yyTrafo.h"static void yyExit ARGS ((void)) { rExit (1); }void (* Trafo_Exit) ARGS ((void)) = yyExit;#ifdef UNIXstatic FILE * yyf = stdout;#elsestatic FILE * yyf;#endifstatic void yyAbort#ifdef __cplusplus (char * yyFunction)#else (yyFunction) char * yyFunction;#endif{ (void) fprintf (stderr, "Error: module Trafo, routine %s failed\n",  yyFunction); Trafo_Exit ();}void Interpret_tcl ARGS ((tTree yyP1));static void get_objects ARGS ((tTree s));static void get_param_objects ARGS ((tTree s));static void add_variables ARGS ((tIdent yyP3, tTree yyP2));static void include ARGS ((tTree yyP4));static void add_global_vars ARGS ((tTree w));static void add_variable_vars ARGS ((tTree w, int acc));static void add_variable_vars_2 ARGS ((tTree yyP5));static void add_vars ARGS ((tTree yyP6, int acc));static void add_foreach_vars ARGS ((tTree yyP7));static void add_var ARGS ((tTree w, int acc));static void add_var_2 ARGS ((tIdent i, tPosition pos, tTree w, tTree e, int acc));static tTree IdentifyLocal ARGS ((tIdent i, tTree o));static tTree IdentifyGlobal ARGS ((tIdent yyP8));static tTree Identify ARGS ((tIdent yyP10, tTree yyP9));static tTree IdentifyProcLocal ARGS ((tIdent i, tTree o));static tTree IdentifyProcGlobal ARGS ((tIdent yyP11));static tTree IdentifyProc ARGS ((tIdent yyP13, tTree yyP12));static tTree get_namespace ARGS ((tTree yyP14));static void pass2 ARGS ((tTree t));static void pass3 ARGS ((tTree yyP15));static tIdent make_one_word ARGS ((tTree yyP16));static void make_one_word_2 ARGS ((tTree yyP17));static tTree Mword ARGS ((tTree yyP19, tTree yyP18));static tTree Mqualification ARGS ((tTree yyP20));static tTree Mstmt ARGS ((tTree yyP22, tTree yyP21));static tTree Mstmt_2 ARGS ((tTree yyP25, tIdent yyP24, tTree yyP23));static tTree Mblock_content ARGS ((tPosition yyP28, tPosition yyP27, tTree yyP26));static tTree make_qualification ARGS ((tTree yyP29));static tTree param_names ARGS ((tTree yyP30));static tTree param_names_2 ARGS ((tTree yyP32, tTree yyP31));static tTree param_names_3 ARGS ((tTree yyP34, tTree yyP33));static tTree param_names_4 ARGS ((tTree yyP36, tTree yyP35));static void get_end_pos ARGS ((tTree yyP37, tPosition * yyP38));static void get_begin_pos ARGS ((tTree yyP39, tPosition * yyP40));static tTree get_env ARGS ((tTree yyP41));static tTree get_env_2 ARGS ((tTree yyP42));static tIdent get_ident ARGS ((tTree yyP43));static void add_qualifications ARGS ((tIdent yyP45, tTree yyP44));static void add_variable_quals ARGS ((tTree yyP46, int acc));static void add_variable_quals_2 ARGS ((tTree yyP47));static void add_quals ARGS ((tTree yyP48, int acc));static void add_foreach_quals ARGS ((tTree yyP49));static void add_qual ARGS ((tTree w, int acc));static void add_qual_2 ARGS ((tTree w, int acc));static void use_qual ARGS ((tTree yyP50));static void use_proc_qual ARGS ((tTree yyP51));static void use_proc ARGS ((tTree yyP52));static void use ARGS ((tTree yyP53, tPosition p, int acc));static void use_2 ARGS ((tTree env, tPosition pos, int acc));static void use_undef ARGS ((tIdent ident, tPosition pos));static void use_proc_undef ARGS ((tIdent ident, tPosition pos));static void dcl ARGS ((tTree yyP54));static void dcl_2 ARGS ((tTree env, tPosition pos));static tString current_namespace ARGS ((tTree yyP55));static tString get_class ARGS ((tTree yyP56));static tString get_class_name ARGS ((tTree yyP57));static void to_names ARGS ((tTree yyP59, tString yyP58));static void get_names ARGS ((tTree yyP60));static void get_separator ARGS ((tTree yyP61));static void relocate ARGS ((tTree yyP62, tTree new_env));void Interpret_tcl#if defined __STDC__ | defined __cplusplus(register tTree yyP1)#else(yyP1) register tTree yyP1;#endif{  if (yyP1->Kind == kprogram) {/* line 44 "tcl.puma" */  {/* line 45 "tcl.puma" */   genv = yyP1->program.stmts->stmts.env;/* line 46 "tcl.puma" */   cur_class_ptr = null;/* line 46 "tcl.puma" */   cur_proc_ptr = null;/* line 47 "tcl.puma" */   get_objects (yyP1->program.stmts);/* line 48 "tcl.puma" */  if (need_pass_2) {      cur_class_ptr = null; cur_proc_ptr = null;      pass2 (yyP1->program.stmts);   }/* line 53 "tcl.puma" */   if (! ((cross_ref_fp))) goto yyL1;  {/* line 54 "tcl.puma" */   cur_class_ptr = null;/* line 54 "tcl.puma" */   cur_proc_ptr = null;/* line 55 "tcl.puma" */   pass3 (yyP1->program.stmts);  }  }   return;yyL1:;  };}static void get_objects#if defined __STDC__ | defined __cplusplus(register tTree s)#else(s) register tTree s;#endif{ yyRecursion:  switch (s->Kind) {  case kproc:  if (s->proc.qualification->Kind == klocal_ident) {/* line 62 "tcl.puma" */ {  register tTree yyV1;  tString prev_proc;  {/* line 65 "tcl.puma" */   yyALLOC (tTree,Tree_PoolFreePtr,Tree_PoolStartPtr,    Tree_Alloc,yobject,MakeTree,yyV1,kobject,Tree_InitHead)    yyV1->object.object = s;    yyV1->object.ident = s->proc.qualification->local_ident.ident;    yyV1->object.next = s->proc.env -> env . objects;   s->proc.env -> env . objects = yyV1;/* line 66 "tcl.puma" */   dcl (s->proc.env -> env . objects);/* line 67 "tcl.puma" */   get_objects (s->proc.next);/* line 68 "tcl.puma" *//* line 68 "tcl.puma" */   prev_proc = cur_proc_ptr;/* line 69 "tcl.puma" */   cur_proc_ptr = GetCStr (s->proc.qualification->local_ident.ident);/* line 70 "tcl.puma" */   get_param_objects (s->proc.param_names);/* line 71 "tcl.puma" */   get_objects (s->proc.block);/* line 72 "tcl.puma" */   cur_proc_ptr = prev_proc;  }   return; }  }  if (s->proc.qualification->Kind == kglobal_ident) {/* line 74 "tcl.puma" */ {  register tTree yyV1;  tString prev_proc;  {/* line 77 "tcl.puma" */   yyALLOC (tTree,Tree_PoolFreePtr,Tree_PoolStartPtr,    Tree_Alloc,yobject,MakeTree,yyV1,kobject,Tree_InitHead)    yyV1->object.object = s;    yyV1->object.ident = s->proc.qualification->global_ident.ident;    yyV1->object.next = genv -> env . objects;   genv -> env . objects = yyV1;/* line 78 "tcl.puma" */   dcl (genv -> env . objects);/* line 79 "tcl.puma" */   get_objects (s->proc.next);/* line 80 "tcl.puma" *//* line 80 "tcl.puma" */   prev_proc = cur_proc_ptr;/* line 81 "tcl.puma" */   cur_proc_ptr = GetCStr (s->proc.qualification->global_ident.ident);/* line 82 "tcl.puma" */   get_param_objects (s->proc.param_names);/* line 83 "tcl.puma" */   get_objects (s->proc.block);/* line 84 "tcl.puma" */   cur_proc_ptr = prev_proc;  }   return; }  }  if (s->proc.qualification->Kind == klocal_text) {/* line 86 "tcl.puma" */ {  tString prev_proc;  {/* line 90 "tcl.puma" */   get_objects (s->proc.next);/* line 91 "tcl.puma" *//* line 91 "tcl.puma" */   prev_proc = cur_proc_ptr;/* line 92 "tcl.puma" */   cur_proc_ptr = GetCStr (get_ident (s->proc.qualification));/* line 93 "tcl.puma" */   get_param_objects (s->proc.param_names);/* line 94 "tcl.puma" */   get_objects (s->proc.block);/* line 95 "tcl.puma" */   cur_proc_ptr = prev_proc;  }   return; }  }  if (s->proc.qualification->Kind == kglobal_text) {/* line 86 "tcl.puma" */ {  tString prev_proc;  {/* line 90 "tcl.puma" */   get_objects (s->proc.next);/* line 91 "tcl.puma" *//* line 91 "tcl.puma" */   prev_proc = cur_proc_ptr;/* line 92 "tcl.puma" */   cur_proc_ptr = GetCStr (get_ident (s->proc.qualification));/* line 93 "tcl.puma" */   get_param_objects (s->proc.param_names);/* line 94 "tcl.puma" */   get_objects (s->proc.block);/* line 95 "tcl.puma" */   cur_proc_ptr = prev_proc;  }   return; }  }/* line 97 "tcl.puma" */  {/* line 99 "tcl.puma" */   need_pass_2 = rtrue;/* line 100 "tcl.puma" */   s = s->proc.next;   goto yyRecursion;  }  case knamespace:  if (s->namespace.qualification->Kind == klocal_ident) {/* line 102 "tcl.puma" */ {  tTree obj;  tString prev_class;  {/* line 104 "tcl.puma" *//* line 104 "tcl.puma" */   obj = IdentifyLocal (s->namespace.qualification->local_ident.ident, s->namespace.env -> env . objects);/* line 105 "tcl.puma" */  if (obj != NoTree && obj->object.object->Kind == knamespace) {      relocate (s->namespace.block, obj->object.object->namespace.block->texts.env);      use (obj, s->namespace.qualification->local_ident.pos, PAF_REF_READ);   } else {      s->namespace.env->env.objects = mobject (s, s->namespace.qualification->local_ident.ident, s->namespace.env->env.objects);      dcl (s->namespace.env->env.objects);   }/* line 113 "tcl.puma" */   get_objects (s->namespace.next);/* line 114 "tcl.puma" *//* line 114 "tcl.puma" */   prev_class = cur_class_ptr;/* line 115 "tcl.puma" */   cur_class_ptr = GetCStr (s->namespace.qualification->local_ident.ident);/* line 116 "tcl.puma" */   get_objects (s->namespace.block);/* line 117 "tcl.puma" */   cur_class_ptr = prev_class;  }   return; }  }  if (s->namespace.qualification->Kind == kglobal_ident) {/* line 119 "tcl.puma" */ {  tTree obj;  tString prev_class;  {/* line 121 "tcl.puma" *//* line 121 "tcl.puma" */   obj = IdentifyGlobal (s->namespace.qualification->global_ident.ident);/* line 122 "tcl.puma" */  if (obj != NoTree && obj->object.object->Kind == knamespace) {      relocate (s->namespace.block, obj->object.object->namespace.block->texts.env);      use (obj, s->namespace.qualification->global_ident.pos, PAF_REF_READ);   } else {      genv->env.objects = mobject (s, s->namespace.qualification->global_ident.ident, genv->env.objects);      dcl (genv->env.objects);   }/* line 130 "tcl.puma" */   get_objects (s->namespace.next);/* line 131 "tcl.puma" *//* line 131 "tcl.puma" */   prev_class = cur_class_ptr;/* line 132 "tcl.puma" */   cur_class_ptr = GetCStr (s->namespace.qualification->global_ident.ident);/* line 133 "tcl.puma" */   get_objects (s->namespace.block);/* line 134 "tcl.puma" */   cur_class_ptr = prev_class;  }   return; }  }  if (s->namespace.qualification->Kind == klocal_text) {/* line 136 "tcl.puma" */ {  tString prev_class;  {/* line 138 "tcl.puma" */   get_objects (s->namespace.next);/* line 139 "tcl.puma" *//* line 139 "tcl.puma" */   prev_class = cur_class_ptr;/* line 140 "tcl.puma" */   cur_class_ptr = GetCStr (get_ident (s->namespace.qualification));/* line 141 "tcl.puma" */   get_objects (s->namespace.block);/* line 142 "tcl.puma" */   cur_class_ptr = prev_class;  }   return; }  }  if (s->namespace.qualification->Kind == kglobal_text) {/* line 136 "tcl.puma" */ {  tString prev_class;  {/* line 138 "tcl.puma" */   get_objects (s->namespace.next);/* line 139 "tcl.puma" *//* line 139 "tcl.puma" */   prev_class = cur_class_ptr;/* line 140 "tcl.puma" */   cur_class_ptr = GetCStr (get_ident (s->namespace.qualification));/* line 141 "tcl.puma" */   get_objects (s->namespace.block);/* line 142 "tcl.puma" */   cur_class_ptr = prev_class;  }   return; }  }/* line 144 "tcl.puma" */  {/* line 145 "tcl.puma" */   need_pass_2 = rtrue;/* line 146 "tcl.puma" */   s = s->namespace.next;   goto yyRecursion;  }  case kstmt:  if (s->stmt.words->Kind == kone_word) {  if (Tree_IsType (s->stmt.words->one_word.next, kword_c)) {/* line 148 "tcl.puma" */  {/* line 150 "tcl.puma" */   add_variables (s->stmt.words->one_word.ident, s->stmt.words->one_word.next);/* line 151 "tcl.puma" */   get_objects (s->stmt.words);/* line 152 "tcl.puma" */   s = s->stmt.next;   goto yyRecursion;  }  }  }/* line 154 "tcl.puma" */  {/* line 155 "tcl.puma" */   get_objects (s->stmt.words);/* line 156 "tcl.puma" */   s = s->stmt.next;   goto yyRecursion;  }  case kblock:/* line 158 "tcl.puma" */  {/* line 159 "tcl.puma" */   get_objects (s->block.stmts);/* line 160 "tcl.puma" */   s = s->block.next;   goto yyRecursion;  }  case kcontent:/* line 162 "tcl.puma" */  {/* line 163 "tcl.puma" */   get_objects (s->content.qualification);/* line 164 "tcl.puma" */   s = s->content.next;   goto yyRecursion;  }  case kblock_content:/* line 166 "tcl.puma" */  {/* line 167 "tcl.puma" */   get_objects (s->block_content.stmts);/* line 168 "tcl.puma" */   s = s->block_content.next;   goto yyRecursion;  }  case ktext:  case kcharacter:  case kident:/* line 170 "tcl.puma" */  {/* line 171 "tcl.puma" */   s = s->text.next;   goto yyRecursion;  }  case kone_word:/* line 173 "tcl.puma" */  {/* line 174 "tcl.puma" */   s = s->one_word.next;   goto yyRecursion;  }  case kqual_word:/* line 176 "tcl.puma" */  {/* line 177 "tcl.puma" */   get_objects (s->qual_word.qualification);/* line 178 "tcl.puma" */   s = s->qual_word.next;   goto yyRecursion;  }  case kqual_words:/* line 180 "tcl.puma" */  {/* line 181 "tcl.puma" */   get_objects (s->qual_words.qualifications);/* line 182 "tcl.puma" */   s = s->qual_words.next;   goto yyRecursion;  }  case kone_qualification:/* line 184 "tcl.puma" */  {/* line 185 "tcl.puma" */   get_objects (s->one_qualification.qualification);/* line 186 "tcl.puma" */   s = s->one_qualification.next;   goto yyRecursion;  }  case klocal_text:/* line 188 "tcl.puma" */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -