diff --git a/compiler2/Identifier.cc b/compiler2/Identifier.cc index 2333ee8a12cf9532051bfe25a741b9da1dc24b03..e8196f39fc133a4fe373e8da4d322df33c649e8e 100644 --- a/compiler2/Identifier.cc +++ b/compiler2/Identifier.cc @@ -22,6 +22,7 @@ #include <ctype.h> #include "Setting.hh" #include "CompilerError.hh" +#include "main.hh" namespace Common { @@ -96,6 +97,7 @@ namespace Common { private: static internal_data_t *instance; static const char* const keywords[][3]; + static const char* const realtime_keywords[][3]; size_t identifier_counter; public: const string string_invalid; @@ -802,7 +804,6 @@ namespace Common { {"noblock__", "noblock", "noblock_"}, {"none__", "none", "none_"}, {"not4b__", "not4b", "not4b_"}, - {"now__", "now", "now_"}, {"nowait__", "nowait", "nowait_"}, {"null__", "null", "null_"}, {"objid__", "objid", "objid_"}, @@ -822,7 +823,6 @@ namespace Common { {"procedure__", "procedure", "procedure_"}, {"raise__", "raise", "raise_"}, {"read__", "read", "read_"}, - {"realtime__", "realtime", "realtime_"}, {"receive__", "receive", "receive_"}, {"record__", "record", "record_"}, {"recursive__", "recursive", "recursive_"}, @@ -846,7 +846,6 @@ namespace Common { {"testcase__", "testcase", "testcase_"}, {"timeout__", "timeout", "timeout_"}, {"timer__", "timer", "timer_"}, - {"timestamp__", "timestamp", "timestamp_"}, {"to__", "to", "to_"}, {"trigger__", "trigger", "trigger_"}, {"type__", "type", "type_"}, @@ -869,6 +868,15 @@ namespace Common { /* the last must be all zeros */ {0, 0, 0} }; // keywords + + // keywords for the real-time testing feature + // (can be switched on or off with a command line option) + const char* const internal_data_t::realtime_keywords[][3] = { + {"now__", "now", "now_"}, + {"realtime__", "realtime", "realtime_"}, + {"timestamp__", "timestamp", "timestamp_"}, + {0, 0, 0} + }; internal_data_t::internal_data_t() : identifier_counter(0), string_invalid("<invalid>"), id_map_name(), @@ -973,6 +981,11 @@ namespace Common { Error_Context cntx(&loc, "While adding keywords"); for(size_t i=0; keywords[i][0]; i++) add_keyword(keywords[i]); + if (realtime_features) { + for(size_t i=0; realtime_keywords[i][0] != 0; i++) { + add_keyword(realtime_keywords[i]); + } + } } /* Perhaps it were good to read a file which contains user-defined mappings :) */ diff --git a/regression_test/compileonly/realtimeKeywords/.gitignore b/regression_test/compileonly/realtimeKeywords/.gitignore index 311f6e289fce796b8dae9d0c9b61398ea7f397ab..d4a23b8577e2e7079d1d6c72dd5cb06fce50910b 100644 --- a/regression_test/compileonly/realtimeKeywords/.gitignore +++ b/regression_test/compileonly/realtimeKeywords/.gitignore @@ -2,3 +2,5 @@ realtimeKeywords realtimeKeywords.exe realtimeKeywords*.cc realtimeKeywords*.hh +RealtimeKeywordsAsn*.cc +RealtimeKeywordsAsn*.hh diff --git a/regression_test/compileonly/realtimeKeywords/Makefile b/regression_test/compileonly/realtimeKeywords/Makefile index b8db0f70bcc902fd4ae5cdce545e37909bd64694..c09cd453e77b29e1771dd7231fff98e5693a2b5c 100644 --- a/regression_test/compileonly/realtimeKeywords/Makefile +++ b/regression_test/compileonly/realtimeKeywords/Makefile @@ -18,7 +18,9 @@ TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) TTCN3_MODULES = realtimeKeywords.ttcn -GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) +ASN1_MODULES = RealtimeKeywordsAsn.asn + +GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) $(ASN1_MODULES:.asn=.cc) GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh) ifdef CODE_SPLIT GENERATED_SOURCES := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), .cc _seq.cc _set.cc _seqof.cc _setof.cc _union.cc)) @@ -39,7 +41,7 @@ $(TARGET): $(GENERATED_SOURCES) $(USER_SOURCES) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) \ -L$(OPENSSL_DIR)/lib -lcrypto $($(PLATFORM)_LIBS) -$(GENERATED_SOURCES) $(GENERATED_HEADERS): $(TTCN3_MODULES) +$(GENERATED_SOURCES) $(GENERATED_HEADERS): $(TTCN3_MODULES) $(ASN1_MODULES) $(TTCN3_COMPILER) $(COMPILER_FLAGS) $^ clean distclean: diff --git a/regression_test/compileonly/realtimeKeywords/RealtimeKeywordsAsn.asn b/regression_test/compileonly/realtimeKeywords/RealtimeKeywordsAsn.asn new file mode 100644 index 0000000000000000000000000000000000000000..262a06346d249fb95e71b951ff9cc1fae27ee039 --- /dev/null +++ b/regression_test/compileonly/realtimeKeywords/RealtimeKeywordsAsn.asn @@ -0,0 +1,25 @@ +--///////////////////////////////////////////////////////////////////////////// +-- Copyright (c) 2000-2018 Ericsson Telecom AB +-- All rights reserved. This program and the accompanying materials +-- are made available under the terms of the Eclipse Public License v2.0 +-- which accompanies this distribution, and is available at +-- https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html +-- +-- Contributors: +-- Baranyi, Botond +-- +--///////////////////////////////////////////////////////////////////////////// +RealtimeKeywordsAsn +DEFINITIONS ::= +BEGIN + +IMPORTS ; -- nothing + +Seq ::= SEQUENCE { + now REAL, + realtime BOOLEAN +} + +timestamp INTEGER ::= 5 + +END diff --git a/regression_test/compileonly/realtimeKeywords/realtimeKeywords.ttcn b/regression_test/compileonly/realtimeKeywords/realtimeKeywords.ttcn index df6ad4dfa7bf8c98d847e13c83dc85bfb91a24df..3a8b3bd13563eb099c2e122970babffad1d380fa 100644 --- a/regression_test/compileonly/realtimeKeywords/realtimeKeywords.ttcn +++ b/regression_test/compileonly/realtimeKeywords/realtimeKeywords.ttcn @@ -14,12 +14,15 @@ // feature is disabled (for backward compatibility). module realtimeKeywords { +import from RealtimeKeywordsAsn all; + type record realtime {} template boolean now := true; -function timestamp() return float { - return -1.0; +function timestamp() return Seq { + var integer x := RealtimeKeywordsAsn.timestamp; + return { now := -1.0, realtime := false }; } }