--- a/absyntax/absyntax.def Fri Nov 21 13:43:49 2008 +0100
+++ b/absyntax/absyntax.def Wed Nov 26 09:06:26 2008 +0100
@@ -162,6 +162,7 @@
SYM_REF0(wstring_type_name_c)
SYM_REF0(constant_int_type_name_c)
SYM_REF0(constant_real_type_name_c)
+SYM_REF0(direct_variable_type_name_c)
/********************************/
--- a/stage1_2/iec.flex Fri Nov 21 13:43:49 2008 +0100
+++ b/stage1_2/iec.flex Wed Nov 26 09:06:26 2008 +0100
@@ -885,6 +885,7 @@
<body_state>{
{st_whitespace_no_pragma} /* Eat any whitespace */
{qualified_identifier}{st_whitespace}":=" unput_text(0); BEGIN(st_state);
+{direct_variable_standard}{st_whitespace}":=" unput_text(0); BEGIN(st_state);
{qualified_identifier}"[" unput_text(0); BEGIN(st_state);
RETURN unput_text(0); BEGIN(st_state);
--- a/stage4/generate_c/generate_c_vardecl.cc Fri Nov 21 13:43:49 2008 +0100
+++ b/stage4/generate_c/generate_c_vardecl.cc Wed Nov 26 09:06:26 2008 +0100
@@ -1060,6 +1060,16 @@
symbol->location->accept(*this);
s4o.print(" = ");
symbol->location->accept(*this);
+ if (this->current_var_init_symbol != NULL) {
+ s4o.print("; *");
+ print_variable_prefix();
+ if (symbol->variable_name != NULL)
+ symbol->variable_name->accept(*this);
+ else
+ symbol->location->accept(*this);
+ s4o.print(" = ");
+ this->current_var_init_symbol->accept(*this);
+ }
s4o.print(";}");
break;
--- a/stage4/generate_c/search_base_type.cc Fri Nov 21 13:43:49 2008 +0100
+++ b/stage4/generate_c/search_base_type.cc Wed Nov 26 09:06:26 2008 +0100
@@ -94,6 +94,7 @@
void *visit(wstring_type_name_c *symbol) {return (void *)symbol;}
void *visit(constant_int_type_name_c *symbol) {return (void *)symbol;}
void *visit(constant_real_type_name_c *symbol) {return (void *)symbol;}
+ void *visit(direct_variable_type_name_c *symbol) {return (void *)symbol;}
/********************************/
/* B 1.3.3 - Derived data types */
--- a/stage4/generate_c/search_constant_type.cc Fri Nov 21 13:43:49 2008 +0100
+++ b/stage4/generate_c/search_constant_type.cc Wed Nov 26 09:06:26 2008 +0100
@@ -66,6 +66,7 @@
static constant_real_type_name_c constant_real_type_name;
static constant_int_type_name_c constant_int_type_name;
+ static direct_variable_type_name_c direct_variable_type_name;
public:
symbol_c *get_type(symbol_c *constant) {
@@ -73,6 +74,7 @@
}
public:
+
/*********************/
/* B 1.2 - Constants */
/*********************/
@@ -128,7 +130,6 @@
void *visit(date_and_time_c *symbol) {return (void *)&dt_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;
@@ -153,6 +154,7 @@
constant_real_type_name_c search_constant_type_c::constant_real_type_name;
constant_int_type_name_c search_constant_type_c::constant_int_type_name;
+direct_variable_type_name_c search_constant_type_c::direct_variable_type_name;
--- a/stage4/generate_c/search_expression_type.cc Fri Nov 21 13:43:49 2008 +0100
+++ b/stage4/generate_c/search_expression_type.cc Wed Nov 26 09:06:26 2008 +0100
@@ -120,6 +120,7 @@
if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;}
if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;}
if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;}
return false;
}
@@ -127,6 +128,7 @@
if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;}
if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;}
if (typeid(*type_symbol) == typeid(constant_real_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;}
return false;
}
@@ -140,6 +142,7 @@
if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;}
if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;}
if (typeid(*type_symbol) == typeid(constant_int_type_name_c)) {return true;}
+ if (typeid(*type_symbol) == typeid(direct_variable_type_name_c)) {return true;}
return false;
}
@@ -156,17 +159,19 @@
if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return true;}
if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return true;}
if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return true;}
+ if (typeid(*first_type) == typeid(direct_variable_type_name_c)) {return true;}
+ if (typeid(*second_type) == typeid(direct_variable_type_name_c)) {return true;}
return false;
}
symbol_c* common_type(symbol_c *first_type, symbol_c *second_type) {
if (typeid(*first_type) == typeid(*second_type)) {return first_type;}
- if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return first_type;}
- if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_integer_type(second_type))) {return second_type;}
- if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c))) {return first_type;}
- if ((typeid(*first_type) == typeid(constant_int_type_name_c) && is_binary_type(second_type))) {return second_type;}
- if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c))) {return first_type;}
- if ((typeid(*first_type) == typeid(constant_real_type_name_c) && is_real_type(second_type))) {return second_type;}
+ if (is_integer_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c) || typeid(*second_type) == typeid(direct_variable_type_name_c))) {return first_type;}
+ if ((typeid(*first_type) == typeid(constant_int_type_name_c) || typeid(*second_type) == typeid(direct_variable_type_name_c)) && is_integer_type(second_type)) {return second_type;}
+ if (is_binary_type(first_type) && (typeid(*second_type) == typeid(constant_int_type_name_c) || typeid(*second_type) == typeid(direct_variable_type_name_c))) {return first_type;}
+ if ((typeid(*first_type) == typeid(constant_int_type_name_c) || typeid(*second_type) == typeid(direct_variable_type_name_c)) && is_binary_type(second_type)) {return second_type;}
+ if (is_real_type(first_type) && (typeid(*second_type) == typeid(constant_real_type_name_c) || typeid(*second_type) == typeid(direct_variable_type_name_c))) {return first_type;}
+ if ((typeid(*first_type) == typeid(constant_real_type_name_c) || typeid(*second_type) == typeid(direct_variable_type_name_c)) && is_real_type(second_type)) {return second_type;}
return NULL;
}
@@ -214,6 +219,18 @@
return NULL;
}
+/********************************************/
+/* B 1.4.1 - Directly Represented Variables */
+/********************************************/
+ void *visit(direct_variable_c *symbol) {
+ switch (symbol->value[2]) {
+ case 'X': // bit
+ return (void *)&bool_type_name;
+ default:
+ return (void *)&direct_variable_type_name;
+ }
+ }
+
/*************************************/
/* B 1.4.2 - Multi-element variables */
/*************************************/
--- a/stage4/generate_iec/generate_iec.cc Fri Nov 21 13:43:49 2008 +0100
+++ b/stage4/generate_iec/generate_iec.cc Wed Nov 26 09:06:26 2008 +0100
@@ -308,6 +308,7 @@
void *visit(wstring_type_name_c *symbol) {s4o.print("WSTRING"); return NULL;}
void *visit(constant_int_type_name_c *symbol) {return NULL;}
void *visit(constant_real_type_name_c *symbol) {return NULL;}
+void *visit(direct_variable_type_name_c *symbol) {return NULL;}
/********************************/