From 86cd906371d8c84f1c754dbafbe5906ddf5db504 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 2 Jul 2014 23:17:30 -0700 Subject: [PATCH] Remove typeinfo_t::type. --- sourcepawn/compiler/sc.h | 3 +-- sourcepawn/compiler/sc1.c | 17 ++++++----------- sourcepawn/compiler/sc3.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h index 9fbd97b6..a8682e6e 100644 --- a/sourcepawn/compiler/sc.h +++ b/sourcepawn/compiler/sc.h @@ -267,8 +267,6 @@ typedef struct svalue_s { #define TYPEMASK_NAMED_DECL (TYPEFLAG_ARGUMENT | TYPEFLAG_VARIABLE) typedef struct { - char type[sNAMEMAX + 1]; - // Array information. int numdim; int dim[sDIMEN_MAX]; @@ -540,6 +538,7 @@ constvalue *pc_tagptr(const char *name); int pc_enablewarning(int number,int enable); const char *pc_tagname(int tag); int parse_decl(declinfo_t *decl, int flags); +const char *type_to_name(int tag); /* * Functions called from the compiler (to be implemented by you) diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index 33c6a1c1..bc6dcfff 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -1262,7 +1262,7 @@ static void setconfig(char *root) static void setcaption(void) { pc_printf("SourcePawn Compiler %s\n", SOURCEMOD_VERSION); - pc_printf("Copyright (c) 1997-2006, ITB CompuPhase, (C)2004-2008 AlliedModders, LLC\n\n"); + pc_printf("Copyright (c) 1997-2006, ITB CompuPhase, (C)2004-2014 AlliedModders, LLC\n\n"); } static void about(void) @@ -3281,27 +3281,22 @@ static int parse_new_typeexpr(typeinfo_t *type, const token_t *first, int flags) switch (tok.id) { case tINT: - strcpy(type->type, "int"); type->tag = 0; break; case tCHAR: - strcpy(type->type, "char"); type->tag = pc_tag_string; break; case tVOID: - strcpy(type->type, "void"); type->tag = pc_tag_void; break; case tOBJECT: - strcpy(type->type, "object"); type->tag = pc_tag_object; break; case tSYMBOL: - strcpy(type->type, tok.str); - if (strcmp(type->type, "float") == 0) { + if (strcmp(tok.str, "float") == 0) { type->tag = sc_rationaltag; } else { - type->tag = pc_findtag(type->type); + type->tag = pc_findtag(tok.str); if (type->tag == sc_rationaltag) { error(98, "Float", "float"); } else if (type->tag == pc_tag_string) { @@ -3309,13 +3304,13 @@ static int parse_new_typeexpr(typeinfo_t *type, const token_t *first, int flags) } else if (type->tag == 0) { error(98, "_", "int"); } else if (type->tag == -1) { - error(139, type->type); + error(139, tok.str); type->tag = 0; } else { // Perform some basic filters so we can start narrowing down what can // be used as a type. if (!(type->tag & TAGTYPEMASK)) - error(139, type->type); + error(139, tok.str); } } break; @@ -3763,7 +3758,7 @@ int parse_property_accessor(const typeinfo_t *type, methodmap_t *map, methodmap_ // Must return the same tag as the property. if (type->tag != target->tag) { const char *kind = getter ? "getter" : "setter"; - error(128, "getter", map->name, type->type); + error(128, "getter", map->name, type_to_name(type->tag)); } if (!check_this_tag(map, target)) { diff --git a/sourcepawn/compiler/sc3.c b/sourcepawn/compiler/sc3.c index 39907863..152ef3ef 100644 --- a/sourcepawn/compiler/sc3.c +++ b/sourcepawn/compiler/sc3.c @@ -314,6 +314,24 @@ SC_FUNC int checktag_string(value *sym1, value *sym2) return FALSE; } +SC_FUNC const char *type_to_name(int tag) +{ + if (tag == 0) + return "int"; + if (tag == sc_rationaltag) + return "float"; + if (tag == pc_tag_string) + return "char"; + + const char *name = pc_tagname(tag); + if (name) + return NULL; + + if (tag & FUNCTAG) + return "function"; + return "unknown"; +} + SC_FUNC int matchtag_string(int ident, int tag) { if (ident == iARRAY || ident == iREFARRAY)