Skip to content

Commit

Permalink
refactoring out unstable values
Browse files Browse the repository at this point in the history
  • Loading branch information
skilesare committed Jul 8, 2022
1 parent b3e83cb commit 9594520
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 1,103 deletions.
14 changes: 11 additions & 3 deletions package-set.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ let Package =
{ name : Text, version : Text, repo : Text, dependencies : List Text }

let
-- This is where you can add your own packages to the package-set
additions =
[] : List Package
[{ name = "stablerbtree"
, repo = "https://github.com/skilesare/StableRBTree"
, version = "v0.6.1"
, dependencies = [ "base"]
},
{ name = "stablebuffer"
, repo = "https://github.com/skilesare/StableBuffer"
, version = "v0.2.0"
, dependencies = [ "base"]
}] : List Package

let
{- This is where you can override existing packages in the package-set
For example, if you wanted to use version `v2.0.0` of the foo library:
let overrides = [
{ name = "foo"
, version = "v2.0.0"
, version = "v2.0"
, repo = "https://github.com/bar/foo"
, dependencies = [] : List Text
}
Expand Down
49 changes: 43 additions & 6 deletions src/clone.mo
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@
import Types "types";
import Array "mo:base/Array";

import SB "mo:stablebuffer/StableBuffer";

module {

type CandyValue = Types.CandyValue;
type CandyValueUnstable = Types.CandyValueUnstable;
type PropertyUnstable = Types.PropertyUnstable;
type Property = Types.Property;


public func cloneValueUnstable(val : CandyValueUnstable) : CandyValueUnstable{
public func clone(val : CandyValue) : CandyValue{
switch(val){
case(#Class(val)){

return #Class(Array.tabulate<PropertyUnstable>(val.size(), func(idx){
{name= val[idx].name; value=cloneValueUnstable(val[idx].value); immutable = val[idx].immutable};
return #Class(Array.tabulate<Property>(val.size(), func(idx){
{name= val[idx].name; value=clone(val[idx].value); immutable = val[idx].immutable};
}));
};
case(#Bytes(val)){
Expand All @@ -36,7 +37,43 @@ module {
};
case(#thawed(val)){

#Bytes(#thawed(val.clone()));
#Bytes(#thawed(SB.clone<Nat8>(val)));
};
}
};
case(#Nats(val)){
switch(val){
case(#frozen(val)){

#Nats(#frozen(val));
};
case(#thawed(val)){

#Nats(#thawed(SB.clone<Nat>(val)));
};
}
};
case(#Floats(val)){
switch(val){
case(#frozen(val)){

#Floats(#frozen(val));
};
case(#thawed(val)){

#Floats(#thawed(SB.clone<Float>(val)));
};
}
};
case(#Array(val)){
switch(val){
case(#frozen(val)){

#Array(#frozen(val));
};
case(#thawed(val)){

#Array(#thawed(SB.clone<CandyValue>(val)));
};
}
};
Expand Down
Loading

0 comments on commit 9594520

Please sign in to comment.