?? symbol2.c
字號:
/* symbol2.c Module for symbol table handling and code generationThe contents of this file are subject to the Mozilla Public License Version 1.1(the "License"); you may not use this file except in compliance with theLicense. You may obtain a copy of the License athttp://www.cs.fsu.edu/~engelen/gsoapcompilerlicense.htmlSoftware distributed under the License is distributed on an "AS IS" basis,WITHOUT WARRANTY OF ANY KIND, either express or implied. See the Licensefor the specific language governing rights and limitations under the License.The Original Code is ''gSOAP compiler'' consisting of:error2.c, error2.h, init2.c, soapcpp2.c, soapcpp2.h, soapcpp2.l, soapcpp2.y, symbol2.c.The Initial Developer of the Original Code is Robert A. van Engelen.Copyright (C) 2000-2002 Robert A. van Engelen. All Rights Reserved.*/#include "soapcpp2.h"/* Use of Bison requires the inclusion of soapcpp2.tab.h instead of y.tab.h: */#ifdef WITH_BISON#include "soapcpp2.tab.h"#else#include "y.tab.h"#endifstatic Symbol *symlist = (Symbol*) 0; /* pointer to linked list of symbols */static Symbol *nslist = (Symbol*) 0; /* pointer to linked list of namespace prefix symbols */static Tnode *Tptr[TYPES];Service *services = NULL;FILE *fout, *fhead, *fclient, *fserver, *fheader;static int typeNO = 0; /* unique no. assigned to all types *//*install - add new symbol*/Symbol *install(const char *name, Token token){ Symbol *p; p = (Symbol*)emalloc(sizeof(Symbol)); p->name = emalloc(strlen(name)+1); strcpy(p->name, name); p->token = token; p->next = symlist; symlist = p; return p;}/*lookup - search for an identifier's name. If found, return pointer to symbol table entry. Return pointer 0 if not found.*/Symbol *lookup(const char *name){ Symbol *p; for (p = symlist; p != (Symbol*) 0; p = p->next) if (strcmp(p->name, name) == 0) return p; return (Symbol*)0;}/*gensym - generate new symbol from base name*/Symbol *gensym(const char *base){ static int num = 1; int i; char *b, buf[512]; strcpy(buf, base); b = buf+strlen(base); for (i = 0; i < num; i++); *b++ = '_'; *b = '\0'; num++; return install(buf, ID);}/*mktable - make a new symbol table incorporating a pointer to a previous table*/Table*mktable(Table *table){ Table *p; p = (Table*)emalloc(sizeof(Table)); p->sym = lookup("/**/"); p->list = (Entry*) 0; if (table == (Table*) 0) p->level = INTERNAL; else p->level = table->level+1; p->prev = table; return p;}/*mkmethod - make a new method by calling mktype*/Tnode*mkmethod(Tnode *ret, Table *args){ FNinfo *fn = (FNinfo*)emalloc(sizeof(FNinfo)); fn->ret = ret; fn->args = args; return mktype(Tfun, fn, 0);}/*freetable - free space by removing a table*/voidfreetable(Table *table){ Entry *p, *q; if (table == (Table*) 0) return; for (p = table->list; p != (Entry*) 0; p = q) { q = p->next; free(p); } free(table);}/*unlinklast - unlink last entry added to table*/Entry *unlinklast(Table *table){ Entry **p, *q; if (table == (Table*)0) return (Entry*)0; for (p = &table->list; *p != (Entry*)0 && (*p)->next != (Entry*)0; p = &(*p)->next); q = *p; *p = (Entry*)0; return q;}/*enter - enter a symbol in a table. Error if already in the table*/Entry *enter(table, sym)Table *table;Symbol *sym;{ Entry *p, *q = (Entry*) 0; for (p = table->list; p != (Entry*) 0; q = p, p = p->next) if (p->sym == sym && p->info.typ->type != Tfun) { sprintf(errbuf, "Duplicate declaration for %s (line %d)", sym->name, p->lineno); semerror(errbuf); return p; } p = (Entry*) emalloc(sizeof(Entry)); p->sym = sym; p->info.typ = (Tnode*)0; p->info.sto = Snone; p->info.hasval = False; p->info.minOccurs = 1; p->info.maxOccurs = 1; p->info.offset = 0; p->level = table->level; p->lineno = yylineno; p->next = (Entry*) 0; if (q == (Entry*) 0) table->list = p; else q->next = p; return p;}/*entry - return pointer to table entry of a symbol*/Entry *entry(table, sym)Table *table;Symbol *sym;{ Table *t; Entry *p; for (t = table; t != (Table *) 0; t = t->prev) for (p = t->list; p != (Entry *) 0; p = p->next) if (p->sym == sym) return p; return (Entry *) 0;}Entry *enumentry(Symbol *sym){ Table *t; Entry *p, *q; for (t = enumtable; t; t = t->prev) for (p = t->list; p; p = p->next) if (q = entry(p->info.typ->ref, sym)) return q; return NULL;}char *c_ident(Tnode*);char *c_storage(Storage);char *c_init(Entry*);char *c_type(Tnode*);char *c_type_id(Tnode*, char*);char *xsi_type(Tnode*);char *the_type(Tnode*);char *wsdl_type(Tnode*, char*);char *xml_tag(Tnode*);char *ns_convert(char*);char *ns_remove(char*);char *ns_overridden(Table*, Entry*);int has_ns(Tnode*);int has_ns_eq(char*, char*);int has_offset(Tnode*);int is_response(Tnode*);Entry *get_response(Tnode*);int is_primitive(Tnode*);Entry *is_dynamic_array(Tnode*);int is_binary(Tnode*);int is_hexBinary(Tnode*);int is_string(Tnode*);int is_wstring(Tnode*);int get_dimension(Tnode*);char *has_soapref(Tnode*);char *xsi_type_Tarray(Tnode*); char *xsi_type_Darray(Tnode*); void xml_def_table(Table *,Tnode *);void xml_out_generate(Tnode *);int no_of_var(Tnode*);char *pointer_stuff(Tnode*);void xml_def_pointer(Tnode*,Tnode*);void in_defs(Table*);void in_defs2(Table*);void out_defs(Table*);void in_attach(Table*);void out_attach(Table*);void serialize(Tnode*);void mark(Tnode*);void defaults(Tnode*);void soap_put(Tnode*);void soap_out(Tnode*);void soap_out_Darray(Tnode *);void soap_get(Tnode*);void soap_in(Tnode*); void soap_in_Darray(Tnode *);void soap_instan_class(Tnode *);int get_Darraydims(Tnode *typ);void function_input_output(Table*);void generate_proto(Table*, Entry*);void generate_call(Table*, Entry*);void generate_server(Table*, Entry*);void generate_header(Table*);void generate_schema(Table*);void gen_schema(FILE*,Table*,char*,char*,int,int,char*);void gen_wsdl(FILE*,Table*,char*,char*,char*,char*,char*,char*);/*mktype - make a (new) type with a reference to additional information and thewidth in bytes required to store objects of that type. A pointer to thetype is returned which can be compared to check if types are identical.*/Tnode *mktype(Type type, void *ref, int width){ Tnode *p; if (type != Tstruct && type != Tclass) for (p = Tptr[type]; p != (Tnode*) 0; p = p->next) if (p->ref == ref && p->sym == (Symbol*) 0 && p->width == width && p->transient == transient) return p; /* type alrady exists in table */ p = (Tnode*)emalloc(sizeof(Tnode)); /* install new type */ p->type = type; p->ref = ref; p->id = lookup("/**/"); p->sym = (Symbol*)0; p->response = (Entry*)0; p->width = width; p->generated = False; p->wsdl = False; p->next = Tptr[type]; p->transient = transient; Tptr[type] = p; return p;}Tnode *mksymtype(Tnode *typ, Symbol *sym){ Tnode *p; p = (Tnode*)emalloc(sizeof(Tnode)); /* install new type */ p->type = typ->type; p->ref = typ->ref; p->id = typ->id; p->sym = sym; p->width = typ->width; p->generated = False; p->wsdl = False; p->next = Tptr[typ->type]; p->transient = transient; Tptr[typ->type] = p; return p;}/* DO NOT REMOVE OR ALTER (SEE LICENCE AGREEMENT AND COPYING.txt) */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -