LLVMValueRef param) {
LLVMValueRef stack[MAX_DEPTH];
int depth = 0;
+ int i;
- for (int i = 0; i < ntokens; i++) {
+ for (i = 0; i < ntokens; i++) {
char tok = tokens[i][0];
switch (tok) {
case '+':
break;
- case '@':
+ case '@': {
+ LLVMValueRef off;
+
if (depth < 1) {
printf("stack underflow\n");
return NULL;
}
- LLVMValueRef off = LLVMBuildGEP(builder, param, &stack[depth - 1], 1, "");
+ off = LLVMBuildGEP(builder, param, &stack[depth - 1], 1, "");
stack[depth - 1] = LLVMBuildLoad(builder, off, "");
break;
+ }
default: {
char *end;
static void handle_line(char **tokens, int ntokens) {
char *name = tokens[0];
+ LLVMValueRef param;
+ LLVMValueRef res;
LLVMModuleRef M = LLVMModuleCreateWithName(name);
LLVMBuilderRef builder = LLVMCreateBuilder();
LLVMPositionBuilderAtEnd(builder, LLVMAppendBasicBlock(F, "entry"));
- LLVMValueRef param;
LLVMGetParams(F, ¶m);
LLVMSetValueName(param, "in");
- LLVMValueRef res = build_from_tokens(tokens + 1, ntokens - 1, builder, param);
+ res = build_from_tokens(tokens + 1, ntokens - 1, builder, param);
if (res) {
char *irstr = LLVMPrintModuleToString(M);
puts(irstr);