Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Generation and Tac to Bytecode translation #50

Open
wants to merge 314 commits into
base: metadata-provider
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
314 commits
Select commit Hold shift + click to select a range
5d35333
refactors
fcurdi Dec 14, 2019
6b6f6be
LoadArrayElementInstruction not basic operation
fcurdi Dec 15, 2019
3ed3578
use existing LoadArrayElementInstruction instead of BasicInstruction
fcurdi Dec 15, 2019
aef5ce3
remove unused methods
fcurdi Dec 15, 2019
64a7113
whitespace
fcurdi Dec 15, 2019
8ff1d2f
handle storeArrayElementInstruction correctly
fcurdi Dec 17, 2019
d11b97d
store array element not a basic instruction anymore
fcurdi Dec 17, 2019
150f68d
add missing Ldelem_i
fcurdi Dec 17, 2019
cbc1fac
handle isInst correctly
fcurdi Dec 19, 2019
70d3255
IsInst is not the same as Cast for convert instructions
fcurdi Dec 19, 2019
00741b7
fix LoadFieldOperation handler
fcurdi Dec 19, 2019
308a83c
remove part that is going to be on other PR
fcurdi Dec 22, 2019
75f2115
whitespace
fcurdi Dec 22, 2019
f856c31
remove part that is going to be on other PR
fcurdi Dec 22, 2019
78691dd
remove part that is going to be on other PR
fcurdi Dec 22, 2019
d5546de
GetOperand supports TypeDefinition
fcurdi Dec 22, 2019
af56b67
fixes
fcurdi Dec 22, 2019
637c2e7
overflow and unsigned variants
fcurdi Dec 23, 2019
9c15d58
fix several body generation issues
fcurdi Dec 26, 2019
cb6c4fa
initialize method parameters (default values)
fcurdi Dec 26, 2019
4a007d1
refactor
fcurdi Dec 28, 2019
ca68664
ExamplesExe
fcurdi Jan 8, 2020
18a00d7
Merge branch 'metadata-provider' of github.com:edgardozoppi/analysis-…
fcurdi Jan 8, 2020
7af992c
Merge branch 'fix/get_operand_type_definition' into code-generator
fcurdi Jan 8, 2020
f5f1ba8
Merge branch 'fix/isinst' into code-generator
fcurdi Jan 8, 2020
2d66616
Merge branch 'fix/StoreArrayElementInstruction' into code-generator
fcurdi Jan 8, 2020
8d679e5
Merge branch 'fix/LoadArrayElementInstruction' into code-generator
fcurdi Jan 8, 2020
f8a57bf
unccomment code base on PR merges
fcurdi Jan 8, 2020
af1552c
minor fixes
fcurdi Jan 10, 2020
32abbbe
Fix field and method reference collisions. Fix static field store
fcurdi Jan 12, 2020
11cd1a5
refactor
fcurdi Jan 12, 2020
4f67663
add assembly kind
fcurdi Jan 12, 2020
2522112
equals and hashcode
fcurdi Jan 12, 2020
2f034d6
remove unnecessary $
fcurdi Jan 12, 2020
6b6f0ba
Merge branch 'feature/add_assembly_kind' into code-generator
fcurdi Jan 12, 2020
87c778c
use assembly kind
fcurdi Jan 12, 2020
0efefb7
Merge remote-tracking branch 'manuel/metadata-initobj' into code-gene…
fcurdi Jan 13, 2020
083a894
generate initObj
fcurdi Jan 13, 2020
7e7bb8a
Merge remote-tracking branch 'manuel/metadata-provider-in-ref-out' in…
fcurdi Jan 13, 2020
2b081da
Merge remote-tracking branch 'manuel/metadata-provider-constrained-in…
fcurdi Jan 13, 2020
4a7d9ba
generate constrained. instruction. Fix IN parameters
fcurdi Jan 13, 2020
8a09ec8
revert LoadArrayElementInstruction and StoreArrayElementInstruction PRs
fcurdi Jan 14, 2020
c30d154
merge with existing Load/Store indirect instructions PR
fcurdi Feb 3, 2020
e3ba143
generate store/load indirect instructions
fcurdi Feb 3, 2020
fc37c94
remove unmarked labels logic
fcurdi Feb 3, 2020
e7a1103
fix pointers and reference handle
fcurdi Feb 8, 2020
6a684a8
Differenciate pointers and managed pointers
fcurdi Feb 8, 2020
018f2ca
Merge branch 'feature/managed_pointers' into code-generator
fcurdi Feb 8, 2020
0c5cccd
Add some missing attributes for types, fields and methods
fcurdi Feb 8, 2020
e32319d
Merge branch 'feature/types_fields_methods_attributes' into code-gene…
fcurdi Feb 8, 2020
1e050e5
Correct attributes for types, fields and methods
fcurdi Feb 8, 2020
7e280ff
examples
fcurdi Feb 9, 2020
9a1d468
fix array encoding
fcurdi Feb 9, 2020
0a08ade
fix
fcurdi Feb 9, 2020
ff9d77a
comments
fcurdi Feb 14, 2020
d7f975e
comments
fcurdi Feb 19, 2020
d49b678
resolve type kind
fcurdi Feb 23, 2020
b9711bf
Merge branch 'fix/resolve_type_kind' into code-generator
fcurdi Feb 23, 2020
cd63e6b
examples working
fcurdi Feb 23, 2020
4bce69c
more properties examples
fcurdi Feb 23, 2020
a39243b
extract properties
fcurdi Feb 25, 2020
406da63
refactor
fcurdi Feb 25, 2020
87be0af
styling
fcurdi Feb 25, 2020
8457bfb
Merge branch 'feature/properties' into code-generator
fcurdi Feb 25, 2020
278bd4f
property generation
fcurdi Feb 25, 2020
277b9cb
fix some instruction generation
fcurdi Mar 6, 2020
853d63f
fixes
fcurdi Mar 19, 2020
09c89b2
Merge branch 'metadata_provider_fixes' into code-generator
fcurdi Mar 19, 2020
cb1eea5
fixes derived from processing some libraries
fcurdi Mar 19, 2020
55f1e18
a lot of changes
fcurdi Apr 10, 2020
c9adf81
fix property map
fcurdi Apr 10, 2020
d633147
more fixes
fcurdi Apr 10, 2020
6bdffb8
Merge branch 'metadata_provider_fixes' into code-generator
fcurdi Apr 10, 2020
fe5f16b
missing merge
fcurdi Apr 10, 2020
c23b1e6
fix merge
fcurdi Apr 10, 2020
14b1be0
fix namespace in GetDefinedType
fcurdi Apr 10, 2020
53d75ea
Merge branch 'metadata_provider_fixes' into code-generator
fcurdi Apr 10, 2020
a0a2934
generate missing types at rootnamespace level
fcurdi Apr 13, 2020
affb9d5
add culture and public key
fcurdi Apr 14, 2020
4b0cc79
Merge branch 'metadata_provider_fixes' into code-generator
fcurdi Apr 14, 2020
dfa503e
culture and public key on assembly and assemblyreferences
fcurdi Apr 14, 2020
bea4b2d
Merge remote-tracking branch 'manuel/metadata-provider-generic-constr…
fcurdi Apr 14, 2020
b3fc58b
generic parameter constraints
fcurdi Apr 14, 2020
696f034
better constraints
fcurdi Apr 16, 2020
6808783
Merge remote-tracking branch 'manuel/metadata-provider-generic-constr…
fcurdi Apr 16, 2020
143630d
generic parameter constraints
fcurdi Apr 16, 2020
905a566
fix
fcurdi Apr 16, 2020
fa78c95
remove unused method
fcurdi Apr 16, 2020
762cdc3
Merge branch 'metadata_provider_fixes' into code-generator
fcurdi Apr 16, 2020
a06da30
uncomment
fcurdi Apr 16, 2020
feb5c82
fix switch instruction & resolver conflicts
fcurdi May 1, 2020
57598d8
method overrides, generic constraints
fcurdi May 1, 2020
9874b5b
Merge branch 'metadata_provider_fixes' into code-generator
fcurdi May 1, 2020
dcf4f70
missing import
fcurdi May 1, 2020
64201da
Merge branch 'metadata_provider_fixes' into code-generator
fcurdi May 1, 2020
0d0a6d0
method overrides generation
fcurdi May 1, 2020
c7a117f
remove generated in file name
fcurdi May 1, 2020
367c4a4
Fix property generation (lazy FirstOrDefault)
fcurdi May 2, 2020
fb29027
layout information
fcurdi May 10, 2020
23db1b2
fix logic
fcurdi May 10, 2020
c0960f0
generate layout information
fcurdi May 11, 2020
6bbe48d
add layout default check
fcurdi May 11, 2020
cc89595
Merge branch 'layout' into code-generator
fcurdi May 11, 2020
454df95
field rva
fcurdi May 11, 2020
4485be4
whitespace
fcurdi May 11, 2020
389bb92
whitespace
fcurdi May 11, 2020
928b5be
Merge branch 'feature/field-rva' into code-generator
fcurdi May 11, 2020
59e4ec6
generate field rva
fcurdi May 11, 2020
ffc7cb2
generate fault region
fcurdi May 13, 2020
5068609
add IsVirtual property to IMethodReference
fcurdi May 16, 2020
c79f48e
Merge branch 'feature/virtual_property_imethodreference' into code-ge…
fcurdi May 16, 2020
bc197d7
ldvirtftn
fcurdi May 16, 2020
2f7af73
serializable
fcurdi May 17, 2020
37388fa
Merge branch 'feature/types_fields_methods_attributes' into code-gene…
fcurdi May 17, 2020
5a35c92
serializable
fcurdi May 17, 2020
e44329c
more attributes cases
fcurdi May 25, 2020
14e0ac0
refactor
fcurdi May 25, 2020
4f5d8e0
custom attributes
fcurdi May 25, 2020
92315c8
:wqMerge branch 'metadata_provider_fixes' into code-generator
fcurdi May 25, 2020
c798ba7
generate custom attributes
fcurdi May 25, 2020
e28f6bf
refactor
fcurdi May 25, 2020
2535a6a
remove assembler class
fcurdi May 25, 2020
d2157c2
Translate simple instructions
fcurdi May 26, 2020
f5c38da
Add isInst TAC ConvertOperation. Remove unused methods, visit InitObj…
fcurdi May 27, 2020
a3a53d8
remove comments. Process Assemble CreateArrayInstruction
fcurdi May 27, 2020
ac28f42
translate more instructions
fcurdi May 28, 2020
9d52be5
remove unwanted char
fcurdi May 28, 2020
4899c05
fixes and translate more instructions
fcurdi May 31, 2020
f7e55a0
draft
fcurdi Jun 6, 2020
b9256fb
exception handling draft
fcurdi Jun 8, 2020
d43d61a
tunning exception handling
fcurdi Jun 10, 2020
27366a0
fix exception translation
fcurdi Jun 13, 2020
f2831eb
better exception generation
fcurdi Jun 14, 2020
a9f8760
fix exception generation
fcurdi Jun 14, 2020
d7866b8
refactor exception information generation
fcurdi Jun 14, 2020
938ddba
clear stack before filter and catch
fcurdi Jun 19, 2020
4f6b1f1
ensure type of variables in dissasembler. add tac constrained instruc…
fcurdi Jun 21, 2020
77261be
assembler offset generation draft
fcurdi Jun 23, 2020
8208bdf
fix load offset generation
fcurdi Jun 24, 2020
9e28c71
some offsets and types fixes
fcurdi Jun 26, 2020
c682c0f
draft
fcurdi Jun 29, 2020
1c3be97
fix local variables translation
fcurdi Jun 30, 2020
afaad4c
translate correctly throw and rethrow instructions
fcurdi Jul 2, 2020
eaeba99
make property non nullable
fcurdi Jul 5, 2020
76989d8
Merge branch 'metadata_provider_fixes' into code-generator
fcurdi Jul 5, 2020
2ae6eb5
non nullable index
fcurdi Jul 5, 2020
6019e89
Merge branch 'code-generator' into refactor/tac_to_bytecode
fcurdi Jul 5, 2020
b7f07ce
refactor
fcurdi Jul 5, 2020
9ba2d9d
renames and relocation
fcurdi Jul 5, 2020
c6a9a0f
refactor exception information
fcurdi Jul 6, 2020
f20dc4e
refactor
fcurdi Jul 6, 2020
165a81c
Offset refactor
fcurdi Jul 7, 2020
e1efc51
unique labels draft
fcurdi Jul 19, 2020
ecf1856
fix switch generation
fcurdi Jul 22, 2020
b9de515
draft
fcurdi Jul 22, 2020
e1e1f57
fix switch generation
fcurdi Jul 25, 2020
64917b8
Merge branch 'code-generator' into tac_to_bytecode
fcurdi Jul 26, 2020
7e65d2a
merge
fcurdi Jul 26, 2020
38ba2d6
merge
fcurdi Jul 26, 2020
93e6b64
clean
fcurdi Jul 26, 2020
8922ad9
fix switch instruction and branche instruction generation
fcurdi Jul 26, 2020
db9c11f
Merge branch 'code-generator' into tac_to_bytecode
fcurdi Jul 26, 2020
eece3c1
revert code generator changes
fcurdi Jul 26, 2020
2afeb2f
Merge branch 'tac_to_bytecode' into refactor/tac_to_bytecode
fcurdi Jul 26, 2020
40fd22a
remove comments
fcurdi Jul 29, 2020
f802931
draft
fcurdi Aug 4, 2020
8e7f024
draft
fcurdi Aug 5, 2020
267be94
remove index
fcurdi Aug 5, 2020
160e8c0
Merge branch 'metadata_provider_fixes' into code-generator
fcurdi Aug 5, 2020
c6a7395
fix indexes
fcurdi Aug 5, 2020
ed68ccc
remove PDB
fcurdi Aug 5, 2020
50fd383
Merge branch 'remove_pdb' into code-generator
fcurdi Aug 5, 2020
4c19243
Merge branch 'code-generator' into tac_to_bytecode
fcurdi Aug 5, 2020
116b373
Merge branch 'tac_to_bytecode' into fix/tac_to_bytecode
fcurdi Aug 5, 2020
f8819f4
fixes
fcurdi Aug 5, 2020
23e31b1
fix exceptions in assembler
fcurdi Aug 6, 2020
bb188bb
draft
fcurdi Aug 6, 2020
8d12a41
simplify to a filed instead of a new type
fcurdi Aug 6, 2020
f81654e
Merge branch 'feature/managed_pointers' into code-generator
fcurdi Aug 6, 2020
54696c0
incorporate managed pointer changes
fcurdi Aug 6, 2020
00f60b7
Merge branch 'code-generator' into tac_to_bytecode
fcurdi Aug 7, 2020
633474e
fix conflicts
fcurdi Aug 7, 2020
512efbf
Merge branch 'tac_to_bytecode' into fix/tac_to_bytecode
fcurdi Aug 7, 2020
24ac940
more fixes
fcurdi Aug 7, 2020
5110a8d
fixes
fcurdi Aug 10, 2020
4295c45
fix
fcurdi Aug 12, 2020
51ae090
fixes
fcurdi Aug 14, 2020
eec5ab1
remove code generator changes
fcurdi Aug 14, 2020
a4947a6
refactor
fcurdi Aug 14, 2020
dddad4b
undo changes
fcurdi Aug 14, 2020
5248171
cleanup
fcurdi Aug 14, 2020
bd9579a
undo code-generator changes
fcurdi Aug 14, 2020
0c28527
Merge branch 'code-generator' into tac_to_bytecode
fcurdi Aug 14, 2020
bb19b74
refactor: use visitor
fcurdi Aug 16, 2020
566082a
Merge branch 'code-generator' into tac_to_bytecode
fcurdi Aug 16, 2020
e8ac43f
refactor: use visitor
fcurdi Aug 17, 2020
3091cab
fix stack size
fcurdi Aug 17, 2020
f80b1c5
instrumentation and generation tests
fcurdi Aug 18, 2020
2e52856
optimization test
fcurdi Aug 19, 2020
7d89e0b
remove unused code
fcurdi Aug 21, 2020
bb4ab88
draft
fcurdi Aug 22, 2020
532fe45
comment
fcurdi Aug 22, 2020
c87bcfd
remove proxy and unused code
fcurdi Aug 22, 2020
5c27c62
fix method instantiation problem
fcurdi Aug 22, 2020
29a56ee
comment
fcurdi Aug 22, 2020
90c098d
Merge branch 'fix/generic_method_instantiation' into code-generator
fcurdi Aug 22, 2020
e28db1d
Merge branch 'code-generator' into tac_to_bytecode
fcurdi Aug 22, 2020
1d42468
Merge branch 'code-generator' into feature/max_stack_generation
fcurdi Aug 22, 2020
3eb80d9
fix
fcurdi Aug 22, 2020
b597c47
comments and rename
fcurdi Aug 22, 2020
ca7547e
Merge branch 'code-generator' into tac_to_bytecode
fcurdi Aug 22, 2020
bddf7e2
remove comment
fcurdi Aug 23, 2020
65e8cf1
simplify examplesExe
fcurdi Aug 23, 2020
0630f86
Merge branch 'code-generator' into tac_to_bytecode
fcurdi Aug 23, 2020
d78121f
remove unnecesary dependency
fcurdi Aug 23, 2020
116e3dc
add some constructor overloads needed for tac to bytecode translation
fcurdi Aug 23, 2020
6f3178d
Merge branch 'feature/bytecode_constructor_overloads' into code-gener…
fcurdi Aug 23, 2020
5c843b5
Merge branch 'code-generator' into tac_to_bytecode
fcurdi Aug 23, 2020
8c1b12b
fix whitespaces
fcurdi Aug 23, 2020
1ae23da
fix whitespaces
fcurdi Aug 23, 2020
be0c861
fix type of this parameter in generic method body
fcurdi Aug 23, 2020
f79b138
Merge branch 'fix/this_parameter_generic_type' into code-generator
fcurdi Aug 23, 2020
86c1fa4
Merge branch 'code-generator' into tac_to_bytecode
fcurdi Aug 23, 2020
56aca9b
fix merge
fcurdi Aug 23, 2020
651ef30
fix merge
fcurdi Aug 23, 2020
baba985
more tests
fcurdi Aug 24, 2020
9a0e327
fix type inferer
fcurdi Aug 24, 2020
7e15be5
retrieve generic parameter instantiated type
fcurdi Aug 24, 2020
423252b
Merge branch 'fix/type_inference_generics' into code-generator
fcurdi Aug 24, 2020
efbae26
Merge branch 'code-generator' into tac_to_bytecode
fcurdi Aug 24, 2020
48d360a
whitespaces
fcurdi Aug 26, 2020
4871b18
remove comments
fcurdi Aug 26, 2020
4963545
rename enum
fcurdi Aug 30, 2020
4cb4914
Merge branch 'feature/add_assembly_kind' into code-generator
fcurdi Aug 30, 2020
2e217bf
refactor
fcurdi Aug 30, 2020
9056170
refactor
fcurdi Aug 30, 2020
a7bb1f6
refactor
fcurdi Aug 30, 2020
e24113d
more refactors. Packages and more classes
fcurdi Aug 30, 2020
2664030
remove comment
fcurdi Aug 30, 2020
bbc94ad
more interesting Program examples
fcurdi Oct 5, 2020
aa9c64f
refactor
fcurdi Oct 17, 2020
4ad8c9b
encoders refactor
fcurdi Oct 18, 2020
703cf99
finish refactor
fcurdi Nov 1, 2020
1c76aef
add comment
fcurdi Nov 1, 2020
a140929
comments + refactor file name
fcurdi Nov 1, 2020
33185e8
correctly calculate max stack by using CFG
fcurdi Nov 24, 2020
d125c1e
refactor example
fcurdi Nov 28, 2020
377fb9a
read assembly attributes
fcurdi Dec 17, 2020
e5ee380
Merge branch 'metadata_provider_fixes' into code-generator
fcurdi Dec 17, 2020
08fec7c
generate assembly attributes
fcurdi Dec 17, 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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
bin
obj
.vs
/packages
/packages
.DS_Store
.idea
TestResult.xml
26 changes: 26 additions & 0 deletions Backend/Analyses/TypeInferenceAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Backend.Model;
using Model.ThreeAddressCode.Values;
using Backend.Utils;
using Model;

namespace Backend.Analyses
{
Expand Down Expand Up @@ -56,6 +57,27 @@ public override void Visit(MethodCallInstruction instruction)
if (instruction.HasResult)
{
instruction.Result.Type = instruction.Method.ReturnType;

// if returnType is a genericParameter that is instantiated, then use its instantiated type
if (instruction.Method.ReturnType is IGenericParameterReference genericParameterReference)
{
IList<IType> genericArguments;
switch (genericParameterReference.Kind)
{
case GenericParameterKind.Type:
genericArguments = ((IBasicType) genericParameterReference.GenericContainer).GenericArguments;
break;
case GenericParameterKind.Method:
genericArguments = ((IMethodReference) genericParameterReference.GenericContainer).GenericArguments;
break;
default:
throw genericParameterReference.Kind.ToUnknownValueException();
}
if (genericArguments.Count > 0)
{
instruction.Result.Type = genericArguments[genericParameterReference.Index];
}
}
}

// Skip implicit "this" parameter.
Expand Down Expand Up @@ -325,6 +347,10 @@ instruction.RightOperand is Constant &&
}
}
}
public override void Visit(FilterInstruction instruction)
{
instruction.Result.Type = instruction.ExceptionType;
}
}

#endregion
Expand Down
2 changes: 2 additions & 0 deletions Backend/Backend.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
<Compile Include="Analyses\PointsToAnalysis.cs" />
<Compile Include="Analyses\ReachingDefinitionsAnalysis.cs" />
<Compile Include="Model\PointsToGraph.cs" />
<Compile Include="Transformations\Assembly\Assembler.cs" />
<Compile Include="Transformations\Assembly\ExceptionInformationBuilder.cs" />
<Compile Include="Transformations\Disassembler.cs" />
<Compile Include="Transformations\StaticSingleAssignment.cs" />
<Compile Include="Analyses\SymbolicAnalysis.cs" />
Expand Down
Loading