khoborerkagoj / inc Goto Github PK
View Code? Open in Web Editor NEWThis project forked from namin/inc
an incremental approach to compiler construction
License: MIT License
This project forked from namin/inc
an incremental approach to compiler construction
License: MIT License
(Originated in step5).
It is possible that we encounter an expression like (fx+ 3 4)
which can be evaluated at compile time to simply emit
mov eax, 7 ; actually 28 because of fixnum representation
For now, we generate the code
mov eax, 3 ; actually 12 (fixnum)
add eax, 4 ; actually 16 (fixnum)
It is best to keep it the way it is for now (so the compiler code is exercised), but when the compiler code is mature, this can be added as an optimization.
From step2: It would be nice to have a return type for primitives, as also an "acceptable" type. For instance,
(emit-program '(fxadd1 (boolean? 32)))
does not make sense, as fxadd1
should only accept fixnums. If boolean?
advertised itself as returning a
boolean, and fxadd1
advertised itself as only accepting a boolean, we could check for this and throw an error at compile time.
From the tutorial exercise 1.4.3:
Consider the expression (if (fx> 3 4) (fxadd1 3) (fxlognot 5))
:
fx>
first compares it arguments, generates 0 or 1, and then returns #t
or #f
depending on the result.
if
then evaluates the result, compares to #f
, and then decides what to do.
The fix would be to have a different definition of emit-expr
which would just generate 1 or 0 as the result of the boolean expression. This alternate form would be called only from the test expression of an if
, so would not affect results. This would save us in the creation of the boolean.
The standard usage of scheme_entry is that it saves the callee's stack (the stack of the C main()
function) in ECX before resetting the stack to the Scheme stack. On return from Scheme (the L_scheme_entry
function), ESP is reset from the saved value in ECX.
However, this means that ECX is not available to the code we generate. One possibility would be to:
push
instruction will both do this and update ESP.Windows conventions for 32 bit dictate that we can trash EAX, ECX and EDX within a function call; other registers must be saved and restored before returning.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.