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

Entrega final #59

Open
wants to merge 520 commits into
base: entrega-final
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
520 commits
Select commit Hold shift + click to select a range
7227ca4
Fix bug
adriantpaez May 21, 2020
124d3a2
Merge branch 'entrega-chequeo_semantico' into entrega-generacion_codigo
adriantpaez May 21, 2020
c5c2e22
Fix LNOT precedence
adriantpaez May 21, 2020
1f98c49
Merge branch 'entrega-chequeo_semantico' into entrega-generacion_codigo
adriantpaez May 21, 2020
50226c2
Add documentation to each function in semantic.py
adriantpaez May 21, 2020
6ed735d
Merge branch 'entrega-chequeo_semantico' into entrega-generacion_codigo
adriantpaez May 21, 2020
1525051
fix last bugs
TuquiSierra May 21, 2020
1c07ae2
adding lasts built in functions
TuquiSierra May 21, 2020
4964ae1
removing commented exception handling
TuquiSierra May 21, 2020
65d2f40
fixing error
TuquiSierra May 21, 2020
3189139
adding less equal and less to cil
TuquiSierra May 21, 2020
76f3bb6
Add class Local
adriantpaez May 22, 2020
d08f8d0
Reformat code in cil.py
adriantpaez May 22, 2020
c66a53d
Change locals_count for __LOCALS __
adriantpaez May 22, 2020
2defc9e
Add built_ind_code to ProgramNode
adriantpaez May 22, 2020
770202d
Add "locals" variable to InstructionNode
adriantpaez May 22, 2020
8c7f625
Add optimization of LOCALS
adriantpaez May 22, 2020
0783169
fixing bugs
TuquiSierra May 23, 2020
f82dae7
Add header to semantic files
adriantpaez May 24, 2020
ac6185e
Add header to lexer/parser files
adriantpaez May 24, 2020
18fae4c
Add header to eerors files
adriantpaez May 24, 2020
15070d8
Add headers to main and utils files
adriantpaez May 24, 2020
33aaf1d
Clean
adriantpaez May 24, 2020
f6d068d
Merge branch 'entrega-chequeo_semantico' into entrega-generacion_codigo
adriantpaez May 24, 2020
4b2418a
fixing style
TuquiSierra May 25, 2020
e8a4adf
Merge branch 'entrega-generacion_codigo' into entrega-generacion_codi…
TuquiSierra May 25, 2020
ca4c0f4
fix getattrnode
TuquiSierra May 25, 2020
d5505e9
Add vars to locals
TuquiSierra May 26, 2020
a1b4226
removing unnecessary instructions and locals
TuquiSierra May 26, 2020
d02a925
removing commented portion of code
TuquiSierra May 26, 2020
fd91679
merging add_local and add_named_local into one
TuquiSierra May 26, 2020
0ab77ef
adding some functions to mips ast
TuquiSierra May 27, 2020
7a783a0
removing code printing visitor and adding str to ast nodes
TuquiSierra May 27, 2020
c757dee
adding the last built in functions
TuquiSierra May 28, 2020
5349ea7
fixing bug
TuquiSierra May 28, 2020
c9b65d7
adding mips.py
TuquiSierra May 28, 2020
af6bec7
adding vcallvisitor
TuquiSierra May 28, 2020
ee03ff9
adding empty functions
TuquiSierra May 28, 2020
1d9aaf7
Add new MIPS instructions implementations
adriantpaez May 28, 2020
6623352
adding stack instruction
TuquiSierra May 28, 2020
8527162
adding param and arg visitors
TuquiSierra May 28, 2020
b5f5737
Add utilities for types in MIPS
adriantpaez May 28, 2020
e6e12df
Rebuild parsetab.py
adriantpaez May 28, 2020
fad23dd
Fix property 'name' access on Instruction
ericmg97 May 28, 2020
103de29
Add documentation to utilities.py
adriantpaez May 28, 2020
d8a4307
Merge branch 'entrega-generacion_codigo-eric' into entrega-generacion…
ericmg97 May 28, 2020
236b48f
adding function to mips visitor
TuquiSierra May 28, 2020
7289d48
Merge branch 'entrega-generacion_codigo' of https://github.com/stdevA…
TuquiSierra May 28, 2020
ddf6868
Reformat code
adriantpaez May 28, 2020
d928aca
Add arithmetic operation to MIPS
ericmg97 May 29, 2020
489db93
Add comparison instructions to MIPS
ericmg97 May 29, 2020
29684a4
Add branch and jump instructions to MIPS
ericmg97 May 29, 2020
96a481b
Move aux methods to utilities.py
ericmg97 May 29, 2020
7e9f443
Merge branch 'entrega-generacion_codigo-adrian' into entrega-generaci…
adriantpaez May 29, 2020
8024d7a
Reformat code
adriantpaez May 29, 2020
c8cb1d7
adding return values to aux methods
TuquiSierra May 29, 2020
72ce930
adding return value to func to mips visitor
TuquiSierra May 29, 2020
771e542
Add ALLOCATE to MIPS visitor
adriantpaez May 29, 2020
a1b3b34
finishing function to mips visitor
TuquiSierra May 29, 2020
5777761
Add COPY to MIPS visitor
adriantpaez May 29, 2020
72e71ab
Add Comment instruction
adriantpaez May 29, 2020
92e35bd
Adding documentation
TuquiSierra May 29, 2020
c4e3f03
Merge branch 'entrega-generacion_codigo' into entrega-generacion_codi…
TuquiSierra May 29, 2020
5009403
fixing push stack
TuquiSierra May 29, 2020
174c4c1
Merge branch 'entrega-generacion_codigo-isabella' into entrega-genera…
TuquiSierra May 29, 2020
8cd9510
adding comment lines to mips visitors
TuquiSierra May 29, 2020
5161d26
Many things
adriantpaez May 29, 2020
7af6706
Merge branch 'entrega-generacion_codigo-adrian' into entrega-generaci…
adriantpaez May 29, 2020
d8f417e
Fix redefined JrInstruction node
ericmg97 May 29, 2020
4f4833e
Add arithmetic instructions to cil to mips visitors
ericmg97 May 29, 2020
e186217
Add attr_index to GETATTR and SETATTR
adriantpaez May 29, 2020
977824f
Add GETATTR to MIPS visitor
adriantpaez May 29, 2020
c195f63
Merge branch 'entrega-generacion_codigo-adrian' into entrega-generaci…
adriantpaez May 29, 2020
bd90d6f
Reformat code
adriantpaez May 29, 2020
d9b72e6
Add SETATTR to MIPS visitor
adriantpaez May 29, 2020
5cdd8ad
Fix arithmetic operators
adriantpaez May 29, 2020
8024632
Re Fix arithmetic operators
ericmg97 May 29, 2020
41bb4fa
Add MIPSProgram class
adriantpaez Jun 1, 2020
d86a819
Change MIPS AST and output format
adriantpaez Jun 1, 2020
3e61f1a
Update .gitignore
adriantpaez Jun 1, 2020
6ca8e2c
Merge branch 'entrega-generacion_codigo' into entrega-generacion_codi…
TuquiSierra Jun 2, 2020
38699da
adding comments
TuquiSierra Jun 2, 2020
b98e1a8
adding print visitor
TuquiSierra Jun 2, 2020
b50aca2
adding read and read int mips visitors
TuquiSierra Jun 2, 2020
7470be1
adding mips label
TuquiSierra Jun 3, 2020
c349ae1
Removing print
TuquiSierra Jun 3, 2020
2fb7004
removing wrong vcall visitor
TuquiSierra Jun 3, 2020
a3c40ca
Add size_vt property to types
adriantpaez Jun 3, 2020
e6fbc85
Recalculate parsetab.py
adriantpaez Jun 3, 2020
53f58d6
Reformat code
adriantpaez Jun 3, 2020
506a3ca
Fix print format
adriantpaez Jun 3, 2020
8a89507
Add virtual table space in .data section
adriantpaez Jun 3, 2020
a040a29
adding substring mips visitor
TuquiSierra Jun 3, 2020
8f485d5
Merge branch 'entrega-generacion_codigo' into entrega-generacion_codi…
TuquiSierra Jun 3, 2020
b3da12f
Add main label to MIPS
adriantpaez Jun 3, 2020
e6b050b
Merge branch 'entrega-generacion_codigo-adrian' into entrega-generaci…
adriantpaez Jun 3, 2020
70c8175
fix bug
TuquiSierra Jun 3, 2020
a42ca37
Merge branch 'entrega-generacion_codigo' of https://github.com/stdevA…
TuquiSierra Jun 3, 2020
580b072
Skip SELF_TYPE in virtual table
adriantpaez Jun 3, 2020
77f0ed1
fix address access
TuquiSierra Jun 3, 2020
bd91c9d
updating table
TuquiSierra Jun 3, 2020
dc1fdfe
Merge branch 'entrega-generacion_codigo' of https://github.com/stdevA…
TuquiSierra Jun 3, 2020
748edb0
Merge branch 'entrega-generacion_codigo-isabella' into entrega-genera…
TuquiSierra Jun 3, 2020
2ab46f9
fixing stack ops
TuquiSierra Jun 3, 2020
9e0a61b
Merge branch 'entrega-generacion_codigo-isabella' into entrega-genera…
TuquiSierra Jun 3, 2020
7b45131
fix bug
TuquiSierra Jun 3, 2020
778d610
Merge branch 'entrega-generacion_codigo-isabella' into entrega-genera…
TuquiSierra Jun 3, 2020
5bdb40b
Build parsetab.py
adriantpaez Jun 3, 2020
fe6eaab
Merge branch 'entrega-generacion_codigo-adrian' into entrega-generaci…
adriantpaez Jun 3, 2020
8060f0e
Add registers to Instruction class
adriantpaez Jun 5, 2020
6adb775
Reformat code in utilities.py
adriantpaez Jun 5, 2020
3bf86a9
Reorder program to MIPS
adriantpaez Jun 5, 2020
54c87cc
Change CIL Function to MIPS code (Initial changes)
adriantpaez Jun 9, 2020
bfb21b4
Move type to external module
adriantpaez Jun 28, 2020
6e1f27f
Initial implementation of VCALL to MIPS
adriantpaez Sep 22, 2020
d8b28b3
Parameters are already pushed
adriantpaez Sep 22, 2020
527f9ba
Use $a0-$a3 registers for function arguments
adriantpaez Sep 23, 2020
9b80564
Remove $a0-$a3 and $v0-$v1 from caller
adriantpaez Sep 23, 2020
c8aa76a
Optimize plus and minus operations
adriantpaez Sep 23, 2020
554d02e
Fix call type in CIL
adriantpaez Sep 24, 2020
dd8145c
Add free_stack function
adriantpaez Sep 24, 2020
8a033cb
Add MIPS instructions of VCALL
adriantpaez Sep 24, 2020
597b8fa
Add .vscode to gitignore
adriantpaez Nov 25, 2020
6d81b04
Fix bugs
danielgpz Oct 25, 2020
32e2c20
Add first semantic test
danielgpz Oct 25, 2020
89627cc
Update utils
danielgpz Oct 25, 2020
fc91a3b
Add new tests
danielgpz Oct 26, 2020
207281f
Add new tests
danielgpz Oct 26, 2020
0fd6d4e
Add new tests
danielgpz Oct 26, 2020
1e2cb2e
Add dispatch tests
danielgpz Oct 27, 2020
b2508fd
Add conditionals tests
danielgpz Oct 27, 2020
b5c8a96
Add loops test
danielgpz Oct 27, 2020
b24b428
Add blocks tests
danielgpz Oct 27, 2020
0cd7cd3
Add let tests
danielgpz Oct 27, 2020
378ac6e
Add case tests
danielgpz Oct 27, 2020
55568e2
Add isvoid tests
danielgpz Oct 27, 2020
9970535
Add aritmetics tests
danielgpz Oct 27, 2020
293816e
Add equility tests
danielgpz Oct 27, 2020
0a1ee37
Format all semantic errors
danielgpz Oct 28, 2020
17f4233
Update travis.yml
danielgpz Oct 30, 2020
3ac170a
Add basic types tests
danielgpz Oct 30, 2020
7a476e5
New arithmetic tests
danielgpz Oct 31, 2020
2ea55b6
Add new case tests
danielgpz Oct 31, 2020
f7a512e
Add new type tests
danielgpz Oct 31, 2020
53b60b7
Add codegen test engine
danielgpz Nov 22, 2020
4c2e051
Update clean rule of makefile
danielgpz Nov 23, 2020
24bb381
Add codegen tests
danielgpz Nov 23, 2020
1c2f7ac
Add GitHub Action workflow
leynier Nov 23, 2020
af0b28b
Add spim installation
leynier Nov 23, 2020
5e23048
Fix typo
leynier Nov 23, 2020
8520336
Merge pull request #1 from leynier/imgbot
leynier Nov 23, 2020
38c5398
Delete old.travis.yml
apiad Nov 24, 2020
bd3ed4e
Update Readme.md
apiad Nov 24, 2020
f21f6ab
Merge branch 'entrega-final-stdevAdrianPaez' into entrega-final
adriantpaez Nov 25, 2020
c0d1ad2
[semantic] Fix error message
adriantpaez Nov 25, 2020
f617a64
Change find_column
adriantpaez Nov 25, 2020
2be0fd6
[semantic] Fix arithmetic-operator position
adriantpaez Nov 25, 2020
19869e2
Fix error message
adriantpaez Nov 25, 2020
6827d6c
Check 'self' cannot be bound in a 'let' expression
adriantpaez Nov 25, 2020
a7ed947
Fix error message
adriantpaez Nov 25, 2020
1b39e33
Check inheritance cycle
adriantpaez Nov 25, 2020
ec58b20
Fir error message
adriantpaez Nov 25, 2020
1143f40
Fix semantic
adriantpaez Nov 26, 2020
35bd9db
Return caller type in get_method
adriantpaez Nov 26, 2020
4058a50
Finally semantic check
adriantpaez Nov 26, 2020
33036a8
hello_world partially working
TuquiSierra Nov 27, 2020
142c25f
Some changes
adriantpaez Nov 28, 2020
7abaee4
Check substring
adriantpaez Nov 28, 2020
783ea30
Merge branch 'entrega-final-stdevAdrianPaez' into entrega-final
adriantpaez Nov 28, 2020
bf0471a
adding read and int
TuquiSierra Nov 28, 2020
4c770f4
Make concat
adriantpaez Nov 28, 2020
3b0e0a2
Merge branch 'entrega-final-stdevAdrianPaez' into entrega-final
adriantpaez Nov 28, 2020
ba22b1e
arg_to_mips
TuquiSierra Nov 28, 2020
d11c859
fixing arg to mips
TuquiSierra Nov 28, 2020
de7e052
add allocate_to_mips
TuquiSierra Nov 28, 2020
d172f21
add type_of to mips
TuquiSierra Nov 28, 2020
9c5a9be
add get_attr to mips
TuquiSierra Nov 28, 2020
7b3c1b6
add set_attr to mips
TuquiSierra Nov 28, 2020
8b17534
add assign to mips
TuquiSierra Nov 28, 2020
e9370a0
fixing errors
TuquiSierra Nov 28, 2020
5bb1087
Merge branch 'entrega-final' of https://github.com/stdevAdrianPaez/co…
TuquiSierra Nov 28, 2020
9dd57a8
fixing errors
TuquiSierra Nov 28, 2020
ac42563
Merge branch 'entrega-final-isabella' of https://github.com/stdevAdri…
TuquiSierra Nov 28, 2020
ad1ea30
add copy to mips
TuquiSierra Nov 28, 2020
c32722f
Merge branch 'entrega-final' into entrega-final-isabella
TuquiSierra Nov 28, 2020
401f638
Fix var names in substring visitor
adriantpaez Nov 29, 2020
53b2b21
ya se imprime hello_world
TuquiSierra Nov 29, 2020
2492268
finally
TuquiSierra Nov 29, 2020
9838fa7
fixing bugs
TuquiSierra Nov 29, 2020
089de95
Reformat cde
adriantpaez Nov 29, 2020
897409d
Fix bugs
adriantpaez Nov 29, 2020
06c9338
fixing bugs
TuquiSierra Nov 29, 2020
9cf5245
fixing bugs
TuquiSierra Nov 29, 2020
ee50bb6
Merge branch 'entrega-final' into entrega-final-isabella
TuquiSierra Nov 29, 2020
c51a144
Fix Typo Errors
ericmg97 Nov 29, 2020
75379fa
Bug Semantic Error on Class Declaration
ericmg97 Nov 29, 2020
e0389d3
Fix bug operators
adriantpaez Nov 29, 2020
a97225e
fix bugs
TuquiSierra Nov 29, 2020
1a156be
Merge branch 'entrega-final' of https://github.com/stdevAdrianPaez/co…
TuquiSierra Nov 29, 2020
b2e2365
Merge branch 'entrega-final-eric' into entrega-final
ericmg97 Nov 29, 2020
e9ebc48
Fix Merge Errors
ericmg97 Nov 29, 2020
06a5776
Fix arg
adriantpaez Nov 29, 2020
e84ef5f
removing extra index shift
TuquiSierra Nov 29, 2020
5bc0536
removing unnecessary locals
TuquiSierra Nov 29, 2020
4438f1b
Fix less and lesseq mips visitors
ericmg97 Nov 29, 2020
c3c77f9
Fix Not mips visitor
ericmg97 Nov 29, 2020
37b5567
Fix Not mips member
ericmg97 Nov 29, 2020
1e7013c
Merge branch 'entrega-final-eric' into entrega-final
ericmg97 Nov 29, 2020
175061e
Merge branch 'entrega-final-isabella' into entrega-final
TuquiSierra Nov 29, 2020
bebbd7d
Add value_id to new visitor
adriantpaez Nov 30, 2020
91c0d98
Add abort to built in
adriantpaez Nov 30, 2020
a32c137
Fix star to mips visitor
adriantpaez Nov 30, 2020
5f0f90b
Check if goto condition is a constant
adriantpaez Nov 30, 2020
1ce97c6
Fix indexes CIL visitors
ericmg97 Nov 30, 2020
1556911
Merge branch 'entrega-final-eric' into entrega-final
ericmg97 Nov 30, 2020
1a6aacc
Change ABORT node in CIL
adriantpaez Nov 30, 2020
dfbb295
Fix bugs
adriantpaez Nov 30, 2020
81857d9
Merge branch 'entrega-final-stdevAdrianPaez' into entrega-final
adriantpaez Nov 30, 2020
bd783f4
Fix index
adriantpaez Nov 30, 2020
22a28d7
Fix bugs
adriantpaez Dec 1, 2020
c89a484
adding changes to virtual table
TuquiSierra Dec 1, 2020
bb68972
adding built in types to function call
TuquiSierra Dec 1, 2020
2c865a5
adding built_in special methods
TuquiSierra Dec 1, 2020
4fe8198
fixing vt size
TuquiSierra Dec 1, 2020
6f7cc46
fixing concat
TuquiSierra Dec 2, 2020
0edd6ad
fixing returned_type
TuquiSierra Dec 2, 2020
7171ed6
removing nl from read
TuquiSierra Dec 2, 2020
65099aa
fixing not nul terminated substring
TuquiSierra Dec 2, 2020
f3caf08
Fix Not Equal to mips visitor
ericmg97 Dec 2, 2020
47afb43
fixinf concat nul terminated
TuquiSierra Dec 2, 2020
5f504b9
Merge remote-tracking branch 'origin/entrega-final-isabella' into ent…
ericmg97 Dec 3, 2020
f76d0aa
adding init function to types
TuquiSierra Dec 3, 2020
2fb23ef
fixing case details
TuquiSierra Dec 4, 2020
e596a3f
fixing allocate result for concat
TuquiSierra Dec 4, 2020
21ea671
fixing substring bug
TuquiSierra Dec 4, 2020
4a6f8eb
Merge branch 'entrega-final-eric' into entrega-final
ericmg97 Dec 4, 2020
1bd4651
fixing bugs
TuquiSierra Dec 4, 2020
3c30fbe
Merge branch 'entrega-final' of https://github.com/stdevAdrianPaez/co…
TuquiSierra Dec 4, 2020
ee233bf
Add type childs
adriantpaez Dec 5, 2020
3e514fa
Set order and min_order properties to CoolType
adriantpaez Dec 5, 2020
d3937e6
fixing space allocation for concat and substring
TuquiSierra Dec 5, 2020
1e36219
adding one more byte to null termination
TuquiSierra Dec 5, 2020
84bbdab
fixing space allocation for concat and substring
TuquiSierra Dec 5, 2020
3efc9cb
adding one more byte to null termination
TuquiSierra Dec 5, 2020
76d1f69
Merge branch 'entrega-final-isabella' of https://github.com/stdevAdri…
TuquiSierra Dec 5, 2020
5afac0b
fixing order in types
TuquiSierra Dec 5, 2020
087c0c5
Final fix ;)
adriantpaez Dec 6, 2020
a927697
Adding report
TuquiSierra Dec 6, 2020
5336367
Updating report
TuquiSierra Dec 12, 2020
46be8b7
Fixing typos
TuquiSierra Dec 13, 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
fixing order in types
  • Loading branch information
