diff --git a/lib/src/http/client-request.ki b/lib/src/http/client-request.ki index 23d07f5..d6f8150 100644 --- a/lib/src/http/client-request.ki +++ b/lib/src/http/client-request.ki @@ -82,10 +82,12 @@ class ClientRequest { } } + let headers = @swap res.headers with Map[String]{}; + return ClientResponse { status: res.status, - headers: res.headers, - body: res.body, + headers: @swap res.headers with Map[String]{}, + body: @swap res.body with "", }; } diff --git a/lib/src/http/server.ki b/lib/src/http/server.ki index 0bd7077..323d143 100644 --- a/lib/src/http/server.ki +++ b/lib/src/http/server.ki @@ -245,10 +245,10 @@ class Server { let req = Request{ http_con: &http_con, - headers: res.headers, - method: res.method, - path: res.path, - body: res.body, + headers: @swap res.headers with Map[String]{}, + method: @swap res.method with "", + body: @swap res.body with "", + path: @swap res.path with "", }; let resp = handler(req); diff --git a/lib/src/net/socket-tcp.ki b/lib/src/net/socket-tcp.ki index c3d6319..529ee69 100644 --- a/lib/src/net/socket-tcp.ki +++ b/lib/src/net/socket-tcp.ki @@ -13,7 +13,7 @@ class SocketTCP async { - addrinfo: sys.cstruct_addrinfo; - connection: ?Connection = null; - static fn new(host: String, port: u16, blocking: bool = true) SocketTCP !os_socket_create !invalid_host { + static fn new(host: *String, port: u16, blocking: bool = true) SocketTCP !os_socket_create !invalid_host { #if OS == win os:WSA_init(); @@ -63,7 +63,7 @@ class SocketTCP async { #end return SocketTCP{ - host: host, + host: host + "", port: port, fd: fd, blocking: blocking, diff --git a/lib/src/net/socket.ki b/lib/src/net/socket.ki index 7ccaa34..fdc095c 100644 --- a/lib/src/net/socket.ki +++ b/lib/src/net/socket.ki @@ -4,7 +4,7 @@ header "sys" as sys; use io; class Socket { - static fn new_tcp(host: String, port: u16, blocking: bool = true) SocketTCP !init_error { + static fn new_tcp(host: *String, port: u16, blocking: bool = true) SocketTCP !init_error { return SocketTCP.new(host, port, blocking) !! throw init_error;; } diff --git a/lib/src/type/string.ki b/lib/src/type/string.ki index 0f140e2..614bc16 100644 --- a/lib/src/type/string.ki +++ b/lib/src/type/string.ki @@ -5,7 +5,7 @@ use mem; use os; -class String type:ptr rc { +class String type:ptr track rc { ///////////////////// // Core diff --git a/src/build/stage-1-parse.c b/src/build/stage-1-parse.c index f2ac692..f1fc4f8 100644 --- a/src/build/stage-1-parse.c +++ b/src/build/stage-1-parse.c @@ -214,7 +214,7 @@ void stage_1_class(Fc *fc, bool is_struct) { class->scope = scope_init(fc->alc, sct_class, fc->scope, false); class->is_struct = is_struct; class->is_rc = !is_struct; - class->track_ownership = false; + class->track_ownership = !is_struct; class->def_chunk = def_chunk; array_push(fc->classes, class); @@ -265,6 +265,7 @@ void stage_1_class(Fc *fc, bool is_struct) { while (strcmp(token, "{") != 0) { if (strcmp(token, "type") == 0) { class->is_rc = false; + class->track_ownership = false; tok_expect(fc, ":", true, false); tok(fc, token, true, false); if (strcmp(token, "ptr") == 0) { diff --git a/src/build/type.c b/src/build/type.c index 529baf5..b46423e 100644 --- a/src/build/type.c +++ b/src/build/type.c @@ -624,11 +624,14 @@ void type_check(Fc *fc, Type *t1, Type *t2) { } } +bool type_tracks_usage(Type *type) { + // + return type_tracks_ownership(type) || type_is_rc(type); +} + bool type_is_rc(Type *type) { - Class *class = type->class; - if (!class) - return false; - return class->is_rc; + // + return type->class && type->class->is_rc; } bool type_tracks_ownership(Type *type) { diff --git a/src/build/value-gen.c b/src/build/value-gen.c index 43340a1..af53f23 100644 --- a/src/build/value-gen.c +++ b/src/build/value-gen.c @@ -98,8 +98,8 @@ Value *vgen_class_pa(Allocator *alc, Scope *scope, Value *on, ClassProp *prop) { if (scope && type_tracks_ownership(prop_type)) { item->cache_llvm_val = true; - if (prop_type->class && prop_type->class->is_circular) - prop_type->shared_ref = true; + // if (prop_type->class && prop_type->class->is_circular) + prop_type->shared_ref = true; Value *from = vgen_ir_from(alc, res); item->deref_token = tgen_ref_change_exec(alc, scope, from, -1); diff --git a/src/build/value.c b/src/build/value.c index ee479dd..f900e0e 100644 --- a/src/build/value.c +++ b/src/build/value.c @@ -132,6 +132,8 @@ Value *read_value(Fc *fc, Allocator *alc, Scope *scope, bool sameline, int prio, sprintf(fc->sbuf, "The first argument in '@swap' must be assignable. e.g. a variable"); fc_error(fc); } + value_disable_upref_deref(var); + if (var->type == v_decl) { Decl *decl = var->item; if (!decl->is_mut) { @@ -1754,6 +1756,7 @@ void value_disable_upref_deref(Value *val) { exec = pa->upref_token->item; exec->enable = false; } + val->rett = pa->prop->type; } if (val->type == v_array_item) { VArrayItem *ai = val->item; diff --git a/src/headers/functions.h b/src/headers/functions.h index 952457c..f786efd 100644 --- a/src/headers/functions.h +++ b/src/headers/functions.h @@ -264,6 +264,7 @@ char *type_to_str(Type *t, char *res, bool simple); void type_check(Fc *fc, Type *t1, Type *t2); Type *type_clone(Allocator *alc, Type *type); bool type_tracks_ownership(Type *type); +bool type_tracks_usage(Type *type); bool type_is_rc(Type *type); bool type_allowed_async(Type *type, bool recursive); Type *type_get_inline(Allocator *alc, Type *type);