Skip to content

Commit

Permalink
Add more language standards.
Browse files Browse the repository at this point in the history
- Add 3.4, 3.5, and experimental as language standards.
- Change LanguageStandard.latest to mean 3.4.
  • Loading branch information
perost committed Jun 3, 2020
1 parent 58b509d commit 0df6e65
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
35 changes: 17 additions & 18 deletions OMCompiler/Compiler/Util/Config.mo
Expand Up @@ -47,7 +47,7 @@ import System;

public

type LanguageStandard = enumeration('1.x', '2.x', '3.0', '3.1', '3.2', '3.3', latest)
type LanguageStandard = enumeration('1.x', '2.x', '3.0', '3.1', '3.2', '3.3', '3.4', latest, '3.5', experimental)
"Defines the various modelica language versions that OMC can use.";

public function typeinfo "+t"
Expand Down Expand Up @@ -450,7 +450,7 @@ protected function languageStandardInt
input LanguageStandard inStandard;
output Integer outValue;
protected
constant Integer lookup[LanguageStandard] = array(10, 20, 30, 31, 32, 33, 1000);
constant Integer lookup[LanguageStandard] = array(10, 20, 30, 31, 32, 33, 34, 1000, 1035, 9999);
algorithm
outValue := lookup[inStandard];
end languageStandardInt;
Expand All @@ -466,15 +466,18 @@ algorithm
case 31 then LanguageStandard.'3.1';
case 32 then LanguageStandard.'3.2';
case 33 then LanguageStandard.'3.3';
case 34 then LanguageStandard.'3.4';
case 1000 then LanguageStandard.latest;
case 1035 then LanguageStandard.'3.5';
case 9999 then LanguageStandard.experimental;
end match;
end intLanguageStandard;

public function languageStandardString
input LanguageStandard inStandard;
output String outString;
protected
constant String lookup[LanguageStandard] = array("1.x","2.x","3.0","3.1","3.2","3.3","3.3" /*Change this to latest version if you add more versions!*/);
constant String lookup[LanguageStandard] = array("1.x","2.x","3.0","3.1","3.2","3.3","3.4","3.4","3.5","experimental" /*Change this to latest version if you add more versions!*/);
algorithm
outString := lookup[inStandard];
end languageStandardString;
Expand All @@ -492,22 +495,21 @@ algorithm

_ := matchcontinue(inLibraryName)
local
String version, new_std_str;
String version;
LanguageStandard new_std;
Boolean show_warning;

case _
algorithm
"Modelica" :: version :: _ := System.strtok(inLibraryName, " ");
new_std := versionStringToStd(version);
if new_std==current_std then
return;
end if;
setLanguageStandard(new_std);
show_warning := hasLanguageStandardChanged(current_std);
new_std_str := languageStandardString(new_std);
if show_warning then
Error.addMessage(Error.CHANGED_STD_VERSION, {new_std_str, version});

if new_std <> current_std then
setLanguageStandard(new_std);

if hasLanguageStandardChanged(current_std) then
Error.addMessage(Error.CHANGED_STD_VERSION,
{languageStandardString(new_std), version});
end if;
end if;
then ();

Expand Down Expand Up @@ -544,6 +546,7 @@ algorithm
case "2" :: _ then LanguageStandard.'2.x';
case "3" :: "0" :: _ then LanguageStandard.'3.0';
case "3" :: "1" :: _ then LanguageStandard.'3.1';
//case "3" :: "2" :: "3" :: _ then LanguageStandard.'3.3';
case "3" :: "2" :: _ then LanguageStandard.'3.2';
case "3" :: "3" :: _ then LanguageStandard.'3.3';
case "3" :: _ then LanguageStandard.latest;
Expand Down Expand Up @@ -635,11 +638,7 @@ end adaptiveHomotopy;
public function synchronousFeaturesAllowed
"@autor: adrpo
checks returns true if language standard is above or equal to Modelica 3.3"
output Boolean outRes;
protected
LanguageStandard std = getLanguageStandard();
algorithm
outRes := intGe(languageStandardInt(std), 33);
output Boolean outRes = getLanguageStandard() >= LanguageStandard.'3.3';
end synchronousFeaturesAllowed;

public function flatModelica
Expand Down
5 changes: 3 additions & 2 deletions OMCompiler/Compiler/Util/Flags.mo
Expand Up @@ -594,8 +594,9 @@ constant ConfigFlag ANNOTATION_VERSION = CONFIG_FLAG(7, "annotationVersion",

constant ConfigFlag LANGUAGE_STANDARD = CONFIG_FLAG(8, "std", NONE(), EXTERNAL(),
ENUM_FLAG(1000,
{("1.x", 10), ("2.x", 20), ("3.0", 30), ("3.1", 31), ("3.2", 32), ("3.3", 33), ("latest",1000)}),
SOME(STRING_OPTION({"1.x", "2.x", "3.1", "3.2", "3.3", "latest"})),
{("1.x", 10), ("2.x", 20), ("3.0", 30), ("3.1", 31), ("3.2", 32), ("3.3", 33),
("3.4", 34), ("latest",1000), ("3.5", 1035), ("experimental", 9999)}),
SOME(STRING_OPTION({"1.x", "2.x", "3.1", "3.2", "3.3", "3.4", "latest", "3.5", "experimental"})),
Gettext.gettext("Sets the language standard that should be used."));

constant ConfigFlag SHOW_ERROR_MESSAGES = CONFIG_FLAG(9, "showErrorMessages",
Expand Down

0 comments on commit 0df6e65

Please sign in to comment.