diff README @ 192:b0d6a6940cb7

*** empty log message ***
author kono
date Tue, 02 Dec 2003 12:18:54 +0900
parents
children 8a72b0afccfc
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README	Tue Dec 02 12:18:54 2003 +0900
@@ -0,0 +1,149 @@
+C with Continuation (CwC) and Continuation based C (CbC)
+   $Id$
+             Shinji Kono
+             University of the Ryukyus
+             2003 December
+
+0. What is this.
+
+This is a extension of C ( and a subset of C ). It has a 
+programming unit which is called code segment.  Code
+segment can be communicate with so called light weight continuation.
+
+
+    #include <stdio.h>
+
+    code factorial(int n,int result,int orig,
+         code(*print)(),code(*exit1)(), void *exit1env)
+    {
+	if (n<0) {
+	    printf("err %d!\n",n);
+	    goto (*exit1)(0),exit1env;
+	}
+	if (n==0)
+	    goto (*print)(n,result,orig,print,exit1,exit1env);
+	else {
+	    result *= n;
+	    n--;
+	    goto factorial(n,result,orig,print,exit1,exit1env);
+	}
+    }
+
+    int main( int ac, char *av[])
+    {
+	int n;
+	n = 10;
+	goto factorial(n,1,n,print,return,environment);
+    }
+
+    code print(int n,int result,int orig,code(*print)(),(*exit1)(),void*exit1env)
+    {
+	printf("%d! = %d\n",orig, result);
+	goto (*exit1)(0),exit1env;
+    }
+
+If you don't use function call, this language becomes subset of C.
+It is called Continuation based C. Actually it can be a lower layer of
+C language.  Normal C program can be compiled into CbC.
+
+CbC is a kind of architecture independent assembler language.
+
+1. Syntax
+
+      code  code_segment_name(interfaces) {
+         body;
+      }
+
+code is a type for code segment. A code segment has no return
+statements. 
+
+Interfaces are arguments. It can be struts. or unions. Some
+part of interfaces are mapped into registers. No
+references are allowed in register interface variables.
+
+Goto statements transfer the control from a segment
+to a segment.
+      goto segment_name(interfaces);
+If two code segments has a same interfaces, transfer cost is very
+small. It us usually a single jump instruction.
+If there are differences, some parallel assignment is performed.
+
+2. Interaction between function and code segment.
+
+In CwC, you can call C function at any time in code segments.
+If you want to call code segment from C and want to do some
+return, explicit handling of function environment.
+
+	goto factorial(n,1,n,print,return,environment);
+
+return and environment is a special variable which contains
+return point. An environment variable is something like jumpbuf
+in setjump, but it is a simple pointer. Unlike jumpbuf,
+there is no way to allocate are for environment.
+       void *environment;
+
+A return variable is a continuation with environment of
+original function. It's type is varied for called function.
+
+       code (*return)(int return_value);
+
+To go to the continuation, use goto with environment.
+
+       goto (*exit1)(0),exit1env;
+
+3. How to use
+
+mc-powerpc, mc-ia32 is a compiler. It generates assembler
+source code .s from C source code. 
+
+     mc-powerpc source.c
+     gcc source.s
+generates a.out.
+     mc-powerpc source.c
+     gcc -c sources.s
+generates sources.o
+
+     -s comments in assembler source.
+     -c check only.
+     -oname  output file names
+     -Idir   add library include directory
+
+Some examples can be fond in test directory.
+
+3. Unimplemented lists
+
+Mips version is not ready.
+
+long long, long double, unsigned long long can be used as type,
+but no operation (including assignment) are no allowed.
+
+Long long value (0LL) can be used but it gives long value. 
+Long is equal to an int and a pointer (32bit).
+
+Only Mac OS X and Red hat Linux is supported.
+
+Inline directive is ignored and gives normal function definition.
+
+Register float arguments does no accepts assignment operation such as
+    *=, /=, +=.
+
+No built-in alloca.
+
+No varargs.
+
+Switch statements is implemented as series of compare and branch,
+no tables.
+
+Some operations such as concatenation are not implemented in macro
+processor.
+
+Macro processor is a coroutine in this compiler, slightly different
+from cpp.
+
+No  -g support.
+
+No runtime driver for CbC.
+
+ #include does not search, sources current directory.
+
+