RUS  ENG
Full version
JOURNALS // Modelirovanie i Analiz Informatsionnykh Sistem // Archive

Model. Anal. Inform. Sist., 2022 Volume 29, Number 3, Pages 246–264 (Mi mais779)

This article is cited in 1 paper

Theory of computing

Transformation of C programming language memory model into object-oriented representation of EO language

A. I. Legalova, Y. G. Bugayenkob, N. K. Chuykina, M. V. Shipitsinc, Ya. I. Riabtseva, A. N. Kamenskiya

a National Research University Higher School of Economics, 20, Myasnitskaya str., Moscow 101000, Russia
b Huawei Russian Research Institute, 7-9, Smolenskaya sq., Moscow 121099, Russia
c ITMO University, 49 bldg. A, Kronverksky Pr., St. Petersburg 197101, Russia

Abstract: The paper analyzes the possibilities of transforming C programming language constructs into objects of EO programming language. The key challenge of the method is the transpilation from a system programming language into a language of a higher level of abstraction, which doesn't allow direct manipulations with computer memory. Almost all application and domain-oriented programming languages disable such direct access to memory. Operations that need to be supported in this case include the use of dereferenced pointers, the imposition of data of different types in the same memory area, and different interpretation of the same data which is located in the same memory address space. A decision was made to create additional EO-objects that directly simulate the interaction with computer memory as in C language. These objects encapsulate unreliable data operations which use pointers. An abstract memory object was proposed for simulating the capabilities of C language to provide interaction with computer memory. The memory object is essentially an array of bytes. It is possible to write into memory and read from memory at a given index. The number of bytes read or written depends on which object is being used. The transformation of various C language constructs into EO code is considered at the level of the compilation unit. To study the variants and analyze the results a transpiler was developed that provides necessary transformations. It is implemented on the basis of Clang, which forms an abstract syntax tree. This tree is processed using LibTooling and LibASTMatchers libraries. As a result of compiling a C program, code in EO language is generated. The considered approach turns out to be appropriate for solving different problems. One of such problems is static code analysis. Such solutions make it possible to isolate low-level code fragments into separate program objects, focusing on their study and possible transformations into more reliable code.

Keywords: program transformation, procedural programming, object-oriented programming, transpilation, compilation, programming languages.

UDC: 004.4’4

MSC: 68N15, 68Q10, 68N20

Received: 07.08.2022
Revised: 01.09.2022
Accepted: 02.09.2022

DOI: 10.18255/1818-1015-2022-3-246-264



© Steklov Math. Inst. of RAS, 2024