bug fixes; added 'map.get_ptr'
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 4 Mar 2021 00:51:25 +0000 (18:51 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 4 Mar 2021 00:51:25 +0000 (18:51 -0600)
build.sh
core/builtin.onyx
core/map.onyx

index 40b6533e1c45af7ea1522527a0d6bf602d200e2a..07fbeb47b4d2776a8baa6852cb77b491feb41f65 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,12 @@
 #!/bin/sh
 
+echo "Installing core libs"
+CORE_DIR='/usr/share/onyx'
+sudo mkdir -p "$CORE_DIR"
+sudo cp -r ./core/ "$CORE_DIR"
+
+[ "$1" = "libs_only" ] && exit 0
+
 C_FILES="onyx onyxastnodes onyxbuiltins onyxchecker onyxclone onyxdoc onyxentities onyxerrors onyxlex onyxparser onyxsymres onyxtypes onyxutils onyxwasm"
 TARGET='./bin/onyx'
 CC='gcc'
@@ -30,10 +37,5 @@ echo "Installing onyx executable"
 BIN_DIR='/usr/bin'
 sudo cp ./bin/onyx "$BIN_DIR/onyx"
 
-echo "Installing core libs"
-CORE_DIR='/usr/share/onyx'
-sudo mkdir -p "$CORE_DIR"
-sudo cp -r ./core/ "$CORE_DIR"
-
 # Otherwise the prompt ends on the same line
-printf "\n"
\ No newline at end of file
+printf "\n"
index 9323fe016e18f09823e1536a423fada95578a8b3..2cb9c2a9feb06ae715deb64718db6c2599795962 100644 (file)
@@ -107,7 +107,7 @@ use package build_opts as build_opts
     use package core.intrinsics.wasm { __initialize }
 
     new :: ($T: type_expr, allocator := context.allocator, initialize := true) -> ^T {
-        res := cast(^T) calloc(sizeof T);
+        res := cast(^T) raw_alloc(allocator, sizeof T);
 
         // @Robustness: This should be a '#if' when those are added in procedures because
         // otherwise the __initialize intrinsic is going to be generated no matter what.
index 42a293cfa34463899faa5b25c8af4b19acddd745..9c5887064a78f566923982218a39ff6e777d71da 100644 (file)
@@ -68,6 +68,13 @@ get :: (use map: ^Map($K, $V), key: K) -> V {
     return default_value;
 }
 
+get_ptr :: (use map: ^Map($K, $V), key: K) -> ^V {
+    lr := lookup(map, key);
+    if lr.entry_index >= 0 do return ^entries[lr.entry_index].value;
+
+    return null;
+}
+
 delete :: (use map: ^Map($K, $V), key: K) {
     lr := lookup(map, key);
     if lr.entry_index < 0 do return;