Skip to content

Commit

Permalink
- Add missing file in previous commit
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23281 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 8, 2014
1 parent 3e9d57c commit 0611eee
Showing 1 changed file with 113 additions and 0 deletions.
113 changes: 113 additions & 0 deletions Compiler/Util/HashTableStringToProgram.mo
@@ -0,0 +1,113 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2014, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
* ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from OSMC, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* 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.
*
*/

encapsulated package HashTableStringToProgram

/* Below is the instance specific code. For each hashtable the user must define:
Key - The key used to uniquely define elements in a hashtable
Value - The data to associate with each key
hashFunc - A function that maps a key to a positive integer.
keyEqual - A comparison function between two keys, returns true if equal.
*/

/* HashTable instance specific code */

public import Absyn;
public import BaseHashTable;
protected import Dump;
protected import Util;
protected import System;

public type Key = String;
public type Value = Absyn.Program;

public type HashTableCrefFunctionsType = tuple<FuncHashCref,FuncCrefEqual,FuncCrefStr,FuncExpStr>;
public type HashTable = tuple<
array<list<tuple<Key,Integer>>>,
tuple<Integer,Integer,array<Option<tuple<Key,Value>>>>,
Integer,
Integer,
HashTableCrefFunctionsType
>;

partial function FuncHashCref
input Key cr;
input Integer mod;
output Integer res;
end FuncHashCref;

partial function FuncCrefEqual
input Key cr1;
input Key cr2;
output Boolean res;
end FuncCrefEqual;

partial function FuncCrefStr
input Key cr;
output String res;
end FuncCrefStr;

partial function FuncExpStr
input Value exp;
output String res;
end FuncExpStr;

public function emptyHashTable
"
Returns an empty HashTable.
Using the default bucketsize..
"
output HashTable hashTable;
algorithm
hashTable := emptyHashTableSized(BaseHashTable.defaultBucketSize);
end emptyHashTable;

public function emptyHashTableSized
"
Returns an empty HashTable.
Using the bucketsize size.
"
input Integer size;
output HashTable hashTable;
algorithm
hashTable := BaseHashTable.emptyHashTableWork(size,(System.stringHashDjb2Mod, stringEq, Util.id, dummyStr));
end emptyHashTableSized;

protected

function dummyStr
input Absyn.Program p;
output String str := "<dummy Absyn.Program string>";
end dummyStr;

annotation(__OpenModelica_Interface="frontend");
end HashTableStringToProgram;

0 comments on commit 0611eee

Please sign in to comment.