TuquiSierra committed Dec 5, 2020
commit 5afac0b2491ce28612b52fed39cfc27ffad0a56d
13 changes: 13 additions & 0 deletions src/code_generation/CIL/ast.py
Original file line number Diff line number Diff line change
@@ -304,6 +304,19 @@ def __init__(self, result, var):
def __str__(self):
return f'{self.result} = GETTYPEORDER {self.var} ;'

class GetTypeMinOrderNode(InstructionNode):
def __init__(self, result, var):
super().__init__()
self.result = result
self.var = var
self.check_local(result)
self.check_local(var)

def __str__(self):
return f'{self.result} = GETTYPEMINORDER {self.var} ;'




class ArrayNode(InstructionNode):
def __init__(self, len, result):
35 changes: 19 additions & 16 deletions src/code_generation/CIL/cil.py
Original file line number Diff line number Diff line change
@@ -301,6 +301,10 @@ def case_to_cil_visitor(case):
body += expr_cil.body
t = add_local()
body.append(CilAST.GetTypeOrderNode(t, expr_cil.value))
t_min=add_local()

body.append(CilAST.GetTypeMinOrderNode(t_min, expr_cil.value))

types = []
labels = []
for c in case.case_list:
@@ -318,20 +322,15 @@ def case_to_cil_visitor(case):
aux_predicate=add_local()

