📄 symbol2.c
字号:
/*symbol2.cSymbol table handling, type graph handling, and code generation.gSOAP XML Web services toolsCopyright (C) 2000-2006, Robert van Engelen, Genivia Inc. All Rights Reserved.This part of the software is released under one of the following licenses:GPL, the gSOAP public license, or Genivia's license for commercial use.--------------------------------------------------------------------------------gSOAP public license.The contents of this file are subject to the gSOAP Public License Version 1.3(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/soaplicense.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 Initial Developer of the Original Code is Robert A. van Engelen.Copyright (C) 2000-2006, Robert van Engelen, Genivia Inc. All Rights Reserved.--------------------------------------------------------------------------------GPL license.This program is free software; you can redistribute it and/or modify it underthe terms of the GNU General Public License as published by the Free SoftwareFoundation; either version 2 of the License, or (at your option) any laterversion.This program is distributed in the hope that it will be useful, but WITHOUT ANYWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR APARTICULAR PURPOSE. See the GNU General Public License for more details.You should have received a copy of the GNU General Public License along withthis program; if not, write to the Free Software Foundation, Inc., 59 TemplePlace, Suite 330, Boston, MA 02111-1307 USAAuthor contact information:engelen@genivia.com / engelen@acm.org--------------------------------------------------------------------------------A commercial use license is available from Genivia, Inc., contact@genivia.com--------------------------------------------------------------------------------*/#include "soapcpp2.h"#include "soapcpp2_yacc.h"char *envURI = "http://schemas.xmlsoap.org/soap/envelope/";char *encURI = "http://schemas.xmlsoap.org/soap/encoding/";char *rpcURI = "http://www.w3.org/2003/05/soap-rpc";char *xsiURI = "http://www.w3.org/2001/XMLSchema-instance";char *xsdURI = "http://www.w3.org/2001/XMLSchema";char *tmpURI = "http://tempuri.org";static 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, *flib, *fmatlab, *fmheader;int typeNO = 1; /* unique no. assigned to all types */static int is_anytype_flag = 0; /* anytype is used *//*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; p = p->next) if (!strcmp(p->name, name)) return p; return NULL;}/*gensymidx - generate new symbol from base name and index*/Symbol *gensymidx(const char *base, int idx){ char buf[1024]; Symbol *s; sprintf(buf, "%s_%d", base, idx); s = lookup(buf); if (s) return s; return install(buf, ID);}/*gensym - generate new symbol from base name*/Symbol *gensym(const char *base){ static int num = 1; return gensymidx(base, num++);}/*mktable - make a new symbol table with 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 = NULL; for (p = table->list; p; q = p, p = p->next) if (p->sym == sym && p->info.typ->type != Tfun) { sprintf(errbuf, "Duplicate declaration of %s (already declarared at line %d)", sym->name, p->lineno); semerror(errbuf); return p; } p = (Entry*)emalloc(sizeof(Entry)); p->sym = sym; p->info.typ = NULL; 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 = NULL; if (!q) 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; t = t->prev) for (p = t->list; p; p = p->next) if (p->sym == sym) return p; return NULL;}/*reenter - re-enter a symbol in a table.*/Entry *reenter(table, sym)Table *table;Symbol *sym;{ Entry *p, *q = NULL; for (p = table->list; p; q = p, p = p->next) if (p->sym == sym) break; if (p && p->next) { if (q) q->next = p->next; else table->list = p->next; for (q = p->next; q->next; q = q->next) ; q->next = p; p->next = NULL; } return p;}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 *get_mxClassID(Tnode*);char *t_ident(Tnode*);char *c_ident(Tnode*);char *soap_type(Tnode*);char *c_storage(Storage);char *c_init(Entry*);char *c_type(Tnode*);char *c_type_id(Tnode*, char*);char *xsi_type_cond(Tnode*, int);char *xsi_type(Tnode*);char *xsi_type_cond_u(Tnode*, int);char *xsi_type_u(Tnode*);char *the_type(Tnode*);char *wsdl_type(Tnode*, char*);char *base_type(Tnode*, char*);char *xml_tag(Tnode*);char *ns_qualifiedElement(Tnode*);char *ns_qualifiedAttribute(Tnode*);char *ns_convert(char*);char *ns_add(char*, char*);char *ns_remove(char*);char *ns_remove1(char*);char *ns_remove2(char*);char *res_remove(char*);char *ns_name(char*);char *ns_cname(char*, char*);int has_class(Tnode*);int has_constructor(Tnode*);int has_destructor(Tnode*);int has_getter(Tnode*);int has_setter(Tnode*);int has_ns(Tnode*);int has_ns_t(Tnode*);int has_ns_eq(char*, char*);char *strict_check();char *ns_of(char*);char *prefix_of(char*);int has_offset(Tnode*);int reflevel(Tnode *typ);Tnode* reftype(Tnode *typ);int is_response(Tnode*);Entry *get_response(Tnode*);int is_primitive_or_string(Tnode*);int is_primitive(Tnode*);Entry *is_discriminant(Tnode*);Entry *is_dynamic_array(Tnode*);int is_transient(Tnode*);int is_external(Tnode*);int is_binary(Tnode*);int is_hexBinary(Tnode*);int is_string(Tnode*);int is_wstring(Tnode*);int is_stdstring(Tnode*);int is_stdwstring(Tnode*);int is_stdstr(Tnode*);int is_typedef(Tnode*);int get_dimension(Tnode*);char *has_soapref(Tnode*);int is_document(const char*);int is_literal(const char*);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -