Skip to content
This repository has been archived by the owner on Feb 14, 2021. It is now read-only.

Compiler finished #48

Open
wants to merge 353 commits into
base: entrega-final
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
353 commits
Select commit Hold shift + click to select a range
67b9692
adding first CIL AST Nodes, visitor class for teh creation of Types, …
ginrod Oct 8, 2020
6e5e2bf
including cil visitors objects in the build_cil_ast logic, renaming p…
ginrod Oct 8, 2020
bfb34ea
getting context from semantic_analyzer
ginrod Oct 8, 2020
0f5c708
importing semantic_analyzer
ginrod Oct 8, 2020
287b686
fixing run-time errors in ast_nodes.py and syntax errors in cil relat…
ginrod Oct 8, 2020
0427054
adding get_all_methods function
ginrod Oct 8, 2020
fe23c4d
returning context in SemanticaAnalyzer.analize
ginrod Oct 8, 2020
9983e80
returning type name in get all methods to can identify type.method an…
ginrod Oct 8, 2020
f795e44
creating cil_ast Program node and passing it to CIL visitors classes
ginrod Oct 8, 2020
11a407f
moving global definition buil_cil_ast to the top of the script, passi…
ginrod Oct 8, 2020
58c07ac
fixing CIL visit calls, adding first node visit
ginrod Oct 8, 2020
80fecff
creating Type section nodes
ginrod Oct 8, 2020
7fdb135
setting string representation for CIL nodes, printing by console and …
ginrod Oct 9, 2020
4f6675e
open file always in just as write mode
ginrod Oct 9, 2020
ae9e8cd
completing cil DATA section mapping
ginrod Oct 9, 2020
f855883
creating CIL Attribute node with COOL Attribute name
ginrod Oct 9, 2020
36a74cf
adding all CIL nodes
ginrod Oct 11, 2020
11f7a86
correctly computing simple expressions
ginrod Oct 11, 2020
9524e5f
finishing some infrastructure code for mapping form COOL to CIL
ginrod Oct 12, 2020
3d575f5
Merge branch 'cool-to-cil'
ginrod Oct 21, 2020
11e0305
build CIL entry function
ginrod Oct 21, 2020
c10d994
remove foo bar variables, append ALLOCATE before SETATTR
ginrod Oct 21, 2020
e74a22d
Merge branch 'add-entry-func'
ginrod Oct 23, 2020
a809835
setting atrr after allocation
ginrod Oct 23, 2020
bea8063
fixing names format
ginrod Oct 23, 2020
bfbc16b
remove reapeted lcoals in block declaration
ginrod Oct 23, 2020
19cf382
Merge branch 'set-attr'
ginrod Oct 24, 2020
14f2844
visiting Args expressions and getting expr_value
ginrod Oct 24, 2020
d18f9b2
Merge branch 'fix-args'
ginrod Oct 24, 2020
45b35dc
Merge branch 'master' of https://github.com/dayanyalfaro/cool-compile…
Oct 25, 2020
a013fbf
Print .CODE cil section
DalyPerez Oct 26, 2020
4dc02e8
Print .TYPES section without builtin types
DalyPerez Oct 26, 2020
7777b8e
Print builtin types in .TYPES section donde
DalyPerez Oct 26, 2020
5f3e627
add empty nodes to cool-to-cil visitor
DalyPerez Oct 26, 2020
b850849
Merge branch 'master' of https://github.com/dayanyalfaro/cool-compile…
Oct 26, 2020
ef5e179
Add label gen
DalyPerez Oct 27, 2020
686413a
If cool node visited in CIL ast
DalyPerez Oct 27, 2020
6ef635a
Equals node visited
DalyPerez Oct 27, 2020
11799f8
all bynary and unary operators visited, DONE
DalyPerez Oct 27, 2020
b694110
Remove VariableInfo from define_internal_local
DalyPerez Oct 27, 2020
31fd09b
Fix node Identifier with GettAttr
DalyPerez Oct 27, 2020
b68aa59
Add SetAttr cil node
DalyPerez Oct 27, 2020
bdec425
visit node While donde
DalyPerez Oct 27, 2020
1b60923
NewType node visited
DalyPerez Oct 28, 2020
3ddcc9a
Merge branch 'master' of https://github.com/dayanyalfaro/cool-compile…
Oct 29, 2020
18b098d
Merge pull request #33 from dayanyalfaro/daly-cool-to-cil
dayanyalfaro Oct 29, 2020
756bac8
add init function to cil
Oct 29, 2020
6c883b0
recursive calls to init parents
Oct 29, 2020
623183c
builtin methods to cil except object copy
Oct 29, 2020
30349d7
adding printing nodes
Oct 29, 2020
b2939c1
Merge branch 'testsDaniel' of https://github.com/matcom/cool-compiler…
ginrod Oct 29, 2020
22ca30d
Merge branch 'master' of https://github.com/dayanyalfaro/cool-compile…
Oct 29, 2020
e815382
add init function to cil
Oct 29, 2020
a8a68cc
recursive calls to init parents
Oct 29, 2020
1ef02ce
running semantic_analyzer in coolc.sh
ginrod Oct 29, 2020
256aea6
executing exit(1) after the first semantic error
ginrod Oct 29, 2020
7582a2c
Merge branch 'fix-semantics' of https://github.com/dayanyalfaro/cool-…
Oct 29, 2020
cef3cc0
only inheritance tests failing
Oct 30, 2020
2d0c715
semantic tests passed
Oct 30, 2020
ec484b5
Merge pull request #38 from dayanyalfaro/fix-semantics
dayanyalfaro Oct 30, 2020
f9124d1
Merge pull request #35 from dayanyalfaro/class-init
dayanyalfaro Oct 30, 2020
08a4342
Merge pull request #36 from dayanyalfaro/builtin-code
dayanyalfaro Oct 30, 2020
56a0e1c
node StaticCall visited
DalyPerez Oct 28, 2020
27cf1d0
node DynamicCall visited
DalyPerez Oct 28, 2020
bc4f6c7
delete labels register
DalyPerez Oct 29, 2020
be8ff22
change attrs and methods type list in cil Type node for dicts
DalyPerez Oct 29, 2020
6af920f
rename all attrs and methods in cil Types definition
DalyPerez Oct 29, 2020
3b8bd15
add scope for declare all locals and variables, visited Let node
DalyPerez Oct 30, 2020
ca2572a
fix the name of the local var in visit LetDef
DalyPerez Oct 30, 2020
e442282
Merge branch 'daly-cool-to-cil'
ginrod Oct 31, 2020
be59b79
adding infrastructure
ginrod Oct 30, 2020
4bd9bc3
setting more infrastructure, generating MIPS for constants (INTEGER o…
ginrod Oct 30, 2020
3bcfa5e
adding mul and div
ginrod Oct 30, 2020
1654a36
adding commas between CIL command parameters
ginrod Oct 30, 2020
a7b73f7
remove unused files and reference, fix some bugs
ginrod Oct 30, 2020
9b9ade1
fix some errors, adding an Allocate preview
ginrod Oct 31, 2020
3920c14
Merge branch 'add-sub-mips'
ginrod Oct 31, 2020
c17bf22
Fix register-builtin-types and visit to Identifier node
DalyPerez Oct 31, 2020
1868777
Add visit to cool node IsVoid
DalyPerez Oct 31, 2020
ffea7ea
rename CoolToCilVisitor
DalyPerez Oct 31, 2020
0a5d7a3
fix visit Class node
DalyPerez Oct 31, 2020
fa835cd
fix Int, String and Bool node
DalyPerez Oct 31, 2020
6c7c737
Update travis.yml
danielgpz Oct 30, 2020
360f57d
Add basic types tests
danielgpz Oct 30, 2020
650a7f8
New arithmetic tests
danielgpz Oct 31, 2020
0026086
Add new case tests
danielgpz Oct 31, 2020
00fa0ca
Add new type tests
danielgpz Oct 31, 2020
f36d7c0
Merge branch 'fetch-tests'
ginrod Nov 1, 2020
10f0ac5
new semantic tests passed
Nov 1, 2020
8eddb64
function cil to mips
Oct 31, 2020
773d3af
Merge pull request #42 from dayanyalfaro/cil-function
dayanyalfaro Nov 1, 2020
cbe83cc
print cil without builtin registers
DalyPerez Nov 1, 2020
7d0bf22
Add print Cil Copy node
DalyPerez Nov 1, 2020
47cdaf5
Compiled test
DalyPerez Nov 1, 2020
c606f44
print cil without builtin registers
DalyPerez Nov 1, 2020
45fe00f
Add print Cil Copy node
DalyPerez Nov 1, 2020
2dd5e53
Compiled test
DalyPerez Nov 1, 2020
624b925
Merge pull request #43 from dayanyalfaro/test-cil
dayanyalfaro Nov 1, 2020
68670ce
method and attributes names changed
Nov 1, 2020
721d408
mips allocate objects
Nov 1, 2020
e2c011f
add init to class methods
Nov 1, 2020
d00c1b1
Merge pull request #44 from dayanyalfaro/cil-dottypes-changes
dayanyalfaro Nov 1, 2020
ca7cadf
small fix in mips syntax
Nov 1, 2020
e2ec346
Merge branch 'test-cil' of https://github.com/dayanyalfaro/cool-compi…
DalyPerez Nov 2, 2020
d73fe40
Merge branch 'master' into test-cil
DalyPerez Nov 2, 2020
33fee50
fix cil params names
DalyPerez Nov 2, 2020
a8f04ce
mips getattr setattr
Nov 2, 2020
22aac6c
Merge pull request #45 from dayanyalfaro/mips-attributes
dayanyalfaro Nov 2, 2020
f8c1b19
performing binary operations
ginrod Nov 2, 2020
33e4b57
removing foo var, checking vars in locals and parameters
ginrod Nov 2, 2020
bee87a3
saving binary operation result into corresponding local offset
ginrod Nov 2, 2020
e33bfea
fix CIL to MIPS Assign visit
ginrod Nov 2, 2020
36ac3c5
Merge branch 'add-binary-op'
ginrod Nov 2, 2020
d5bf014
visit args inside vcall, same search_offset for locals and params
Nov 2, 2020
c55f4dc
add computed_type to expr in ast for dynamic dispatch
Nov 2, 2020
6efb251
dispatch done
Nov 2, 2020
ad86961
delete locals and params disambiguation
Nov 2, 2020
e186af8
Merge pull request #47 from dayanyalfaro/mips-function-calls
dayanyalfaro Nov 3, 2020
2b3ca0f
writing IfGoto visit
ginrod Nov 3, 2020
49fd3d8
visiting Goto and Label nodes, fixing Assign visit
ginrod Nov 3, 2020
51dd807
remove duplicate code
ginrod Nov 3, 2020
78b8173
Merge branch 'if-else-cgen'
ginrod Nov 3, 2020
23c9103
add Print_int mips
DalyPerez Nov 3, 2020
59b0fd8
add print_string mips
DalyPerez Nov 3, 2020
aea964b
create dicts for all offsets
DalyPerez Nov 3, 2020
68e4632
add compare instruction to the dict of binary-op
DalyPerez Nov 3, 2020
03f3977
visit Cil UnaryOp node
DalyPerez Nov 3, 2020
92fa18d
read integer donde in mips
DalyPerez Nov 3, 2020
1171485
Merge pull request #51 from dayanyalfaro/mips-print
DalyPerez Nov 3, 2020
35b2199
merge done
DalyPerez Nov 3, 2020
f00c88e
adapt builtin types to be references
Nov 3, 2020
4281ad8
Merge pull request #50 from dayanyalfaro/builtin-by-reference
dayanyalfaro Nov 3, 2020
89edfd3
some bugs fixed
DalyPerez Nov 4, 2020
d2bd296
add load nodes to cil and mips
Nov 5, 2020
9b19507
add halt in mips
Nov 5, 2020
9ae5bb3
add typeof node in mips
Nov 5, 2020
16911c3
add void behavior
Nov 5, 2020
e042c09
small fixes
Nov 5, 2020
394bc6f
add .cil and .s to gitignore
Nov 5, 2020
c682f84
Merge pull request #52 from dayanyalfaro/cil-load-int
dayanyalfaro Nov 5, 2020
80e9f35
multiply allocate space by 4 and reverse args in builtins init
Nov 6, 2020
ab9438a
Getting atrr in all Bianry operations but equals
ginrod Nov 7, 2020
5ca84f8
getting atrr in UnaryOperator expressions
ginrod Nov 7, 2020
9fa5b9e
returning instance of Bool or Int in arithmetics and comparison opera…
ginrod Nov 7, 2020
3e9b38a
in Equals GetAtrr for Int and Bool types
ginrod Nov 7, 2020
0d8c92e
Merge branch 'compare-by-value-in-builtins'
ginrod Nov 7, 2020
ad29c52
hotfix: missing self
ginrod Nov 7, 2020
74d8c6c
change init name
Nov 7, 2020
c2ce503
rename init call in operation nodes
Nov 7, 2020
abcfe2e
Merge pull request #58 from dayanyalfaro/rename-init-calls
dayanyalfaro Nov 7, 2020
cc8afb5
fix the entry and call to the compiler
ginrod Nov 7, 2020
3e33a1b
Merge branch 'fix-compilator-main'
ginrod Nov 7, 2020
662c325
fix in attr_offset and method_offset initialization
Nov 7, 2020
ce5059e
fix visit to node Identifier
DalyPerez Nov 7, 2020
53f3b31
hotfix calling expr visit passing the scope in CIL IsVoid visit
ginrod Nov 7, 2020
c1245dc
fix interpolation in line 311, finish Object.copy method
ginrod Nov 11, 2020
a960838
fix copy
ginrod Nov 13, 2020
be8b203
Merge branch 'copy'
ginrod Nov 13, 2020
0d30c8f
add numeric tag to object layout, fix bug in attr offset
Nov 13, 2020
5d40b95
Merge pull request #63 from dayanyalfaro/change-obj-layout
dayanyalfaro Nov 13, 2020
e2b7356
add report
DalyPerez Nov 13, 2020
619c2c7
Merge branch 'master' of https://github.com/dayanyalfaro/cool-compile…
DalyPerez Nov 13, 2020
5595732
generating code for string length function
ginrod Nov 13, 2020
7f82ad3
adding len for each string in CIL Concat node, getting len before reg…
ginrod Nov 13, 2020
b380c70
implementing Concat visit
ginrod Nov 14, 2020
d5020ea
fix bug in concat and implementing substr method
ginrod Nov 14, 2020
2b948cd
Merge branch 'string-methods'
ginrod Nov 17, 2020
82ed7c1
set tag and max_tag in types
Nov 14, 2020
06c9276
remove extra locals in if node cool to cil
Nov 14, 2020
b4ccb23
cil case expression done except assign expr to id
Nov 14, 2020
4e2991e
mips case expression
Nov 14, 2020
97cc915
set tag in object layout
Nov 14, 2020
96614c9
assig case expr to action id
Nov 16, 2020
e068b16
fix sorting in actions
Nov 16, 2020
17b31e6
saving space for locals in just one line
Nov 16, 2020
4d14986
Merge pull request #65 from dayanyalfaro/case-expression
dayanyalfaro Nov 19, 2020
3891897
fix visit to AssingExpre node
DalyPerez Nov 20, 2020
46f8095
Add codegen test engine
danielgpz Nov 22, 2020
93514a0
Update clean rule of makefile
danielgpz Nov 23, 2020
8bd9f54
Add codegen tests
danielgpz Nov 23, 2020
360c011
Add GitHub Action workflow
leynier Nov 23, 2020
5f0cfc7
Add spim installation
leynier Nov 23, 2020
e566a9d
Fix typo
leynier Nov 23, 2020
71089f9
Merge pull request #1 from leynier/imgbot
leynier Nov 23, 2020
8a1aa29
Merge branch 'fetch-tests'
ginrod Nov 24, 2020
361bb4a
compile report
DalyPerez Nov 24, 2020
a574cc7
add runtime error detection
Nov 22, 2020
ea6537c
add heap overflow runtime error
Nov 24, 2020
84f44bd
Merge pull request #66 from dayanyalfaro/runtime-errors
dayanyalfaro Nov 24, 2020
cd804af
start lexer and parsing in report
DalyPerez Nov 24, 2020
6750bfe
reset hello_world.cl
ginrod Nov 24, 2020
872f1c8
Merge branch 'fix-hello-world-cl'
ginrod Nov 24, 2020
52309d2
complete grammar
DalyPerez Nov 25, 2020
4ddb0b9
Merge branch 'master' into daly-mips
DalyPerez Nov 25, 2020
f6b53a5
some bug fixes in codegen
Nov 25, 2020
ce589f4
save return value in calls
Nov 25, 2020
e097279
advance lexer and parsing in report
DalyPerez Nov 25, 2020
5e421d1
intro to the architecture
DalyPerez Nov 25, 2020
0ca4e2d
modify grammar.md
DalyPerez Nov 25, 2020
da19418
Merge pull request #67 from dayanyalfaro/testing-codegen
DalyPerez Nov 25, 2020
552e692
Merge branch 'master' into daly_report
DalyPerez Nov 25, 2020
481f132
branching in IfGoto when condition is not 0
ginrod Nov 26, 2020
a7dc529
fix if jumps and not operator
Nov 26, 2020
42a52a0
Merge pull request #68 from dayanyalfaro/testing-codegen
dayanyalfaro Nov 26, 2020
1bf33bd
change sub operand order and abort message
Nov 26, 2020
3046ff8
fix redefine methods and self param in static calls
Nov 26, 2020
7459661
Merge pull request #69 from dayanyalfaro/testing-codegen
dayanyalfaro Nov 26, 2020
f3cea0b
fixes in substr, cleaning register before load byte, and return the b…
ginrod Nov 26, 2020
57d1f57
Merge branch 'master' into daly_report
DalyPerez Nov 26, 2020
53b2b54
merge work nice
DalyPerez Nov 26, 2020
3374bcf
test print-cool passed
DalyPerez Nov 26, 2020
5b73c5c
fix concat str
DalyPerez Nov 26, 2020
0250e39
fix length str
DalyPerez Nov 26, 2020
50e9527
change String equality
DalyPerez Nov 27, 2020
10f30c4
mips in report
Nov 27, 2020
9a563bf
comparing string char by char
ginrod Nov 28, 2020
aedeb0e
fix addi
ginrod Nov 28, 2020
2c6ed4b
refactoring MIPS char by char comparison
ginrod Nov 28, 2020
3ed08bb
cleaning cil_to_mips main
ginrod Nov 28, 2020
bb9966d
Merge branch 'compare-strings-char-by-char'
ginrod Nov 28, 2020
0c20d6e
fix the length inside concat
Nov 28, 2020
b9d3a54
Merge pull request #71 from dayanyalfaro/testing-codegen
dayanyalfaro Nov 28, 2020
5a9034d
add init by default in let expression
Nov 28, 2020
ab86c14
add read str
Nov 28, 2020
8d4dd56
Merge branch 'testing-codegen'
ginrod Nov 28, 2020
74b7e15
removing last char after a read string in MIPS
ginrod Nov 28, 2020
f42454d
add : on MIPS label
ginrod Nov 28, 2020
516ddf8
Merge branch 'fix-read-str'
ginrod Nov 28, 2020
37c8225
add multiple comments and string to inform
Nov 29, 2020
572023b
Merge branch 'master' of https://github.com/dayanyalfaro/cool-compile…
Nov 29, 2020
2824b08
remove last char only if it is a '\n'
ginrod Nov 29, 2020
c39a72a
removing '\r\n' if there are any in MIPS read string
ginrod Nov 29, 2020
cd32971
Merge branch 'fix-string-length'
ginrod Nov 29, 2020
35ffef9
fix tag setting
Nov 29, 2020
32aae34
fix some details
ginrod Nov 29, 2020
3de3bb7
adding usage
ginrod Nov 29, 2020
a3ee89b
fix section errors
ginrod Nov 29, 2020
3873cea
adding usage to doc/Readme.md
ginrod Nov 29, 2020
847269b
Merge branch 'add-usage-to-report'
ginrod Nov 29, 2020
0b5c604
fix copy MIPS logic
ginrod Nov 29, 2020
83e562c
removing test case, create MIPS with .mips extension
ginrod Nov 29, 2020
da12bcf
Merge branch 'fix-copy'
ginrod Nov 29, 2020
7b354ec
remove str redef in cil ast nodes
Nov 29, 2020
11d4708
remove search offsets
Nov 29, 2020
415c982
remove useless comments
Nov 29, 2020
3bed28f
remove tester_semantic
Nov 30, 2020
a14d174
Merge pull request #76 from dayanyalfaro/clean-code
dayanyalfaro Nov 30, 2020
65d7866
Merge branch 'entrega-final' into master
apiad Nov 30, 2020
e3152f4
fix small details in report
Dec 1, 2020
a623d08
fix pdf failing to upload because gitignore
Dec 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
recursive calls to init parents
  • Loading branch information
dayanyalfaro committed Oct 29, 2020
commit 6c883b0ae5a5e0caec13cecbd34810affe843302
33 changes: 23 additions & 10 deletions src/cool_to_cil.py
Original file line number Diff line number Diff line change
@@ -103,7 +103,9 @@ def visit(self, node, scope):
self.current_function = self.register_function('entry')
instance = self.define_internal_local()
result = self.define_internal_local()
self.register_instruction(CIL_AST.Call(self.to_function_name('init', 'Main'), instance))
self.register_instruction(CIL_AST.Allocate('Main', instance))
self.register_instruction(CIL_AST.Arg(instance))
self.register_instruction(CIL_AST.Call(self.to_function_name('init', 'Main'), result))
self.register_instruction(CIL_AST.Arg(instance))
self.register_instruction(CIL_AST.Call(self.to_function_name('main', 'Main'), result))
self.register_instruction(CIL_AST.Return(0))
@@ -132,17 +134,24 @@ def visit(self, node, scope):

attr_declarations = (f for f in node.features if not isinstance(f, COOL_AST.ClassMethod))

#Definition of init function
self.current_function = self.to_function_name('init', node.name)

instance = self.define_internal_local()
self.register_instruction(CIL_AST.Allocate(node.name, instance))
self.current_type.instance = instance

#-------------------------Init---------------------------------
self.current_function = self.to_function_name('init', node.name)
self.register_param(VariableInfo('instance', None))

#Init parents recursively
result = self.define_internal_local()
self.register_instruction(CIL_AST.Arg(instance))
self.register_instruction(CIL_AST.Call(self.to_function_name('init', node.parent), result))

for attr in attr_declarations:
self.visit(attr, scope)

self.register_instruction(CIL_AST.Return(instance))
self.register_instruction(CIL_AST.Return(0))
#---------------------------------------------------------------

self.current_function = None
self.current_type = None
@@ -165,13 +174,12 @@ def visit(self, node, scope):

@visitor.when(COOL_AST.AttributeDef)
def visit(self, node, scope):
self.register_instruction(CIL_AST.SetAttr(self.current_type.instance, node.name,0, node.type))
self.register_instruction(CIL_AST.SetAttr('instance', node.name,0, node.type))

@visitor.when(COOL_AST.AttributeInit)
def visit(self, node, scope):
expr = self.visit(node.expr, scope)
self.register_instruction(CIL_AST.SetAttr(
self.current_type.instance, node.name, expr, node.type))
self.register_instruction(CIL_AST.SetAttr('instance', node.name, expr, node.type))

@visitor.when(COOL_AST.AssignExpr)
def visit(self, node, scope):
@@ -272,13 +280,18 @@ def visit(self, node, scope):
@visitor.when(COOL_AST.NewType)
def visit(self, node, scope):
result_local = self.define_internal_local()
result_init = self.define_internal_local()

if node.type == "SELF_TYPE":
get_type_local = self.define_internal_local()
self.register_instruction(CIL_AST.TypeOf("self", get_type_local))
self.register_instruction(CIL_AST.Call(self.to_function_name('init', get_type_local), result_local))
self.register_instruction(CIL_AST.Allocate(get_type_local, result_local))
self.register_instruction(CIL_AST.Arg(result_local))
self.register_instruction(CIL_AST.Call(self.to_function_name('init', get_type_local), result_init))
else:
self.register_instruction(CIL_AST.Call(self.to_function_name('init', node.type), result_local))
self.register_instruction(CIL_AST.Allocate(node.type, result_local))
self.register_instruction(CIL_AST.Arg(result_local))
self.register_instruction(CIL_AST.Call(self.to_function_name('init', node.type), result_init))

return result_local