order=CT.TypesByName[branch.type].order
comp_result=add_local()
body.append(CilAST.LessNode(order, t, comp_result))
body.append(CilAST.ConditionalGotoNode(comp_result, labels[i]))

min_order=CT.TypesByName[branch.type].min_order

first_comp_result=add_local()
body.append(CilAST.LessNode(order, t, first_comp_result))
body.append(CilAST.ConditionalGotoNode(first_comp_result, labels[i]))

# str_addr = add_str_data(branch.type)
# str_id, need_load = add_data_local(str_addr)
# if need_load:
# body.append(CilAST.LoadNode(str_addr, str_id))
# body.append(CilAST.EqStringNode(t, str_id, aux_predicate)),
# body.append(CilAST.EqNode(aux_predicate, 0, predicate)),
# body.append(CilAST.ConditionalGotoNode(predicate, labels[i]))

second_comp_result=add_local()
body.append(CilAST.LessNode(t_min, min_order, second_comp_result))
body.append(CilAST.ConditionalGotoNode(second_comp_result, labels[i]))

val = add_local(branch.id)
body.append(CilAST.AssignNode(val, expr_cil.value))
@@ -353,7 +352,7 @@ def assign_to_cil_visitor(assign):
expr = expression_to_cil_visitor(assign.expr)
if assign.id in __ATTR__[__CURRENT_TYPE__]:
index = __ATTR__[__CURRENT_TYPE__].index(assign.id)
body = expr.body + [CilAST.SetAttrNode('self', assign.id, expr.value, index + 4)]
body = expr.body + [CilAST.SetAttrNode('self', assign.id, expr.value, index + 5)]
return CIL_block(body, expr.value)
else:
val = add_local(assign.id)
@@ -474,7 +473,7 @@ def id_to_cil_visitor(id):
if id.id in __ATTR__[__CURRENT_TYPE__]:
result = add_local()
index = __ATTR__[__CURRENT_TYPE__].index(id.id)
return CIL_block([CilAST.GetAttrNode('self', id.id, result, index + 4)], result)
return CIL_block([CilAST.GetAttrNode('self', id.id, result, index + 5)], result)
return CIL_block([], id.id)

def init_instance(t, parent=None):
@@ -495,7 +494,7 @@ def init_instance(t, parent=None):

all_attr= CT.TypesByName[t].get_all_attributes()
init_attr = CT.TypesByName[t].get_self_attributes()
for index, attr in enumerate(init_attr, len(all_attr)-len(init_attr)+4):
for index, attr in enumerate(init_attr, len(all_attr)-len(init_attr)+5):
if attr.expression:
attr_cil = expression_to_cil_visitor(
attr.expression)
@@ -541,17 +540,21 @@ def new_to_cil_visitor(new_node, val_id=None, default_type=None):
t_local = add_local()
size_local = add_local()
order_local=add_local()
min_order_local=add_local()
#

init_attr = CT.TypesByName[t].get_all_attributes()

body.append(CilAST.LoadNode(t_data, t_local))
body.append(CilAST.SetAttrNode(value, '@type', t_local))
body.append(CilAST.AssignNode(size_local, (len(init_attr)+4)*4))
body.append(CilAST.AssignNode(size_local, (len(init_attr)+5)*4))
body.append(CilAST.SetAttrNode(value, '@size', size_local, 1))
body.append(CilAST.AssignNode(order_local, CT.TypesByName[t].order))
body.append(CilAST.SetAttrNode(value, '@order', order_local, 3))

