OpenModelica Compiler (OMC) Overview

Similar documents
OpenModelica Compiler (OMC) Overview

OpenModelica Environment and Modelica Overview

Modelica Environments and OpenModelica

Technical Overview of OpenModelica and its Development Environment

The OpenModelica Modeling, Simulation, and Development Environment

Technical Overview of OpenModelica and its Development Environment

OpenModelica System Documentation

OpenModelica Development Environment with Eclipse Integration for Browsing, Modeling, and Debugging

Technical Overview of OpenModelica and its Development Environment

Technical Overview of OpenModelica and its Development Environment

OpenModelica OMShell and OMNotebook Introduction and Exercises

INTRODUCTION TO OBJECT-ORIENTED MODELING AND SIMULATION WITH MODELICA USING THE OPENMODELICA ENVIRONMENT

Technical Overview of OpenModelica and its Development Environment

int a; class x { public int a; class x { float b; Asda ad public int a; Asa asad Aac sdscfcc c a

and its Development Environment

Modelica Change Proposal MCP-0019 Flattening (In Development) Proposed Changes to the Modelica Language Specification Version 3.

The Open Source Modelica Project

What follows is a list of the OMC APIs with their syntax and examples.

Towards Run-time Debugging of Equation-based Object-oriented Languages

GENERATING A MODELICA COMPILER FROM NATURAL SEMANTICS SPECIFICATIONS

Towards Modelica 4 Meta-Programming and Language Modeling with MetaModelica 2.0

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

OMEdit OpenModelica Connection Editor

OMEdit. OpenModelica Connection Editor. User Manual Version April 2011

An Eclipse-based Integrated Environment for Developing Executable Structural Operational Semantics Specifications

Task-Graph-Based Parallelization of Modelica-Simulations. Tutorial on the Usage of the HPCOM-Module

Meta-Programming with Modelica. Model Transformations

Abstract Syntax Can Make the Definition of Modelica Less Abstract

1st Annual OpenModelica Workshop Feb 2, 2009

Interpreting Languages for the Java Platform

OpenModelica Eclipse Plugin and MetaModelica Exercises

Implementation of F# language support in JetBrains Rider IDE

State Machines in OpenModelica

Modelica Based Parser Generator with Good Error Handling

Formal editing: jedit-mmt. Narrative editing: LaTeX-MMT. Browsing: MMT web server. Building: MMT scripting language. The MMT API: A Generic MKM System

Modelica Development Tooling for Eclipse

Semantic actions for expressions

A comparison of metacompilation approaches to implementing Modelica

Meta-Programming and Language Modeling with MetaModelica 1.0

Introduction Variables Helper commands Control Flow Constructs Basic Plumbing. Bash Scripting. Alessandro Barenghi

arxiv:cs/ v1 [cs.ma] 27 Jan 2004

AUTOMATIC PARALLELIZATION OF OBJECT ORIENTED MODELS ACROSS METHOD AND SYSTEM

CSE 401 Midterm Exam Sample Solution 11/4/11

Enhanced Class Design -- Introduction

The NetRexx Interpreter

Towards Unified System Modeling with the ModelicaML UML Profile

Automatic Parallelization of Mathematical Models Solved with Inlined Runge-Kutta Solvers

Modelica3D. Platform Independent Simulation Visualization. Christoph Höger. Technische Universität Berlin Fraunhofer FIRST

A Modular. OpenModelica. Compiler Backend

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far

An OpenModelica Python Interface and its use in PySimulator

An Evaluation of Domain-Specific Language Technologies for Code Generation

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

The Environment Model. Nate Foster Spring 2018

Bugloo: A Source Level Debugger for Scheme Programs Compiled into JVM Bytecode

CSE 504: Compiler Design. Intermediate Representations Symbol Table

COS 320. Compiling Techniques

Fault Tolerance Analysis using OpenModelica with Figaro Extensions for Modelica

About the Authors... iii Introduction... xvii. Chapter 1: System Software... 1

The PEPA Eclipse Plug-in

Programming Project II

Mo E A Communication Service Between Modelica Compilers and Text Editors

Anatomy of a Compiler. Overview of Semantic Analysis. The Compiler So Far. Why a Separate Semantic Analysis?

MonoLog - Logging and Monitoring Specifications

Parsing Scheme (+ (* 2 3) 1) * 1

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILING

CS 4201 Compilers 2014/2015 Handout: Lab 1

Integrated Model-Driven Development Environments for Equation-Based Object-Oriented Languages

Semantic Analysis. Lecture 9. February 7, 2018

News in RSA-RTE 10.0 updated for sprint Mattias Mohlin/Anders Ek, June 2016

UNIVERSITY OF COLUMBIA ADL++ Architecture Description Language. Alan Khara 5/14/2014

JavaScript CS 4640 Programming Languages for Web Applications

Modelica Meta-Programming and Symbolic Transformations

CSE P 501 Compilers. Static Semantics Hal Perkins Winter /22/ Hal Perkins & UW CSE I-1

CS153: Compilers Lecture 14: Type Checking

Noopur Gupta Eclipse JDT/UI Committer IBM India

The Environment Model

We d like to hear your suggestions for improving our indexes. Send to

CSCE 314 Programming Languages. Type System

MWorks: a Modern IDE for Modeling and Simulation of Multidomain Physical Systems Based on Modelica

LECTURE NOTES ON COMPILER DESIGN P a g e 2

Towards a model driven Modelica IDE

Lecture 12: Conditional Expressions and Local Binding

Programming Assignment 5 Interpreter and Static Analysis

Semantic actions for declarations and expressions

Programming in Visual Basic with Microsoft Visual Studio 2010

The role of semantic analysis in a compiler

SUDO(5) File Formats Manual SUDO(5)

SYED AMMAL ENGINEERING COLLEGE (An ISO 9001:2008 Certified Institution) Dr. E.M. Abdullah Campus, Ramanathapuram

Institutionen för datavetenskap Department of Computer and Information Science

Undergraduate Compilers in a Day

Semantic actions for declarations and expressions. Monday, September 28, 15

Comment- and Indentation Preserving Refactoring and Unparsing for Modelica

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, November 2017

A simple syntax-directed

DC69 C# &.NET DEC 2015

PlanAhead Release Notes

Hands-On Perl Scripting and CGI Programming

Transcription:

OpenModelica Compiler (OMC) Overview, Adrian Pop, Peter Aronsson OpenModelica Course at INRIA, 2006 06 08 1 OpenModelica Environment Architecture Eclipse Plugin Editor/Browser Emacs Editor/Browser Interactive session handler Graphical Model Editor/Browser Textual Model Editor DrModelica OMNoteBook Model Editor Execution Modelica Compiler Modelica Debugger 2

OpenModelica Compiler/Interpreter New version (1.4.0) released May 15, 2006 Currently implemented in 100 000 lines of MetaModelica Includes code generation, BLT-transformation, index reduction, connection to DASSL, etc. Most of the Modelica language including classes, functions, inheritance, modifications, import, etc. Hybrid/Discrete event support 3 Invoking OMC two Methods Calling OMC from the command line Calling OMC as a server via the Corba interface 4

Command Line Invokation of OMC omc file.mo Return flat Modelica by code flattening of the class in the file file.mo which is a the top of the instance hierarchy (toplevel class) omc file.mof Put the flat Modelica produced by flattening of the toplevel class within file.mo in the file named file.mof. omc file.mos Run the Modelica script file called file.mos. 5 Some General OMC Flags omc +s file.mo/.mof Generate simulation code for the model last in file.mo or file.mof. The following files are generated: modelname.cpp, modelname.h, modelname_init.txt, modelname.makefile. omc +q Quietly run the compiler, no output to stdout. omc +d=blt Perform BLT transformation of the equations. omc +d=interactive Run the compiler in interactive mode with Socket communication. This functionality is depreciated and is replaced by the newer Corba communication module, but still useful in some cases for debugging communication. This flag only works under Linux and Cygwin. omc +d=interactivecorba Run the compiler in interactive mode with Corba communication. This is the standard communication that is used for the interactive mode. 6

OpenModelica Client-Server Architecture OMC Server Including Compiler, Interpreter, etc. Parse Corba Client: Graphic Model Editor Client: OMShell Interactive Session Handler SCode Inst Ceval Interactive system Untyped API Typed Checked Command API plot etc. Client: Eclipse Plugin MDT 7 OMC Corba Client-Server API Simple text-based (string) communication in Modelica Syntax API supporting model structure query and update Example Calls: Calls fulfill the normal Modelica function call syntax.: savemodel("myresistorfile.mo",myresistor) will save the model MyResistor into the file MyResistorFile.mo. For creating new models it is most practical to send a model, e.g.: model Foo end Foo; or, e.g., connector Port end Port; 8

Some of the Corba API functions savemodel(a1<string>,a2<cref>) loadfile(a1<string>) loadmodel(a1<cref>) deleteclass(a1<cref>) addcomponent(a1<ident>,a2<cref>, A3<cref>,annotate=<expr>) deletecomponent(a1<ident>, A2<cref>) updatecomponent(a1<ident>, A2<cref>, A3<cref>,annotate=<expr>) addclassannotation(a1<cref>, annotate=<expr>) getcomponents(a1<cref>) getcomponentannotations(a1<cref>) getcomponentcount(a1<cref>) getnthcomponent(a1<cref>,a2<int>) getnthcomponentannotation( A1<cref>,A2<int>) getnthcomponentmodification( A1<cref>,A2<int>)?? getinheritancecount(a1<cref>) 9 getnthinheritedclass(a1<cref>, Saves the model (A2) in a file given by a string (A1). This call is also in typed API. Loads all models in the file. Also in typed API. Returns list of names of top level classes in the loaded files. Loads the model (A1) by looking up the correct file to load in $MODELICAPATH. Loads all models in that file into the symbol table. Deletes the class from the symbol table. Adds a component with name (A1), type (A2), and class (A3) as arguments. Optional annotations are given with the named argument annotate. Deletes a component (A1) within a class (A2). Updates an already existing component with name (A1), type (A2), and class (A3) as arguments. Optional annotations are given with the named argument annotate. Adds annotation given by A2( in the form annotate= classmod(...)) to the model definition referenced by A1. Should be used to add Icon Diagram and Documentation annotations. Returns a list of the component declarations within class A1: {{Atype,varidA, commenta },{Btype,varidB, commentb }, {...}} Returns a list {...} of all annotations of all components in A1, in the same order as the components, one annotation per component. Returns the number (as a string) of components in a class, e.g return 2 if there are 2 components. Returns the belonging class, component name and type name of the nth component of a class, e.g. A.B.C,R2,Resistor, where the first component is numbered 1. Returns the flattened annotation record of the nth component (A2) (the first is has no 1) within class/component A1. Consists of a comma separated string of 15 values, see Annotations in Section 2.4.4 below, e.g false,10,30,... Returns the modification of the nth component (A2) where the first has no 1) of class/component A1. Returns the number (as a string) of inherited classes of a class. Returns the type name of the nth inherited class of a class. The first class has number 1. Detailed Architecture of OMC (OpenModelica Compiler).mo Parse Data Type Modules: Absyn Types Main ClassLoader SCode DAE Absyn Prefix.Prefix Prefix SCode /explode SCode ClassInf.Event ClassInf.State ClassInf Exp.Exp (Env, name) Mod Lookup SCode.Class (Env, name) SCode.Exp Inst (Exp.Exp, Types.Type) Static Ceval Connect Types.Mod SCode.Mod Exp.Componentref Exp.Ident DAE DAE: Equations Algorithms Values.Value Exp.Exp DAE: Functions DAE Derive CodeGen Dump DAEEXT Exp.Exp DAELow Utility Modules: Dump Flat Modelica VarTransform DAE DAELow.DAELow SimCodeGen Debug DAE, substlist C code Algorithm Exp Builtin Util ModUtil Print System RTOpts 10

Three Kinds of Modules in OMC Function modules that perform a specified function, e.g. Lookup, code instantiation, etc. Data type modules that contain declarations of certain data types, e.g. Absyn that declares the abstract syntax. Utility modules that contain certain utility functions that can be called from any module, e.g. the Util module with list processing funtions. Note: Some modules perform more than one kind of function 11 Approximate Description The Main program calls a number of modules, including the parser (Parse), SCode, etc. The parser generates abstract syntax (Absyn) which is converted to the simplified (SCode) intermediate form. The model flattering module (Inst) is the most complex module, and calls many other modules. It calls Lookup to find a name in an environment, calls Prefix for analyzing prefixes in qualified variable designators (components), calls Mod for modifier analysis and Connect for connect equation analys. It also generates the DAE equation representation which is simplified by DAELow and fed to the SimCodeGen and CodeGen code generators The Ceval module performs compile-time or interactive expression evaluation and returns values. The Static module performs static semantics and type checking. The DAELow module performs BLT sorting and index reduction. The DAE module internally uses Exp.Exp, Types.Type and Algorithm.Algorithm; the SCode module internally uses Absyn The Vartransform module called from DAELow performs variable substitution during the symbolic transformation phase (BLT and index reduction). 12

Short Overview of OMC Modules (A-D) Absyn Abstract Syntax Algorithm Data Types and Functions for Algorithm Sections Builtin Builtin Types and Variables Ceval Evaluation/interpretation of Expressions. ClassInf Inference and check of class restrictions for restricted classes. ClassLoader Loading of Classes from $MODELICAPATH Codegen Generate C Code from functions in DAE representation. Connect Connection Set Management Corba Modelica Compiler Corba Communication Module 13 Short Overview of OMC Modules (D-G) DAE DAE Equation Management and Output DAEEXT External Utility Functions for DAE Management DAELow Lower Level DAE Using Sparse Matrises for BLT Debug Trace Printing Used for Debugging Derive Differentiation of Equations from DAELow Dump Abstract Syntax Unparsing/Printing DumpGraphviz Dump Info for Graph visualization of AST Env Environment Management Exp Typed Expressions after Static Analysis /*updated) Graphviz Graph Visualization from Textual Representation 14

Short Overview of OMC Modules (I-P) Inst Flattening of Modelica Models Interactive Model management and expression evaluation Keeps interactive symbol tables. Contains High performance API, etc. Lookup Lookup of Classes, Variables, etc. Main The Main Program. Calls Interactive, the Parser, the Compiler, etc. Mod Modification Handling ModSim /*Depreciated, not used). Previously communication for Simulation, Plotting, etc. ModUtil Modelica Related Utility Functions Parse Parse Modelica or Commands into Abstract Syntax Prefix Handling Prefixes in Variable Names Print Buffered Printing to Files and Error Message Printing 15 Short Overview of OMC Modules (R-V) SCode Simple Lower Level Intermediate Code Representation. SimCodegen Generate simulation code for solver from equations and algorithm sections in DAE. Socket (Partly Depreciated) OpenModelica Socket Communication Static Static Semantic Analysis of Expressions System System Calls and Utility Functions TaskGraph Building Task Graphs from Expressions and Systems of Equations. Optional module. TaskGraphExt External Representation of Task Graphs. Optional module. Types Representation of Types and Type System Info Util General Utility Functions Values Representation of Evaluated Expression Values VarTransform Binary Tree Representation of Variable Transformations 16