compiler

What is the technique behind the code generation feature of UML tools

Hello everyone. I am an engineering student, and deciding upon my final year project. One of the many candidates is an online UML tool with code generation facilities. But I did not take compiler designing classes, so I am not much aware of the code generation techniques. I want to know about the techniques that I should look to stud...

What is the performance penalty if any for a large .maxstack?

I'm working on writing a compiler and one feature of this compiler is that it automatically generates GetHashCode(), Equals(object), and Equals({this value type}) methods for value types. Right now the Equals({this value type}) implementation basically generates il equivalent to the il generated by this c#: public bool Equals(ThisType o...

Language literal support

Are there any languages that support easily extending the compiler to support new literals example such as for json/xml/yaml/different string encodings/extra number types. I understand that you can always fork the compiler, write a dsl but that's not quite what I'm asking about. I understand that some languages such as smalltalk and lisp...

gcc 4.3.3 compiler options enabled by default

I have moved from gcc version 4.0.3 to 4.3.3 and realized that -mfpmath was set to sse by default in gcc 4.3.3. This actually caused errors in my application. In 4.0.3 the -mfpmath was 387. I want to know how I can get all the default options enabled by gcc for a given version. How can I dump set of all options used by gcc while compil...

Linker error (only simulator) with own library after update to iPhone SDK 4.0

Hey all, I recently updated to iPhone SDK 4.0 and are no longer able to build my project for the iPhone simulator. The problem is that classes of one of my own libraries can no longer be found by ld: "_OBJC_CLASS_$_Book", referenced from: objc-class-ref-to-Book in Category.o (maybe you meant: ...) ld: symbol(s) not found collect2...

porting vb6 app to VS2008 vb.net - make compiler flag unitialized form's private variable as error

I can make the compiler give me an error (Use of variable prior to assignment) with: private sub Test() Dim ord As Order Dim ord2 As Order ord2 = ord end sub but not with: Friend Class frmReceiving ... Private mobjOrder As Order ... private sub Testing() Dim ord2 As Order ord2 = mobjOrder end sub How can I make ...

Problem With Setting Compiler Flags

I'm trying to configure my cross compiler (mipseb-linux-g++) to generate binaries with the MIPSI ISA. There is a flag for this "-mips1". I have this flag in my make file and for some reason g++ is still generating MIPSII instructions (which I assume is default?). Am I doing anything wrong? Here's my process flow: write c++ program ...

Why compilers creates one variable "twice"?

Hi, I know this is more "heavy" question, but I think its interesting too. It was part of my previous questions about compiler functions, but back than I explained it very badly, and many answered just my first question, so ther it is: So, if my knowledge is correct, modern Windows systems use paging as a way to switch tasks and secure ...

Strange (possibly wrong?) C# compiler behavior with method overloading and enums

Hi, today I discovered a very strange behavior with C# function overloading. The problem occurs when I have a method with 2 overloads, one accepting Object and the other accepting Enum of any type. When I pass 0 as parameter, the Enum version of the method is called. When I use any other integer value, the Object version is called. I kno...

get compile timestamp iphone sdk

How can i get the timestamp of when an application was compiled for iphone At the moment I've got this method on my app delegate - (NSDate*) compiledAt { NSDateFormatter *k= [[NSDateFormatter alloc] init]; [k setDateFormat:@"MMM d yyyy HH:mm:ss"] ; NSString *dateString = [[[NSString stringWithUTF8String:__DATE__] stringByAp...

Strange decompiled code from event subscribe code in a generic class

This simple class public class Test<T> { public static void A(Window wa, Window wb) { wa.Closed += (s, e) => wb.Close(); } } Gets compiled to this (I'm using Reflector to decompile) : public class Test<T> { [CompilerGenerated] private sealed class <>c__DisplayClass1 { public Window wb; ...

How to get pointers and sizes of variables from the compiler - from outside the compiled code?

I'd like the compiler to output a file containing the pointers to all global variables in the source code it is compiling, and also the sizes of them. Is this possible? Is there a way to do it in any c compiler? ...

Compiler Generated GetHashCode()

I'm working on writing a compiler for a language running on .net and one of the things I would like it to do is to automatically generate the GetHashCode method, but I have several questions: Is this possible, does the compiler know enough about the type(s) involved to do a reasonable job implementing the method? Should I do this for v...

VC++ compilation time and performance

Hi Folks, I'm working on a multiplaform project (MacOS, Linux and Windows) and I've been having some performance issues when trying to compile a big source file in VS C++ 2010. Here's a little background. There's one .cpp file inside the project that is 800KB big. The size of the file is caused by the fact that I'm compiling an array t...

How to disable dead code elimination in the Java compiler?

This may seem a strange question... Why would anyone want to disable such a thing? But I know what I'm doing (and why I want/need to do this) and I really want to disable dead code elimination. Is it possible somehow? I use Eclipse by the way, if it's relevant... ...

Intentional compiler warnings for Visual C++ that appear in Error List?

How can you create a compiler warning (in the model of #error, except as a warning) on purpose in Visual C++ that will show up on the Error List with the correct file and line number? GCC and other compilers offer #warning, but the MSVC compiler does not. The "solution" at http://support.microsoft.com/kb/155196 does not parse in the Vi...

Make macros and functions integrate more seamlessly

OK, I understand pretty well how to use both function and macros. What I'm curious about is why the compiler can't be a bit more clever when integrating the two, e.g. consider the Clojure code: (defmacro wonky-add [a b] `(+ ~a (* 2 ~b))) (defn wonky-increment [a] (apply wonky-add a 1)) => Error: can't take value of a macro Yes, I kn...

Variable name 'xor' results in internal compiler error 'segmentation fault'!

Compiling this code int main(int argc, char **argv) { int xor = 0; } via g++ main.cpp results in: internal compiler error: Segmentation fault with i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5659). Renaming the variable removes the error. Question: Is gcc from Apple crap? ...

How to compile facelets?

Many times I had errors like: -tag is not closed(xml error) -xhtml has duplicated id Id like to write validator to check is those errors exist in files. I bet there is some facelets compiler that compile xhtml into java classes and than validates it. ...

Python library for experimenting with compiler optimizations

I want to learn about compilers and some optimization techniques, and I thought it would be helpful to do some quick implementations of the algorithms. Is there a library/framework for Python that can make things easier (like the Natural Language Toolkit) - generating the parse tree, manipulating loops, methods? I saw that Microsoft...