body.append(CilAST.AssignNode(min_order_local, CT.TypesByName[t].min_order))
body.append(CilAST.SetAttrNode(value, '@min_order', min_order_local, 4))

if t not in ('IO', 'Object', 'Int', 'String', 'Bool'):
body.append(CilAST.ArgNode(value))
allocate_res=add_local()
12 changes: 12 additions & 0 deletions src/code_generation/MIPS/mips.py
Original file line number Diff line number Diff line change
@@ -805,6 +805,16 @@ def get_type_order_to_mips_visitor(get_order:cil.GetTypeOrderNode):
mips.LwInstruction('$t0', f'12($t1)'),
mips.SwInstruction('$t0', f'{t_addr}($fp)')
]

def get_type_order_min_to_mips_visitor(get_order:cil.GetTypeMinOrderNode):
x_addr = CURRENT_FUNCTION.offset[str(get_order.var)]
t_addr = CURRENT_FUNCTION.offset[str(get_order.result)]
return [
mips.Comment(str(get_order)),
mips.LwInstruction('$t1', f'{x_addr}($fp)'),
mips.LwInstruction('$t0', f'16($t1)'),
mips.SwInstruction('$t0', f'{t_addr}($fp)')
]

def assign_to_mips_visitor(assign: cil.AssignNode):
"""
@@ -933,6 +943,8 @@ def abort_to_mips_visitor(abort: cil.AbortNode):
cil.AbortNode: abort_to_mips_visitor,
cil.GetTypeAddrNode: get_type_addr_to_mips_visitor,
cil.GetTypeOrderNode:get_type_order_to_mips_visitor,

cil.GetTypeMinOrderNode:get_type_order_min_to_mips_visitor,
cil.EqNode: eq_to_mips_visitor,
cil.NotEqNode:not_eq_to_mips_visitor,
cil.NotEqInstanceNode:not_eq_instance_to_mips_visitor,
2 changes: 1 addition & 1 deletion src/code_generation/MIPS/utilities.py
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ def init_types(types):
size_vt=0
for i, t in enumerate(types):
t.code_mips = i
t.size_mips = (len(t.attributes) + 4) * 4
t.size_mips = (len(t.attributes) + 5) * 4
size_vt +=(len(t.methods) + 1) * 4
t.attr_index_mips = {}
for i, a in enumerate(t.attributes):