# HG changeset patch # User Mario de Sousa # Date 1351255936 -3600 # Node ID ec8df1de3e08fc4d4c52c0227297e2717c954123 # Parent bb4511694c0ef63d9be6c9a3baa51fb7e9192680 Remove deprecated class search_constant_type_c diff -r bb4511694c0e -r ec8df1de3e08 absyntax_utils/Makefile.am --- a/absyntax_utils/Makefile.am Fri Oct 26 13:48:16 2012 +0100 +++ b/absyntax_utils/Makefile.am Fri Oct 26 13:52:16 2012 +0100 @@ -15,7 +15,6 @@ get_var_name.cc \ search_il_label.cc \ search_base_type.cc \ - search_constant_type.cc \ search_fb_instance_decl.cc \ search_fb_typedecl.cc \ search_varfb_instance_type.cc \ diff -r bb4511694c0e -r ec8df1de3e08 absyntax_utils/Makefile.in --- a/absyntax_utils/Makefile.in Fri Oct 26 13:48:16 2012 +0100 +++ b/absyntax_utils/Makefile.in Fri Oct 26 13:52:16 2012 +0100 @@ -86,7 +86,6 @@ function_param_iterator.$(OBJEXT) \ get_sizeof_datatype.$(OBJEXT) get_var_name.$(OBJEXT) \ search_il_label.$(OBJEXT) search_base_type.$(OBJEXT) \ - search_constant_type.$(OBJEXT) \ search_fb_instance_decl.$(OBJEXT) search_fb_typedecl.$(OBJEXT) \ search_varfb_instance_type.$(OBJEXT) \ search_var_instance_decl.$(OBJEXT) \ @@ -224,7 +223,6 @@ get_var_name.cc \ search_il_label.cc \ search_base_type.cc \ - search_constant_type.cc \ search_fb_instance_decl.cc \ search_fb_typedecl.cc \ search_varfb_instance_type.cc \ @@ -328,7 +326,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_sizeof_datatype.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_var_name.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/search_base_type.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/search_constant_type.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/search_fb_instance_decl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/search_fb_typedecl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/search_il_label.Po@am__quote@ diff -r bb4511694c0e -r ec8df1de3e08 absyntax_utils/absyntax_utils.hh --- a/absyntax_utils/absyntax_utils.hh Fri Oct 26 13:48:16 2012 +0100 +++ b/absyntax_utils/absyntax_utils.hh Fri Oct 26 13:52:16 2012 +0100 @@ -111,7 +111,6 @@ #include "search_var_instance_decl.hh" #include "decompose_var_instance_name.hh" #include "search_varfb_instance_type.hh" -#include "search_constant_type.hh" #include "add_en_eno_param_decl.hh" #include "get_sizeof_datatype.hh" #include "search_il_label.hh" diff -r bb4511694c0e -r ec8df1de3e08 absyntax_utils/search_constant_type.cc --- a/absyntax_utils/search_constant_type.cc Fri Oct 26 13:48:16 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,180 +0,0 @@ -/* - * matiec - a compiler for the programming languages defined in IEC 61131-3 - * - * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) - * Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * - * This code is made available on the understanding that it will not be - * used in safety-critical situations without a full and competent review. - */ - -/* - * An IEC 61131-3 compiler. - * - * Based on the - * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) - * - */ - -/* Determine the data type of a specific constant or variable. - * A reference to the relevant type definition is returned. - * - * For example: - * 22 -> returns reference to a int_type_name_c object. - * 22.2 -> returns reference to a real_type_name_c object. - * LREAL#22.2 -> returns reference to a lreal_type_name_c object. - * etc... - */ - - -#include "../util/symtable.hh" -#include "search_constant_type.hh" -#include "absyntax_utils.hh" -#include "../main.hh" // required for ERROR() and ERROR_MSG() macros. - - - -symbol_c *search_constant_type_c::get_type(symbol_c *constant) { - return (symbol_c *)constant->accept(*this); -} - - -/*********************/ -/* B 1.2 - Constants */ -/*********************/ - -/******************************/ -/* B 1.2.1 - Numeric Literals */ -/******************************/ -/* Numeric literals without any explicit type cast have unknown data type, - * so we continue considering them as their own basic data types until - * they can be resolved (for example, when using '30+x' where 'x' is a LINT variable, the - * numeric literal '30' must then be considered a LINT so the ADD function may be called - * with all inputs of the same data type. - * If 'x' were a SINT, then the '30' would have to be a SINT too! - */ -void *search_constant_type_c::visit(real_c *symbol) {return (void *)symbol;} -void *search_constant_type_c::visit(neg_real_c *symbol) {return (void *)symbol;} -void *search_constant_type_c::visit(integer_c *symbol) {return (void *)symbol;} -void *search_constant_type_c::visit(neg_integer_c *symbol) {return (void *)symbol;} -void *search_constant_type_c::visit(binary_integer_c *symbol) {return (void *)symbol;} -void *search_constant_type_c::visit(octal_integer_c *symbol) {return (void *)symbol;} -void *search_constant_type_c::visit(hex_integer_c *symbol) {return (void *)symbol;} - -void *search_constant_type_c::visit(integer_literal_c *symbol) - {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));} -void *search_constant_type_c::visit(real_literal_c *symbol) - {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));} -void *search_constant_type_c::visit(bit_string_literal_c *symbol) - {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));} -void *search_constant_type_c::visit(boolean_literal_c *symbol) - {return (void *)((symbol->type!=NULL)?symbol->type:symbol->value->accept(*this));} - -void *search_constant_type_c::visit(boolean_true_c *symbol) {return (void *)symbol;} -void *search_constant_type_c::visit(boolean_false_c *symbol) {return (void *)symbol;} - - -/*******************************/ -/* B.1.2.2 Character Strings */ -/*******************************/ -void *search_constant_type_c::visit(double_byte_character_string_c *symbol) {return (void *)&wstring_type_name;} -void *search_constant_type_c::visit(single_byte_character_string_c *symbol) {return (void *)&string_type_name;} - -/***************************/ -/* B 1.2.3 - Time Literals */ -/***************************/ -/************************/ -/* B 1.2.3.1 - Duration */ -/************************/ -void *search_constant_type_c::visit(neg_time_c *symbol) {ERROR; return NULL;} /* this member function should never be called. */ -void *search_constant_type_c::visit(duration_c *symbol) {return (void *)(symbol->type_name);} -void *search_constant_type_c::visit(fixed_point_c *symbol) {ERROR; return NULL;} /* this member function should never be called. */ -void *search_constant_type_c::visit(interval_c *symbol) {ERROR; return NULL;} /* this member function should never be called. */ - -/************************************/ -/* B 1.2.3.2 - Time of day and Date */ -/************************************/ -void *search_constant_type_c::visit(time_of_day_c *symbol) {return (void *)(symbol->type_name);} -void *search_constant_type_c::visit(daytime_c *symbol) {ERROR; return NULL;} /* this member function should never be called. */ -void *search_constant_type_c::visit(date_c *symbol) {return (void *)(symbol->type_name);} -void *search_constant_type_c::visit(date_literal_c *symbol) {ERROR; return NULL;} /* this member function should never be called. */ -void *search_constant_type_c::visit(date_and_time_c *symbol) {return (void *)(symbol->type_name);} - -/********************************/ -/* B 1.3.3 - Derived data types */ -/********************************/ -void *search_constant_type_c::visit(enumerated_value_c *symbol) { - if (symbol->type != NULL) - return (void *)(symbol->type); - - symbol_c *value_type = enumerated_value_symtable.find_value(symbol->value); - if (value_type == enumerated_value_symtable.end_value()) - return NULL; - return (void *)value_type; -} - - - - -invalid_type_name_c search_constant_type_c::invalid_type_name; - - -real_type_name_c search_constant_type_c::real_type_name; -sint_type_name_c search_constant_type_c::sint_type_name; -lint_type_name_c search_constant_type_c::lint_type_name; -dint_type_name_c search_constant_type_c::dint_type_name; -date_type_name_c search_constant_type_c::date_type_name; -dword_type_name_c search_constant_type_c::dword_type_name; -dt_type_name_c search_constant_type_c::dt_type_name; -tod_type_name_c search_constant_type_c::tod_type_name; -udint_type_name_c search_constant_type_c::udint_type_name; -word_type_name_c search_constant_type_c::word_type_name; -wstring_type_name_c search_constant_type_c::wstring_type_name; -string_type_name_c search_constant_type_c::string_type_name; -lword_type_name_c search_constant_type_c::lword_type_name; -uint_type_name_c search_constant_type_c::uint_type_name; -lreal_type_name_c search_constant_type_c::lreal_type_name; -byte_type_name_c search_constant_type_c::byte_type_name; -usint_type_name_c search_constant_type_c::usint_type_name; -ulint_type_name_c search_constant_type_c::ulint_type_name; -bool_type_name_c search_constant_type_c::bool_type_name; -time_type_name_c search_constant_type_c::time_type_name; -int_type_name_c search_constant_type_c::int_type_name; - -safetime_type_name_c search_constant_type_c::safetime_type_name; -safetod_type_name_c search_constant_type_c::safetod_type_name; -safedt_type_name_c search_constant_type_c::safedt_type_name; -safedate_type_name_c search_constant_type_c::safedate_type_name; -safereal_type_name_c search_constant_type_c::safereal_type_name; -safesint_type_name_c search_constant_type_c::safesint_type_name; -safelint_type_name_c search_constant_type_c::safelint_type_name; -safedint_type_name_c search_constant_type_c::safedint_type_name; -safedword_type_name_c search_constant_type_c::safedword_type_name; -safeudint_type_name_c search_constant_type_c::safeudint_type_name; -safeword_type_name_c search_constant_type_c::safeword_type_name; -safewstring_type_name_c search_constant_type_c::safewstring_type_name; -safestring_type_name_c search_constant_type_c::safestring_type_name; -safelword_type_name_c search_constant_type_c::safelword_type_name; -safeuint_type_name_c search_constant_type_c::safeuint_type_name; -safelreal_type_name_c search_constant_type_c::safelreal_type_name; -safebyte_type_name_c search_constant_type_c::safebyte_type_name; -safeusint_type_name_c search_constant_type_c::safeusint_type_name; -safeulint_type_name_c search_constant_type_c::safeulint_type_name; -safebool_type_name_c search_constant_type_c::safebool_type_name; -safeint_type_name_c search_constant_type_c::safeint_type_name; - - diff -r bb4511694c0e -r ec8df1de3e08 absyntax_utils/search_constant_type.hh --- a/absyntax_utils/search_constant_type.hh Fri Oct 26 13:48:16 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,188 +0,0 @@ -/* - * matiec - a compiler for the programming languages defined in IEC 61131-3 - * - * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) - * Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * - * This code is made available on the understanding that it will not be - * used in safety-critical situations without a full and competent review. - */ - -/* - * An IEC 61131-3 compiler. - * - * Based on the - * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) - * - */ - -/* NOTE: The use of this visitor class is now deprecated. - * The new version of stage3 data type checking adds an entry to - * every relevant object in the abstract syntax tree defining - * the data type of that object. Please use that instead! - */ - - - -/* Determine the data type of a specific constant or variable. - * A reference to the relevant type definition is returned. - * - * For example: - * 22 -> returns reference to a int_type_name_c object. - * 22.2 -> returns reference to a real_type_name_c object. - * LREAL#22.2 -> returns reference to a lreal_type_name_c object. - * etc... - */ - - -#include "../absyntax/visitor.hh" - -#ifndef _SEARCH_CONSTANT_TYPE_HH -#define _SEARCH_CONSTANT_TYPE_HH - -class search_constant_type_c: public search_visitor_c { - - public: - /* object used to identify an entry in the abstract syntax tree with an invalid data type */ - /* This is only used from stage3 onwards. Stages 1 and 2 will never create any instances of invalid_type_name_c */ - static invalid_type_name_c invalid_type_name; - - /**********************/ - /* B.1.3 - Data types */ - /**********************/ - /***********************************/ - /* B 1.3.1 - Elementary Data Types */ - /***********************************/ - static real_type_name_c real_type_name; - static sint_type_name_c sint_type_name; - static lint_type_name_c lint_type_name; - static dint_type_name_c dint_type_name; - static date_type_name_c date_type_name; - static dword_type_name_c dword_type_name; - static dt_type_name_c dt_type_name; - static tod_type_name_c tod_type_name; - static udint_type_name_c udint_type_name; - static word_type_name_c word_type_name; - static wstring_type_name_c wstring_type_name; - static string_type_name_c string_type_name; - static lword_type_name_c lword_type_name; - static uint_type_name_c uint_type_name; - static lreal_type_name_c lreal_type_name; - static byte_type_name_c byte_type_name; - static usint_type_name_c usint_type_name; - static ulint_type_name_c ulint_type_name; - static bool_type_name_c bool_type_name; - static time_type_name_c time_type_name; - static int_type_name_c int_type_name; - - - /******************************************************/ - /* Extensions to the base standard as defined in */ - /* "Safety Software Technical Specification, */ - /* Part 1: Concepts and Function Blocks, */ - /* Version 1.0 – Official Release" */ - /* by PLCopen - Technical Committee 5 - 2006-01-31 */ - /******************************************************/ - -// static safebool_type_name_c safebool_type_name; - /* The following is required because the expression (TOD_var - TOD_var) will result in a data type - * (in this case, TIME) that is neither of the expression elements... - */ - static safetime_type_name_c safetime_type_name; - static safetod_type_name_c safetod_type_name; - static safedt_type_name_c safedt_type_name; - static safedate_type_name_c safedate_type_name; - static safereal_type_name_c safereal_type_name; - static safesint_type_name_c safesint_type_name; - static safelint_type_name_c safelint_type_name; - static safedint_type_name_c safedint_type_name; - static safedword_type_name_c safedword_type_name; - static safeudint_type_name_c safeudint_type_name; - static safeword_type_name_c safeword_type_name; - static safewstring_type_name_c safewstring_type_name; - static safestring_type_name_c safestring_type_name; - static safelword_type_name_c safelword_type_name; - static safeuint_type_name_c safeuint_type_name; - static safelreal_type_name_c safelreal_type_name; - static safebyte_type_name_c safebyte_type_name; - static safeusint_type_name_c safeusint_type_name; - static safeulint_type_name_c safeulint_type_name; - static safebool_type_name_c safebool_type_name; - static safeint_type_name_c safeint_type_name; - - public: - symbol_c *get_type(symbol_c *constant); - - - private: - /*********************/ - /* B 1.2 - Constants */ - /*********************/ - - /******************************/ - /* B 1.2.1 - Numeric Literals */ - /******************************/ - void *visit(real_c *symbol); - void *visit(neg_real_c *symbol); - void *visit(integer_c *symbol); - void *visit(neg_integer_c *symbol); - void *visit(binary_integer_c *symbol); - void *visit(octal_integer_c *symbol); - void *visit(hex_integer_c *symbol); - - void *visit(integer_literal_c *symbol); - void *visit(real_literal_c *symbol); - void *visit(bit_string_literal_c *symbol); - void *visit(boolean_literal_c *symbol); - - void *visit(boolean_true_c *symbol); - void *visit(boolean_false_c *symbol); - - /*******************************/ - /* B.1.2.2 Character Strings */ - /*******************************/ - void *visit(double_byte_character_string_c *symbol); - void *visit(single_byte_character_string_c *symbol); - - /***************************/ - /* B 1.2.3 - Time Literals */ - /***************************/ - /************************/ - /* B 1.2.3.1 - Duration */ - /************************/ - void *visit(neg_time_c *symbol); - void *visit(duration_c *symbol); - void *visit(interval_c *symbol); - void *visit(fixed_point_c *symbol); - - /************************************/ - /* B 1.2.3.2 - Time of day and Date */ - /************************************/ - void *visit(time_of_day_c *symbol); - void *visit(daytime_c *symbol); - void *visit(date_c *symbol); - void *visit(date_literal_c *symbol); - void *visit(date_and_time_c *symbol); - - /********************************/ - /* B 1.3.3 - Derived data types */ - /********************************/ - void *visit(enumerated_value_c *symbol); -}; // search_constant_type_c - - -#endif /* ifndef _SEARCH_CONSTANT_TYPE_HH */ diff -r bb4511694c0e -r ec8df1de3e08 stage4/generate_c/generate_c_typedecl.cc --- a/stage4/generate_c/generate_c_typedecl.cc Fri Oct 26 13:48:16 2012 +0100 +++ b/stage4/generate_c/generate_c_typedecl.cc Fri Oct 26 13:52:16 2012 +0100 @@ -32,7 +32,6 @@ symbol_c* current_type_name; bool array_is_derived; search_base_type_c search_base_type; - search_constant_type_c search_constant_type; generate_c_base_c *basedecl;