-
Notifications
You must be signed in to change notification settings - Fork 0
Generator
/crackono.sh edited this page Dec 8, 2020
·
6 revisions
Code generator's functions are called from parser when specific criterion is met and it generates IFJcode20 code depending on what we are currently generating and it sends it to stdout
. If everything were generated correctly we are able to send it to interpreter (which was written by our dear professors) and run it.
- GenerateHeader - generates header required by ic20int and jump to main function
- GenerateFunction - generates beginning of function or entire function code if it's internal function (if internal, label starts with
_
, otherwise$
) - GenerateFuncArguments - generates function's arguments and pops them from stack
- GenerateFuncCall - generates call for specified function
- GenerateFuncReturn - generates pushes of return values to stack
- GenerateFuncEnd - generates end of function (return to last instruction and frame pop)
- GenerateDefinitions - generates definition of variable
- GenerateAssignments - generates variable's assignment
- GeneratorPrint - generates internal function for printing, outputs 1 argument to
stdout
- GenerateIfScope - generates
if
,else if
,else
scope - GenerateForBeginning - generates counter variable definition
- GenerateForExpression - generates assignment + expression of
for
loop - GenerateForCondition - generates condition for ending
for
loop - GenerateForAssignment - generates label of
for
assignment - GenerateForAssignmentEnd - generates jump to
for
expression (after assignment is done) - GenerateForScope - generates beginning of
for
loop scope - GenerateForScopeEnd - generates end of
for
loop scope - IgnoreIfScope - determines whether
if
,else if
orelse
scope will be ignored and not generated - GeneratorSaveID - adds identifier to end of list for definition or assignment
- GeneratorGetID - gets last added identifier
- GenerateUsedInternalFunctions - generates used internal functions (if none, don't generate)
- GeneratorPrintCheck - check that printArguments is true, if so pop + print the value to stdout, otherwise do nothing
- GenerateCodeInternal - generates internal code (internal function code, header)
- SetUpCodeInternal - sets up code variable for generating internal function code
- IsFuncInternal - checks that given name is really internal function
In contrast with scanner or parser we don't call just one function here, which would then proceed to call other functions, but we have to call corresponding function to where we are currently in parser and what we need to generate. For that function names should be great indicator for what to use.
- Dominik Horky
- @horsecz ([email protected])
- Roman Janiczek
- @theleteron ([email protected])
- Lukas Hais
- @crackonosh ([email protected])
- Jan Pospisil
- @zelick0 ([email protected])