Questions tagged [program-transformation]

A program transformation is (a usually mechanical) process to modify one program to produce another.

A program transformation is any process that converts a program into another program. They are used to optimize programs, or to translate them to other languages, or to make mass changes to support evolution.

That process may be a manual process, but generally are thought of as automated actions. These actions can be implemented procedurally (as is the case with most compilers and code generators) or with source-to-source transformations, which use pairs of source code patterns to describe the before and after states of code fragments.

Program transformation includes the following as special cases: refactoring, aspect-oriented programming, code generation and compilation.

22 questions
45
votes
11 answers

Converting C source to C++

How would you go about converting a reasonably large (>300K), fairly mature C codebase to C++? The kind of C I have in mind is split into files roughly corresponding to modules (i.e. less granular than a typical OO class-based decomposition), using…
Barry Kelly
  • 41,404
  • 5
  • 117
  • 189
40
votes
4 answers

What is an AST transformation?

What is an AST transformation in general? I came across these words when reading Groovy blog's. But what it is in general?
Aravinth
  • 401
  • 1
  • 4
  • 3
38
votes
2 answers

What is tail-recursion elimination?

Steve Yegge mentioned it in a blog post and I have no idea what it means, could someone fill me in? Is it the same thing as tail call optimization?
12
votes
3 answers

Is there command-line tool to extract typedef, structure, enumeration, variable, function from a C or C++ file?

I am desiring a command-line tool to extract a definition or declaration (typedef, structure, enumeration, variable, or function) from a C or C++ source file. Also a way to replace an existing definition/declaration would be handy (after…
FooF
  • 4,323
  • 2
  • 31
  • 47
11
votes
0 answers

floating pass of fully lazy lambda lifting?

I'm reading implementing functional languages: a tutorial, and encountered a problem when implementing floating pass of fully lazy lambda lifting. I would like to describe how floating works to make this question clear, if you are familiar with it,…
8
votes
4 answers

Is there any formal definition for "refactoring"?

Anyone knows a way to define refactoring in a more formal way? UPDATE. A refactoring is a pair R = (pre; T) where pre is the precondition that the program must satisfy, and T is the program transformation.
jaircazarin-old-account
  • 2,875
  • 3
  • 20
  • 17
8
votes
3 answers

Parallel Dynamic Programming

Are there any good papers discussing how to take a dynamic program and parallelize it?
adk
  • 4,479
  • 9
  • 36
  • 38
4
votes
6 answers

How to automatically remove methods in java code

I need to remove some methods in a large java project and I was wondering if there are tools that would help me do so. I would basically specify a signature and a source folder in which all the matching method would be removed. It no such thing…
RaySF
  • 1,289
  • 1
  • 9
  • 17
4
votes
1 answer

Reassociation according to Muchnick

I’m reading Muchnick’s “Advanced Compiler Design & Implementation”, where Fig 12.6 lists 20 transformation rules which, if applied in order, do constant folding and reassociation to move constants together. The rules (leaving out distributitvity…
3
votes
1 answer

Tail recursion fibonacci derived from linear recursive version using Burstall & Darlington's folding/unfolding system

The inefficient (tree-recursive) fib(n) function calculates the n-th Fibonacci number. In Haskell: fib 0 = 0 fib 1 = 1 fib n = fib (n - 1) + fib (n - 2) Using the following identity: gfib(n) = (fib(n), fib(n+1)) we could synthesize a linear…
3
votes
5 answers

Any C compiler with C output?

We all know that C compilers spit out assembly. However I am doing research where my tool only accepts a narrow subset of ANSI C. Is there any C-to-C translators out there that can inline functions or flatten struct's, but writes out C code? Any…
eisbaw
  • 2,678
  • 2
  • 19
  • 18
3
votes
1 answer

Stratego/XT: Understanding the basic of basics

I have really tried to get my head around the first steps of understanding Stratego/XT. I've googled a lot and all the web resources I have found seem to make a large enough leap at the beginning that I just can't make the connection. Let me…
Sam Washburn
  • 1,817
  • 3
  • 25
  • 43
2
votes
2 answers

Is there any language to specify automatic code modifications?

I'm doing some work where I need to be able to describe modifications to some program code that are to be done automatically. Is there any language that allows to describe this? The language should have modules or functions that receive the location…
Francisco Vieira
  • 196
  • 1
  • 10
2
votes
1 answer

Inserting extra lines of code using Antlr4

The target is to insert codes to monitor the entry and exit of Java synchronized block. i.e. enteringSync(); synchronized(lockObj){ enteredSync(); ... leavingSync(); } leftSync(); My original thought was to implement the enter/exit listener…
1
vote
2 answers

Running generated ARM machine code on Android gives UnsupportedOperationException with Java Bitmap objects

We ( http://www.mosync.com ) have compiled our ARM recompiler with the Android NDK which takes our internal byte code and generates ARM machine code. When executing recompiled code we see an enormous increase in performance, with one small…
1
2