changeset 267:d2b70cba661e

Warning cleanup
author Michael Pavone <pavone@retrodev.com>
date Fri, 18 Jul 2014 00:14:22 -0700
parents 75dc7161c1ca
children 123e9468d55e
files cbackend.js modules/string.tp runtime/object.c runtime/object.h
diffstat 4 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/cbackend.js	Thu Jul 17 23:57:41 2014 -0700
+++ b/cbackend.js	Fri Jul 18 00:14:22 2014 -0700
@@ -93,7 +93,7 @@
 	if (info.type == 'toplevel') {
 		return toplevel.moduleVar(name);
 	} else if (info.type == 'self' && info.def instanceof lambda) {
-		return 'mcall(' + getMethodId(name) + '/* ' + name + ' */, 1, ' + (new symbol('self', this.symbols)).toC() + ')';
+		return 'mcall(' + getMethodId(name) + '/* ' + name + ' */, 1, (object *)' + (new symbol('self', this.symbols)).toC() + ')';
 	} else if (info.type == 'parent' && info.def instanceof lambda) {
 		var obj = (new symbol('self', this.symbols)).toC() + '->header.';
 		for (var i = 0; i < info.depth; ++i) {
@@ -449,7 +449,7 @@
 		this.addMessage(propname, {
 			vars: {},
 			lines: [
-				'return self->' + escaped + ';'
+				'return (object *)self->' + escaped + ';'
 		]});
 		this.addMessage(propname + '!', {
 			vars: {},
@@ -1086,7 +1086,7 @@
 	}
 	if (compiled.length) {
 		if (exprs[exprs.length - 1] instanceof assignment) {
-			compiled.push('return ' + exprs[exprs.length - 1].symbol.toC() + ';');
+			compiled.push('return (object *)' + exprs[exprs.length - 1].symbol.toC() + ';');
 		} else {
 			compiled[compiled.length-1] = 'return (object *)(' + compiled[compiled.length-1] + ');';
 		}
@@ -1205,7 +1205,14 @@
 		this.symbols.declareVar(this.symbol.name);
 		debugprint('//declared var', this.symbol.name);
 	}
-	return prefix + this.symbol.toC() + ' = ' + val;
+	var cast = '';
+	if (this.symbol.name == 'self') {
+		//ugly hack alert
+		cast = '(void *)';
+	} else {
+		cast = '(object *)';
+	}
+	return prefix + this.symbol.toC() + ' = ' + cast + val;
 };
 assignment.prototype.toCObject = function(cobj) {
 	debugprint('//message definition', this.symbol.name);
--- a/modules/string.tp	Thu Jul 17 23:57:41 2014 -0700
+++ b/modules/string.tp	Fri Jul 18 00:14:22 2014 -0700
@@ -61,7 +61,7 @@
 		argb <- (string ptr)
 		out <- (string ptr)
 	} andCode: :argbo {
-		argb <- mcall: string 1 argbo
+		argb <- (mcall: string 1 argbo) castTo: (string ptr)
 		out <- make_object: (addr_of: string_meta) NULL 0
 		out bytes!: bytes + (argb bytes)
 		out len!: len + (argb len)
@@ -173,7 +173,7 @@
 		i <- uint32_t
 		notFound <- uint32_t
 	} andCode: :oneedle :startpos :ifNotFound {
-		sneedle <- mcall: string 1 oneedle
+		sneedle <- (mcall: string 1 oneedle) castTo: (string ptr)
 		i <- startpos num
 		notFound <- 1
 		while: { notFound && i + (sneedle bytes) <= bytes} do: {
--- a/runtime/object.c	Thu Jul 17 23:57:41 2014 -0700
+++ b/runtime/object.c	Fri Jul 18 00:14:22 2014 -0700
@@ -4,7 +4,7 @@
 #include <stddef.h>
 #include <gc/gc.h>
 
-object * make_object(obj_meta * meta, void * parent, int num_props, ...)
+void * make_object(obj_meta * meta, void * parent, int num_props, ...)
 {
 	va_list args;
 	object * newobj = GC_MALLOC(meta->size);
--- a/runtime/object.h	Thu Jul 17 23:57:41 2014 -0700
+++ b/runtime/object.h	Fri Jul 18 00:14:22 2014 -0700
@@ -37,7 +37,7 @@
 object * mcall(uint32_t method_id, uint32_t num_args, object * self, ...);
 #define ccall(clos, num_args, ...) (((lambda *)clos)->func(((lambda *)clos)->env, num_args,##__VA_ARGS__))
 
-object * make_object(obj_meta * meta, void * parent, int num_props, ...);
+void * make_object(obj_meta * meta, void * parent, int num_props, ...);
 object * make_lambda(void * env, closure_func func);
 object * make_array(uint32_t num_els, ...);
 object * make_list(uint32_t num_els, ...);