diff --git a/Compiler/template_precompile/C__GenerateFunctionBodies.tpl b/Compiler/template_precompile/C__GenerateFunctionBodies.tpl deleted file mode 100644 index 14bacb6d117..00000000000 --- a/Compiler/template_precompile/C__GenerateFunctionBodies.tpl +++ /dev/null @@ -1,20 +0,0 @@ - (}", ">)\n -\{ -}> - - -}> - - -}> - - -}> -\}\n -\n -}> -}> diff --git a/Compiler/template_precompile/C__GenerateFunctions.tpl b/Compiler/template_precompile/C__GenerateFunctions.tpl deleted file mode 100644 index d8c992ff54b..00000000000 --- a/Compiler/template_precompile/C__GenerateFunctions.tpl +++ /dev/null @@ -1,38 +0,0 @@ -#ifdef __cplusplus\n -extern "C" \{\n -#endif\n - -/* header part */\n -\n}> - - (}", ">);\n -} -else { -#ifdef __cplusplus\n -extern "C" \{\n -#endif\n -\n}> - - (}", ">);\n -}> - -#ifdef __cplusplus\n -\}\n -#endif\n -}> -}> -/* End of header part */\n - -\n -/* Body */\n - -/* End Body */\n -\n -#ifdef __cplusplus\n -\}\n -#endif\n diff --git a/Compiler/template_precompile/Error.mo b/Compiler/template_precompile/Error.mo deleted file mode 100644 index 787ab8feb9e..00000000000 --- a/Compiler/template_precompile/Error.mo +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of OpenModelica. - * - * Copyright (c) 1998-2010, Link�pings University, - * Department of Computer and Information Science, - * SE-58183 Link�ping, Sweden. - * - * All rights reserved. - * - * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THIS OSMC PUBLIC - * LICENSE (OSMC-PL). ANY USE, REPRODUCTION OR DISTRIBUTION OF - * THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THE OSMC - * PUBLIC LICENSE. - * - * The OpenModelica software and the Open Source Modelica - * Consortium (OSMC) Public License (OSMC-PL) are obtained - * from Link�pings University, either from the above address, - * from the URL: http://www.ida.liu.se/projects/OpenModelica - * and in the OpenModelica distribution. - * - * This program is distributed WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH - * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS - * OF OSMC-PL. - * - * See the full OSMC Public License conditions for more details. - * - */ - -package Error -" - file: Error.mo - package: Error - description: Error handling (stub for TemplCG) - - RCS: $Id: Error.mo 3863 2009-02-13 18:56:21Z sjoelund.se $ - - This file contains the Error handling for the Compiler." - -import Print; -import Util; - -public -type ErrorID = Integer "Unique error id. Used to - look up message string and type and severity"; -public -type MessageTokens = list; - -public constant ErrorID TEMPLCG_INVALID_TEMPLATE = 111; -public constant ErrorID TEMPLCG_FAILED_TO_APPLY_TEMPLATE = 112; - -public function addMessage - input ErrorID inErrorID; - input MessageTokens inMessageTokens; -algorithm - _ := Util.listMap(inMessageTokens, Print.printBuf2); -end addMessage; - -end Error; - diff --git a/Compiler/template_precompile/Main.mo b/Compiler/template_precompile/Main.mo deleted file mode 100644 index a46135859cd..00000000000 --- a/Compiler/template_precompile/Main.mo +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file is part of OpenModelica. - * - * Copyright (c) 1998-2010, Link�pings University, - * Department of Computer and Information Science, - * SE-58183 Link�ping, Sweden. - * - * All rights reserved. - * - * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THIS OSMC PUBLIC - * LICENSE (OSMC-PL). ANY USE, REPRODUCTION OR DISTRIBUTION OF - * THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THE OSMC - * PUBLIC LICENSE. - * - * The OpenModelica software and the Open Source Modelica - * Consortium (OSMC) Public License (OSMC-PL) are obtained - * from Link�pings University, either from the above address, - * from the URL: http://www.ida.liu.se/projects/OpenModelica - * and in the OpenModelica distribution. - * - * This program is distributed WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH - * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS - * OF OSMC-PL. - * - * See the full OSMC Public License conditions for more details. - * - */ - -package Main -" - file: Main.mo - package: Precompile - description: Precompiles templates for faster code generation - - RCS: $Id: Error.mo 3863 2009-02-13 18:56:21Z sjoelund.se $ - " - -import Templates; - -function main - input list arg; -protected - list cTemplates; -algorithm - /* Use print instead of the template engine because TemplCG.PrintTemplateTreeSequence - * has already been written. That function shouldn't use the template engine because - * it is used as debug print for the engine itself (and could cause infinite loops - * if something goes wrong). - */ - - print("/* - * Auto-generated file containing pre-compiled templates for - * fast code generation. Do not edit manually. - */ - -package CompiledTemplates - -import TemplCG; - -record CompiledTemplateSet - String name; - TemplCG.TemplateTreeSequence generateFunctions; - TemplCG.TemplateTreeSequence generateFunctionBodies; -end CompiledTemplateSet; - -uniontype TemplateType - record GEN_FUNCTIONS end GEN_FUNCTIONS; - record GEN_BODIES end GEN_BODIES; -end TemplateType; - -public function getTemplateFromSet - input CompiledTemplateSet set; - input TemplateType ty; - output TemplCG.TemplateTreeSequence out; -algorithm - out := matchcontinue (set,ty) - local - TemplCG.TemplateTreeSequence out; - case (CompiledTemplateSet(generateFunctions = out), GEN_FUNCTIONS()) then out; - case (CompiledTemplateSet(generateFunctionBodies = out), GEN_BODIES()) then out; - end matchcontinue; -end getTemplateFromSet; - -constant list availableTemplates = {\n"); - cTemplates := Templates.CompileTemplateSets(Templates.templateList); - Templates.PrintCompiledTemplates(cTemplates); - print("};\n"); - print("end CompiledTemplates;\n"); -end main; - -end Main; - diff --git a/Compiler/template_precompile/Makefile.in b/Compiler/template_precompile/Makefile.in deleted file mode 100644 index 12634edadb9..00000000000 --- a/Compiler/template_precompile/Makefile.in +++ /dev/null @@ -1,66 +0,0 @@ -# -# Makefile for omc -# -# David Kågedal -# -# $Id: Makefile.in 3766 2008-12-08 05:24:54Z adrpo $ -# - -SHELL = /bin/sh -CC = gcc -CFLAGS = $(USE_CORBA) -RMLHOME = @rmlhome@ -RMLINC = -I$(RMLHOME)/include/plain - -EXEEXT = @EXEEXT@ - -srcdir = .. -top_builddir = ../.. -builddir_bin=$(top_builddir)/build/bin -builddir_lib=$(top_builddir)/build/lib -builddir_inc=$(top_builddir)/build/include -builddir_doc=$(top_builddir)/build/doc - -LDFLAGS = -lm -L$(RMLHOME)/lib/plain -lrml -ldl readfile.a - -PROG = tpc -RMLC = @rmlc_bin@ -RML = $(RMLHOME)/bin/rml -RMLCFLAGS = -Wr,-ftrace - -SRCO = Print.o Error.o Util.o TemplCG.o Templates.o Main.o - -SUBDIRS = $(srcdir)/runtime $(srcdir)/absyn_builder $(srcdir)/modpar - -all : $(ALLMO) $(PROG) CompiledTemplates.mo ../CompiledTemplates.mo - - -.SUFFIXES: -.SUFFIXES: .o .mo .h -.PHONY: all subdirs $(SUBDIRS) report vctarget absyn_subdir clean reallyclean - -CompiledTemplates.mo: $(PROG) - ./$(PROG) > CompiledTemplates.mo - -../CompiledTemplates.mo: CompiledTemplates.o - cp CompiledTemplates.mo ../CompiledTemplates.mo - -readfile.a: readfile.o - ar rcs $@ $< -readfile.o: readfile.c - gcc $(RMLINC) -c $< - -TemplCG.mo: $(srcdir)/TemplCG.mo - cp $< $@ - -.mo.o: - $(RMLC) $(RMLCFLAGS) -c $< - -$(PROG): $(SRCO) - g++ -O3 -o $(PROG)$(EXEEXT) $(SRCO) $(AST) $(RTOBJ) $(LDFLAGS) $(PLTPKGFLAGS) - -clean: - $(RM) *.srz *.h *.o $(PROG)$(EXEEXT) - -Makefile: Makefile.in - $(top_builddir)/config.status Makefile diff --git a/Compiler/template_precompile/Print.mo b/Compiler/template_precompile/Print.mo deleted file mode 100644 index e236334359a..00000000000 --- a/Compiler/template_precompile/Print.mo +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of OpenModelica. - * - * Copyright (c) 1998-2010, Link�pings University, - * Department of Computer and Information Science, - * SE-58183 Link�ping, Sweden. - * - * All rights reserved. - * - * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THIS OSMC PUBLIC - * LICENSE (OSMC-PL). ANY USE, REPRODUCTION OR DISTRIBUTION OF - * THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THE OSMC - * PUBLIC LICENSE. - * - * The OpenModelica software and the Open Source Modelica - * Consortium (OSMC) Public License (OSMC-PL) are obtained - * from Link�pings University, either from the above address, - * from the URL: http://www.ida.liu.se/projects/OpenModelica - * and in the OpenModelica distribution. - * - * This program is distributed WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH - * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS - * OF OSMC-PL. - * - * See the full OSMC Public License conditions for more details. - * - */ - -package Print -" file: Print.mo - package: Print - description: Print stub for TemplCG precompile - - RCS: $Id: Print.mo 3768 2008-12-08 05:50:27Z adrpo $ - " - -public function printBuf2 - input String s; - output String out; -algorithm - print(s); - out := s; -end printBuf2; - -public function printBuf - input String s; -algorithm - print(s); -end printBuf; - -end Print; - diff --git a/Compiler/template_precompile/System.mo b/Compiler/template_precompile/System.mo deleted file mode 100644 index 5614b3677c8..00000000000 --- a/Compiler/template_precompile/System.mo +++ /dev/null @@ -1,11 +0,0 @@ -package System "Stub" - -public function readFile - input String inString; - output String outString; - - external "C"; -end readFile; - -end System; - diff --git a/Compiler/template_precompile/Templates.mo b/Compiler/template_precompile/Templates.mo deleted file mode 100644 index c9210209edc..00000000000 --- a/Compiler/template_precompile/Templates.mo +++ /dev/null @@ -1,84 +0,0 @@ -package Templates - -import TemplCG; -import Util; - -record TemplateSet - String name; - String generateFunctions; - String generateFunctionBodies; -end TemplateSet; - -record CompiledTemplateSet - String name; - TemplCG.TemplateTreeSequence generateFunctions; - TemplCG.TemplateTreeSequence generateFunctionBodies; -end CompiledTemplateSet; - -constant list templateList = { - TemplateSet("C89", "C__GenerateFunctions.tpl","C__GenerateFunctionBodies.tpl") -}; - -public function CompileTemplateSets - input list templates; - output list out; -algorithm - out := Util.listMap(templates,CompileTemplateSet); -end CompileTemplateSets; - -public function CompileTemplateSet - input TemplateSet templateSet; - output CompiledTemplateSet out; -algorithm - out := matchcontinue (templateSet) - local - String name, funcs, bodies; - TemplCG.TemplateTreeSequence cFuncs, cBodies; - case TemplateSet(name,funcs,bodies) equation - cBodies = TemplCG.CompileTemplateFromFile(bodies, {}); - cFuncs = TemplCG.CompileTemplateFromFile(funcs, {}); - then CompiledTemplateSet(name,cFuncs,cBodies); - end matchcontinue; -end CompileTemplateSet; - -public function PrintCompiledTemplates - input list templates; -algorithm - _ := matchcontinue (templates) - local - CompiledTemplateSet cur; - list rest; - case {} then (); - case (cur :: rest) equation - PrintCompiledTemplate(cur); - print("\n"); - PrintCompiledTemplates(rest); - then (); - case (cur :: rest) equation - PrintCompiledTemplate(cur); - print(",\n"); - PrintCompiledTemplates(rest); - then (); - end matchcontinue; -end PrintCompiledTemplates; - -public function PrintCompiledTemplate - input CompiledTemplateSet template; -algorithm - _ := matchcontinue (template) - local - String name; - TemplCG.TemplateTreeSequence functions, bodies; - case CompiledTemplateSet(name,functions,bodies) equation - print("CompiledTemplateSet(\""); - print(name); - print("\","); - TemplCG.PrintTemplateTreeSequence(functions); - print(","); - TemplCG.PrintTemplateTreeSequence(bodies); - print(")"); - then (); - end matchcontinue; -end PrintCompiledTemplate; - -end Templates; \ No newline at end of file diff --git a/Compiler/template_precompile/Util.mo b/Compiler/template_precompile/Util.mo deleted file mode 100644 index 71f013f7a74..00000000000 --- a/Compiler/template_precompile/Util.mo +++ /dev/null @@ -1,263 +0,0 @@ -/* - * This file is part of OpenModelica. - * - * Copyright (c) 1998-2010, Link�pings University, - * Department of Computer and Information Science, - * SE-58183 Link�ping, Sweden. - * - * All rights reserved. - * - * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THIS OSMC PUBLIC - * LICENSE (OSMC-PL). ANY USE, REPRODUCTION OR DISTRIBUTION OF - * THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THE OSMC - * PUBLIC LICENSE. - * - * The OpenModelica software and the Open Source Modelica - * Consortium (OSMC) Public License (OSMC-PL) are obtained - * from Link�pings University, either from the above address, - * from the URL: http://www.ida.liu.se/projects/OpenModelica - * and in the OpenModelica distribution. - * - * This program is distributed WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH - * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS - * OF OSMC-PL. - * - * See the full OSMC Public License conditions for more details. - * - */ - -package Util -" file: Util.mo - package: Util - description: Part of Util.mo, to get rid off System for TemplCG... - - RCS: $Id: Util.mo 3875 2009-02-17 07:57:42Z adrpo $ -" - -public function stringReplaceChar "function stringReplaceChar - Takes a string and two chars and replaces the first char with the second char: - Example: string_replace_char(\"hej.b.c\",\".\",\"_\") => \"hej_b_c\" - 2007-11-26 BZ: Now it is possible to replace chars with emptychar, and - replace a char with a string - Example: string_replace_char(\"hej.b.c\",\".\",\"_dot_\") => \"hej_dot_b_dot_c\" - " - input String inString1; - input String inString2; - input String inString3; - output String outString; -algorithm - outString:= - matchcontinue (inString1,inString2,inString3) - local - list strList,resList; - String res,str; - String fromChar,toChar; - case (str,fromChar,toChar) - equation - strList = string_list_string_char(str); - resList = stringReplaceChar2(strList, fromChar, toChar); - res = string_char_list_string(resList); - then - res; - case (strList,_,_) - local String strList; - equation - print("- Util.stringReplaceChar failed\n"); - then - strList; - end matchcontinue; -end stringReplaceChar; - -protected function stringReplaceChar2 - input list inStringLst1; - input String inString2; - input String inString3; - output list outStringLst; -algorithm - outStringLst:= - matchcontinue (inStringLst1,inString2,inString3) - local - list res,rest,strList, charList2; - String firstChar,fromChar,toChar; - case ({},_,_) then {}; - case ((firstChar :: rest),fromChar,"") // added special case for removal of char. - equation - equality(firstChar = fromChar); - res = stringReplaceChar2(rest, fromChar, ""); - then - (res); - case ((firstChar :: rest),fromChar,toChar) - equation - equality(firstChar = fromChar); - res = stringReplaceChar2(rest, fromChar, toChar); - charList2 = string_list_string_char(toChar); - res = listAppend(charList2,res); - then - res; - - case ((firstChar :: rest),fromChar,toChar) - equation - failure(equality(firstChar = fromChar)); - res = stringReplaceChar2(rest, fromChar, toChar); - then - (firstChar :: res); - case (strList,_,_) - equation - print("- Util.stringReplaceChar2 failed\n"); - then - strList; - end matchcontinue; -end stringReplaceChar2; - -public function stringSplitAtChar "function stringSplitAtChar - Takes a string and a char and split the string at the char returning the list of components. - Example: stringSplitAtChar(\"hej.b.c\",\".\") => {\"hej,\"b\",\"c\"}" - input String inString1; - input String inString2; - output list outStringLst; -algorithm - outStringLst:= - matchcontinue (inString1,inString2) - local - list chrList; - list stringList; - String str,strList; - String chr; - case (str,chr) - equation - chrList = string_list_string_char(str); - stringList = stringSplitAtChar2(chrList, chr, {}) "listString(resList) => res" ; - then - stringList; - case (strList,_) then {strList}; - end matchcontinue; -end stringSplitAtChar; - -protected function stringSplitAtChar2 - input list inStringLst1; - input String inString2; - input list inStringLst3; - output list outStringLst; -algorithm - outStringLst:= - matchcontinue (inStringLst1,inString2,inStringLst3) - local - list chr_rest_1,chr_rest,chrList,rest,strList; - String res; - list res_str; - String firstChar,chr; - case ({},_,chr_rest) - equation - chr_rest_1 = listReverse(chr_rest); - res = string_char_list_string(chr_rest_1); - then - {res}; - case ((firstChar :: rest),chr,chr_rest) - equation - equality(firstChar = chr); - chrList = listReverse(chr_rest) "this is needed because it returns the reversed list" ; - res = string_char_list_string(chrList); - res_str = stringSplitAtChar2(rest, chr, {}); - then - (res :: res_str); - case ((firstChar :: rest),chr,chr_rest) - local list res; - equation - failure(equality(firstChar = chr)); - res = stringSplitAtChar2(rest, chr, (firstChar :: chr_rest)); - then - res; - case (strList,_,_) - equation - print("- Util.stringSplitAtChar2 failed\n"); - then - fail(); - end matchcontinue; -end stringSplitAtChar2; - -public function listFirst "function: listFirst - Returns the first element of a list - Example: listFirst({3,5,7,11,13}) => 3" - input list inTypeALst; - output Type_a outTypeA; - replaceable type Type_a subtypeof Any; -algorithm - outTypeA:= listNth(inTypeALst, 0); -end listFirst; - -public function listMap "function: listMap - Takes a list and a function over the elements of the lists, which is applied - for each element, producing a new list. - Example: listMap({1,2,3}, intString) => { \"1\", \"2\", \"3\"}" - input list inTypeALst; - input FuncTypeType_aToType_b inFuncTypeTypeAToTypeB; - output list outTypeBLst; - replaceable type Type_a subtypeof Any; - partial function FuncTypeType_aToType_b - input Type_a inTypeA; - output Type_b outTypeB; - replaceable type Type_b subtypeof Any; - end FuncTypeType_aToType_b; - replaceable type Type_b subtypeof Any; -algorithm - /* Fastest impl. on large lists, 10M elts takes about 3 seconds */ - outTypeBLst := listMap_impl_2(inTypeALst,{},inFuncTypeTypeAToTypeB); -end listMap; - -function listMap_impl_2 -"@author adrpo - this will work in O(2n) due to listReverse" - replaceable type TypeA subtypeof Any; - replaceable type TypeB subtypeof Any; - input list inLst; - input list accumulator; - input FuncTypeTypeVarToTypeVar fn; - output list outLst; - partial function FuncTypeTypeVarToTypeVar - input TypeA inTypeA; - output TypeB outTypeB; - replaceable type TypeA subtypeof Any; - replaceable type TypeB subtypeof Any; - end FuncTypeTypeVarToTypeVar; -algorithm - outLst := matchcontinue(inLst, accumulator, fn) - local - TypeA hd; - TypeB hdChanged; - list rest; - list l, result; - case ({}, l, _) then listReverse(l); - case (hd::rest, l, fn) - equation - hdChanged = fn(hd); - l = hdChanged::l; - result = listMap_impl_2(rest, l, fn); - then - result; - end matchcontinue; -end listMap_impl_2; - -public function if_ "function: if_ - Takes a boolean and two values. - Returns the first value (second argument) if the boolean value is - true, otherwise the second value (third argument) is returned. - Example: if_(true,\"a\",\"b\") => \"a\" -" - input Boolean inBoolean1; - input Type_a inTypeA2; - input Type_a inTypeA3; - output Type_a outTypeA; - replaceable type Type_a subtypeof Any; -algorithm - outTypeA:= - matchcontinue (inBoolean1,inTypeA2,inTypeA3) - local Type_a r; - case (true,r,_) then r; - case (false,_,r) then r; - end matchcontinue; -end if_; - -end Util; - diff --git a/Compiler/template_precompile/readfile.c b/Compiler/template_precompile/readfile.c deleted file mode 100644 index acb2e725fd5..00000000000 --- a/Compiler/template_precompile/readfile.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include -#include "rml.h" - -void System_5finit () -{ -} - -RML_BEGIN_LABEL(System__readFile) -{ - char* filename = RML_STRINGDATA(rmlA0); - char* buf; - int res; - FILE * file = NULL; - struct stat statstr; - res = stat(filename, &statstr); - - if(res!=0) - { - fprintf(stderr, "Error opening file %s\n", filename); - abort(); - } - - file = fopen(filename,"rb"); - buf = malloc(statstr.st_size+1); - - if( (res = fread(buf, sizeof(char), statstr.st_size, file)) != statstr.st_size) - { - fprintf(stderr, "Error reading file %s\n", filename); - abort(); - } - buf[statstr.st_size] = '\0'; - fclose(file); - - rmlA0 = (void*) mk_scon(buf); - free(buf); - - RML_TAILCALLK(rmlSC); - return buf; -} -RML_END_LABEL -