Skip to content

Commit

Permalink
Merge pull request #44 from fabiosvm/feature/import-external-file
Browse files Browse the repository at this point in the history
Add support for importing external file
  • Loading branch information
fabiosvm authored Aug 7, 2023
2 parents 926ff04 + 6afa686 commit 06c24a7
Show file tree
Hide file tree
Showing 15 changed files with 419 additions and 79 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[![Build and test](https://github.com/fabiosvm/hook-lang/actions/workflows/build.yml/badge.svg)](https://github.com/fabiosvm/hook-lang/actions/workflows/build.yml)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f2f1345083c1455683dabcf48b0ea6dd)](https://www.codacy.com/gh/fabiosvm/hook-lang/dashboard?utm_source=github.com&utm_medium=referral&utm_content=fabiosvm/hook-lang&utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f2f1345083c1455683dabcf48b0ea6dd)](https://app.codacy.com/gh/fabiosvm/hook-lang/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![codecov](https://codecov.io/gh/fabiosvm/hook-lang/branch/main/graph/badge.svg?token=mkmMpfS1yu)](https://codecov.io/gh/fabiosvm/hook-lang)

# The Hook Programming Language
Expand Down
21 changes: 21 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_library(math_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/compiler.c
../src/iterable.c
Expand All @@ -31,6 +32,7 @@ add_library(os_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/compiler.c
../src/iterable.c
Expand All @@ -52,6 +54,7 @@ add_library(io_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/compiler.c
../src/iterable.c
Expand All @@ -73,12 +76,14 @@ add_library(numbers_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -92,12 +97,14 @@ add_library(strings_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -111,12 +118,14 @@ add_library(arrays_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -130,13 +139,15 @@ add_library(utf8_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/state.c
../src/range.c
../src/scanner.c
../src/string_map.c
../src/string.c
../src/struct.c
Expand All @@ -156,12 +167,14 @@ add_library(hashing_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -179,12 +192,14 @@ add_library(encoding_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -198,12 +213,14 @@ add_library(socket_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -218,12 +235,14 @@ add_library(json_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -237,12 +256,14 @@ add_library(lists_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand Down
2 changes: 1 addition & 1 deletion core/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void file_deinit(HkUserdata *udata)
FILE *stream = ((File *) udata)->stream;
if (stream == stdin || stream == stdout || stream == stderr)
return;
fclose(stream);
(void) fclose(stream);
}

static void open_call(HkState *state, HkValue *args)
Expand Down
10 changes: 10 additions & 0 deletions examples/import.hk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// import.hk
//

import os;
import { foo, bar } from module;

println(os.clock());
println(foo());
println(bar());
17 changes: 17 additions & 0 deletions examples/module.hk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// module.hk
//

struct module {
foo, bar
}

fn foo() {
return 1;
}

fn bar() {
return 2;
}

return module { foo, bar };
20 changes: 20 additions & 0 deletions extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ add_library(sqlite_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -67,12 +69,14 @@ add_library(curl_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -86,12 +90,14 @@ add_library(redis_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -106,12 +112,14 @@ add_library(secp256r1_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -125,12 +133,14 @@ add_library(fastcgi_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -144,12 +154,14 @@ add_library(mysql_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -163,12 +175,14 @@ add_library(bigint_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -182,12 +196,14 @@ add_library(zeromq_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -201,12 +217,14 @@ add_library(leveldb_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand All @@ -221,12 +239,14 @@ add_library(crypto_mod SHARED
../src/builtin.c
../src/callable.c
../src/chunk.c
../src/compiler.c
../src/utils.c
../src/iterable.c
../src/iterator.c
../src/memory.c
../src/module.c
../src/range.c
../src/scanner.c
../src/state.c
../src/string_map.c
../src/string.c
Expand Down
6 changes: 6 additions & 0 deletions include/hook/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@

#define HK_ARRAY_MIN_CAPACITY (1 << 3)

#define hk_array_is_empty(a) (!(a)->length)
#define hk_array_get_element(a, i) ((a)->elements[(i)])

#define hk_array_inplace_clear(a) do \
{ \
(a)->length = 0; \
} while (0)

typedef struct
{
HK_OBJECT_HEADER
Expand Down
Loading

0 comments on commit 06c24a7

Please sign in to comment.