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

Add some compiler features and documentation #147

Merged
merged 3 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 12 additions & 3 deletions common/goos/TextDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,25 @@ void TextDb::link(const Object& o, std::shared_ptr<SourceText> frag, int offset)
/*!
* Given an object, get a string representing where it's from. Or "?" if we can't find it.
*/
std::string TextDb::get_info_for(const Object& o) {
std::string TextDb::get_info_for(const Object& o, bool* terminate_compiler_error) {
if (o.is_pair()) {
auto kv = map.find(o.heap_obj);
if (kv != map.end()) {
if (terminate_compiler_error) {
*terminate_compiler_error = kv->second.frag->terminate_compiler_error();
}
return get_info_for(kv->second.frag, kv->second.offset);
} else {
return "?";
if (terminate_compiler_error) {
*terminate_compiler_error = false;
}
return "?\n";
}
} else {
return "?";
if (terminate_compiler_error) {
*terminate_compiler_error = false;
}
return "?\n";
}
}

Expand Down
6 changes: 5 additions & 1 deletion common/goos/TextDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class SourceText {
virtual std::string get_description() = 0;
std::string get_line_containing_offset(int offset);
int get_line_idx(int offset);
// should the compiler keep looking up the stack when printing errors on this, or not?
// this should return true if the text source is specific enough so that they can find what they
// want
virtual bool terminate_compiler_error() { return true; }

virtual ~SourceText(){};

Expand Down Expand Up @@ -87,7 +91,7 @@ class TextDb {
public:
void insert(const std::shared_ptr<SourceText>& frag);
void link(const Object& o, std::shared_ptr<SourceText> frag, int offset);
std::string get_info_for(const Object& o);
std::string get_info_for(const Object& o, bool* terminate_compiler_error = nullptr);
std::string get_info_for(const std::shared_ptr<SourceText>& frag, int offset);

private:
Expand Down
2 changes: 1 addition & 1 deletion common/versions.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace versions {
// language version
constexpr s32 GOAL_VERSION_MAJOR = 0;
constexpr s32 GOAL_VERSION_MINOR = 2;
constexpr s32 GOAL_VERSION_MINOR = 3;
constexpr u32 ART_FILE_VERSION = 6;
constexpr u32 LEVEL_FILE_VERSION = 30;
constexpr u32 DGO_FILE_VERSION = 1;
Expand Down
4 changes: 2 additions & 2 deletions decompiler/config/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
(require-for-run uint32 :offset-assert 8)
(allow-to-run uint32 :offset-assert 12)
(next-pid int32 :offset-assert 16)
(fast-stack-top uint32 :offset-assert 20)
(fast-stack-top pointer :offset-assert 20)
(current-process basic :offset-assert 24)
(relocating-process basic :offset-assert 28)
(relocating-min int32 :offset-assert 32)
Expand Down Expand Up @@ -10885,7 +10885,7 @@
(deftype load-chunk-msg (structure)
((rsvd uint16 :offset-assert 0)
(result uint16 :offset-assert 2)
(address uint32 :offset-assert 4)
(address pointer :offset-assert 4)
(section uint32 :offset-assert 8)
(maxlen uint32 :offset-assert 12)
(id uint32 :offset 4)
Expand Down
6 changes: 5 additions & 1 deletion doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@
- Added `shl`, `shr`, and `sar` shifts which take a constant integer. These cannot be used with a variable shift amount.
- Added bitfield types to the type system
- Added the ability to cast integers to bitfield types
- Fixed a bug where casting between integer types with `the` that did not involve emitting code would permanently change the type of the variable.
- Fixed a bug where casting between integer types with `the` that did not involve emitting code would permanently change the type of the variable.
- Added a `:disassemble` option to `asm-file` to disassemble functions for debugging purposes.

## V0.3
- Added typechecking when setting fields of a type.
20 changes: 18 additions & 2 deletions doc/code_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ Needs child types of integer
## vu-macros.gc
Empty.

# Math Section

## math.gc
Has a unit test for a lot of functions.
rand-vu-init, rand-vu, rand-vu-nostep, rand-vu-float-range, rand-vu-percent?, rand-vu-int-range, rand-vu-int-count aren't implemented

rand-uint31-gen might be wrong.

## vector.gc
## vector-h.gc
Partially done

## gravity-h.gc
Expand Down Expand Up @@ -62,4 +64,18 @@ Done!
Empty File.

## transformq-h.gc
Not done.
Not done.

## bounding-box.gc

## matrix.gc

## transform.gc

## quaternion.gc

## euler.gc

## geometry.gc

## trigonometry.gc
Loading