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

Added in Symbol Tables #2

Merged
merged 42 commits into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3d931b8
Added symbol tables and got definitions to be renamed
NickyBoy89 Apr 19, 2022
bc106a0
Made all types draw from the symbol table
NickyBoy89 Apr 19, 2022
8eb3246
Fixed the source of renaming, and refactored the names of the public/…
NickyBoy89 Apr 20, 2022
c9c5731
Started with second pass of type checks and some cleanup
NickyBoy89 Apr 24, 2022
a8c43ce
Finished up second stage type resolving and added another test case f…
NickyBoy89 May 3, 2022
db14013
fix: Rename typecheck.go to symbols.go to reflect more of the functio…
NickyBoy89 May 3, 2022
83501f9
Change parser to load files into memory instead of reading them repea…
NickyBoy89 May 8, 2022
7a484b7
Changed search method to use the type's parameters, and refactored ty…
NickyBoy89 May 10, 2022
8c47258
Added initial steps for identifier renaming, and changed test cases t…
NickyBoy89 May 11, 2022
5bd51d8
Added renaming for parameters
NickyBoy89 May 11, 2022
09a6368
Added multi-dimensional array initializers
NickyBoy89 May 12, 2022
3c12355
Added renaming for class accessors
NickyBoy89 May 12, 2022
8efb85d
Started renaming constructors, and fixed a bug in looking up methods
NickyBoy89 May 12, 2022
0ee1956
Removed old filter for classes
NickyBoy89 May 12, 2022
d0a1135
Updated version of quiltflower in script
NickyBoy89 May 12, 2022
266ab35
Quit immediately if there is nothing to do
NickyBoy89 May 12, 2022
b6796c9
Handled spread parameters correctly
NickyBoy89 May 12, 2022
c936f31
Added hacky workaround for current issues and got files to transpile …
NickyBoy89 May 13, 2022
c37db32
Fixed too many open files when writing output to disk
NickyBoy89 May 13, 2022
66123f0
Added support for renaming calls to constructors
NickyBoy89 May 13, 2022
3ca5d22
Added support for unresolved constructors, and fixed looking up const…
NickyBoy89 May 18, 2022
017ca0b
Added support for scoped type identifiers and correctly renamed field
NickyBoy89 May 18, 2022
1062a77
Fixed variable lookups in the global variables, and fixed variable lo…
NickyBoy89 May 18, 2022
06004b4
Fixed some errors in scrambled loop test case
NickyBoy89 May 19, 2022
6d135d0
Change to handle method declarations correctly in interfaces
NickyBoy89 May 19, 2022
0d822f3
Added general-purpose renaming for duplicate methods
NickyBoy89 May 20, 2022
01a328e
Refactored some function names and added renaming support for global …
NickyBoy89 May 21, 2022
1f79b50
Refactored definitions to store subclasses
NickyBoy89 May 21, 2022
8e1a4a6
Work-in-progress changes for a large refactor
NickyBoy89 Jun 5, 2022
bd868a2
Separated out all of the files, and got everything to compile
NickyBoy89 Jun 5, 2022
2b6936a
Start of major refactor, but not compiling yet
NickyBoy89 Aug 19, 2022
abe2265
Another step on the refactor
NickyBoy89 Aug 20, 2022
33a2b3b
Refactored a lot of the search code and started on tidying the symbol…
NickyBoy89 Aug 20, 2022
19f56e6
Added a flag to turn off symbol generation
NickyBoy89 Aug 22, 2022
467aa38
Fixed an immediate crash with symbols turned off
NickyBoy89 Aug 22, 2022
b6d3ad5
Fixed method symbol parsing
NickyBoy89 Aug 22, 2022
91081dd
Refactored the lambda code and added more searching logic
NickyBoy89 Aug 25, 2022
91f4f67
Refactored a lot of the context code to be more class-aware, and
NickyBoy89 Aug 27, 2022
b705ef4
Fixed indexing in subclasses and constructors
NickyBoy89 Aug 28, 2022
4f97b61
Fixed some more lookups
NickyBoy89 Aug 28, 2022
996bc06
Fixed type parsing for array creating expressions
NickyBoy89 Aug 28, 2022
a7ffd07
Fixed symbol parsing
NickyBoy89 Aug 28, 2022
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Helper script for decompiling some files for testing

fernflower = fabric-fernflower-1.4.1+local.jar
quiltflower = quiltflower-1.7.0+local.jar
quiltflower = quiltflower-1.8.1+local.jar
namedjar = 1.16.5-named.jar
procyon = `curl --silent https://api.github.com/repos/mstrobel/procyon/releases/latest | jq -r .assets[0].name`

Expand Down
61 changes: 61 additions & 0 deletions astutil/type_parsing.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package astutil

import (
"fmt"
"go/ast"

sitter "github.com/smacker/go-tree-sitter"
)

func ParseType(node *sitter.Node, source []byte) ast.Expr {
switch node.Type() {
case "integral_type":
switch node.Child(0).Type() {
case "int":
return &ast.Ident{Name: "int32"}
case "short":
return &ast.Ident{Name: "int16"}
case "long":
return &ast.Ident{Name: "int64"}
case "char":
return &ast.Ident{Name: "rune"}
case "byte":
return &ast.Ident{Name: node.Content(source)}
}

panic(fmt.Errorf("Unknown integral type: %v", node.Child(0).Type()))
case "floating_point_type": // Can be either `float` or `double`
switch node.Child(0).Type() {
case "float":
return &ast.Ident{Name: "float32"}
case "double":
return &ast.Ident{Name: "float64"}
}

panic(fmt.Errorf("Unknown float type: %v", node.Child(0).Type()))
case "void_type":
return &ast.Ident{}
case "boolean_type":
return &ast.Ident{Name: "bool"}
case "generic_type":
// A generic type is any type that is of the form GenericType<T>
return &ast.Ident{Name: node.NamedChild(0).Content(source)}
case "array_type":
return &ast.ArrayType{Elt: ParseType(node.NamedChild(0), source)}
case "type_identifier": // Any reference type
switch node.Content(source) {
// Special case for strings, because in Go, these are primitive types
case "String":
return &ast.Ident{Name: "string"}
}

return &ast.StarExpr{
X: &ast.Ident{Name: node.Content(source)},
}
case "scoped_type_identifier":
// This contains a reference to the type of a nested class
// Ex: LinkedList.Node
return &ast.StarExpr{X: &ast.Ident{Name: node.Content(source)}}
}
panic("Unknown type to convert: " + node.Type())
}
Loading