uhmanoa-transpiler-project / shaka-scheme

The official repository for the UH Manoa Transpiler Project's Scheme interpreter, Shaka Scheme.
32 stars 24 forks source link

Basic DataPair implementation (used for representing Scheme data pairs) #25

Closed CinchBlue closed 7 years ago

CinchBlue commented 7 years ago

First of all, there are a few background changes that I made for building, etc.:

In Data, certain changes were also made:

Here is a basic implementation of DataPairs that holds two references to other Data.

NodePtr is a using alias that resolves to std::shared_ptr<shaka::Data> for now. It is known that this implementation is broken if we are dealing with reference cycles that may appear due to the presence of circular lists, etc. We are expecting to replace this faulty implementation of managed data pointers in the future with a proper garbage collection system that is designed to detect cycle detection and break ownership chains as necessary for proper memory management.

It implements four major functions:

Please also review whether my implementation of deep copying of Data to other Data in the copy constructor in Data(const Data& other) is correct. I'm not sure if it is.

CinchBlue commented 7 years ago

https://github.com/uhmanoa-transpiler-project/shaka-scheme/pull/25/commits/4d5461ed727cadf85aaa2c5dc6ea039ea8d1cb4b is a commit that fixes the last unit test that was broken because it was trying to construct a shaka::String using the double-quoted version that was printed to the output std::stringstream used for testing and then compare it back to the original. I changed the test to comparing the outputted string to "Hello world" which works.

CinchBlue commented 7 years ago

@Mortrax I have completed the small typo changes in DataPair's copy constructor. Thanks for the catch.