compiler-construction

Using the TypeScript type checker to see if two types are assignable

做~自己de王妃 提交于 2020-05-09 04:51:25
问题 I'm building a small script that scans for all interfaces that have a member of a given type using the TypeScript Compiler API, of which the source can be found here. I inspect the members of these classes to see how they are interlinked. My question is: how do I know when a type is assignable to another type? I searched the TypeChecker for a method but I couldn't find one. Does anyone by any chance have any pointers? Here's an example of something that should be able to get analysed: export

Using the TypeScript type checker to see if two types are assignable

偶尔善良 提交于 2020-05-09 04:51:10
问题 I'm building a small script that scans for all interfaces that have a member of a given type using the TypeScript Compiler API, of which the source can be found here. I inspect the members of these classes to see how they are interlinked. My question is: how do I know when a type is assignable to another type? I searched the TypeChecker for a method but I couldn't find one. Does anyone by any chance have any pointers? Here's an example of something that should be able to get analysed: export

Sum types - Why in Haskell is `show (Int | Double)` different than `(show Int) | (show Double)`

末鹿安然 提交于 2020-04-12 09:57:06
问题 Why are these not equivalent? show $ if someCondition then someInt else some double and if someCondition then show someInt else show someDouble I understand that if you isolate the if ... else part in the first example to an expression by itself then you can't represent its type with an anonymous sum type, the kind of Int | Double , like something you could do easily in TypeScript (mentioning TypeScript because it is the langauge I used often and that supports Sum types), and would have to

How to get Register-Transfer-Language (RTL) Code from C and JAVA Code?

余生颓废 提交于 2020-04-10 04:46:14
问题 When any compiler like GCC compiles a C Program it generates intermediate code. Just like we can get Assembly code by applying -s option to any .c file, similarly I want to get Register-Transfer-Language (RTL) for C and JAVA file . How to get it ? 回答1: The three adress code is called gimple, see e.g. https://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html but this seems more frontend-backend communication, it can be dumped using gcc -fdump-tree-gimple <file> See http://www.cse.iitb.ac.in/~uday

Java: Is method name/signature resolution done statically (compile-time)?

余生长醉 提交于 2020-04-10 04:17:29
问题 I encountered an interesting problem today which I thought was not possible in Java. I compiled my java code against version 2.6 of jgroups but used version 2.12 at runtime (tomcat web app deployment). I got the following error org.jgroups.Message.<init>(Lorg/jgroups/Address;Lorg/jgroups/Address;Ljava/io/Serializable;) Assuming that the API would have change since then, I thought of porting my code to jgroups-2.12, but to my surprise the code compiled fine with jgroups-2.12 and when I

What is the difference between make and gcc?

こ雲淡風輕ζ 提交于 2020-04-07 12:07:08
问题 The last sentence in the article caught my eye [F]or C/C++ developers and students interested in learning to program in C/C++ rather than users of Linux. This is because the compiling of source code is made simple in GNU/Linux by the use of the 'make' command. I have always used gcc to compile my C/C++ programs, whereas javac to compile my Java programs. I have only used make to install programs to my computer by configure/make/make install. It seems that you can compile apparently all your

What is the difference between make and gcc?

我只是一个虾纸丫 提交于 2020-04-07 12:06:48
问题 The last sentence in the article caught my eye [F]or C/C++ developers and students interested in learning to program in C/C++ rather than users of Linux. This is because the compiling of source code is made simple in GNU/Linux by the use of the 'make' command. I have always used gcc to compile my C/C++ programs, whereas javac to compile my Java programs. I have only used make to install programs to my computer by configure/make/make install. It seems that you can compile apparently all your

How to extend a ELF binary

两盒软妹~` 提交于 2020-03-28 03:56:53
问题 I am writing a small instrumentation tool. I must insert the instrumentation routine within the binary file. A good approach should be to insert those routines in a separate code segment and a separate data segment, could you explain how to accomplish this? Furthemore how can I modify the size of the code segment in the original file? Best, 回答1: I must insert the instrumentation routine within the binary file. A good approach should be to insert those routines in a separate code segment and a

How to extend a ELF binary

有些话、适合烂在心里 提交于 2020-03-28 03:55:00
问题 I am writing a small instrumentation tool. I must insert the instrumentation routine within the binary file. A good approach should be to insert those routines in a separate code segment and a separate data segment, could you explain how to accomplish this? Furthemore how can I modify the size of the code segment in the original file? Best, 回答1: I must insert the instrumentation routine within the binary file. A good approach should be to insert those routines in a separate code segment and a

Compile Java in Xcode 4

风流意气都作罢 提交于 2020-03-17 06:04:07
问题 I know that this question has been floating around for ages now ... Java in Xcode 4 . I don't need any recommendations (Eclipse, Netbeans e.g.) I just want to compile some simple Java Code in "XCode4" (not 3). I managed to create a File and as expected the syntax and everything works but the Compiler due to the missing Scheme. I am kinda stuck at the executable. My Question is: Is it possible to do that? 回答1: Is it possible to do that? YES this is possible. 1) File > New > New Project > Other