diff options
Diffstat (limited to 'environment.c')
| -rw-r--r-- | environment.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/environment.c b/environment.c index 84f6880e..8de3fc20 100644 --- a/environment.c +++ b/environment.c @@ -11,6 +11,7 @@ type_t *TEXT_TYPE = NULL; type_t *RANGE_TYPE = NULL; +public type_t *THREAD_TYPE = NULL; env_t *new_compilation_unit(CORD *libname) { @@ -68,6 +69,11 @@ env_t *new_compilation_unit(CORD *libname) .next=new(arg_t, .name="step", .type=INT_TYPE, .default_val=FakeAST(Int, .i=1, .bits=64))))); } + { + env_t *thread_env = namespace_env(env, "Thread"); + THREAD_TYPE = Type(StructType, .name="Thread", .env=thread_env, .opaque=true); + } + struct { const char *name; type_t *type; @@ -215,6 +221,12 @@ env_t *new_compilation_unit(CORD *libname) {"upper", "Text$upper", "func(text:Text)->Text"}, {"without", "Text$without", "func(text:Text, target:Text, where=Where.Anywhere)->Text"}, )}, + {"Thread", THREAD_TYPE, "pthread_t*", "Thread", TypedArray(ns_entry_t, + {"new", "Thread$new", "func(fn:func()->Void)->Thread"}, + {"cancel", "Thread$cancel", "func(thread:Thread)->Void"}, + {"join", "Thread$join", "func(thread:Thread)->Void"}, + {"detach", "Thread$detach", "func(thread:Thread)->Void"}, + )}, }; for (size_t i = 0; i < sizeof(global_types)/sizeof(global_types[0]); i++) { |
