📄 systemfun.cpp
字号:
#include "stdafx.h"
#include <string.h>
#include "symbol.h"
#include "memory.h"
#include "error.h"
SYMBOL *s_SysFun;
char *codeSignature(DECL *f, TYPE *t);
FUNCTION *funCinit;
/* 手工生成系统函数的符号表 */
void generateSymbol_SysFun()
{
SYMBOL *s;
FUNCTION *f;
DECL *d, *d1;
TYPE *t, *t1;
t1 = makeTYPEvoid();
d = NULL;
f = makeFUNCTION("cinit", t1, d, NULL);
f->formals = d;
f->signature = codeSignature(f->formals,f->type);
funCinit = f;
s = NEW(SYMBOL);
s->name = "cinit";
s->kind = functionSym;
s->val.functionS = f;
s->next = s_SysFun;
s_SysFun = s;
t = makeTYPEstring();
t1 = makeTYPEvoid();
d = makeDECLformal(t, "name");
f = makeFUNCTION("printf", t1, d, NULL);
f->formals = d;
f->signature = codeSignature(f->formals,f->type);
s = NEW(SYMBOL);
s->name = "printf";
s->kind = functionSym;
s->val.functionS = f;
s->next = s_SysFun;
s_SysFun = s;
t = makeTYPEint();
d = makeDECLformal(t, "a");
d1 = makeDECLformal(t, "b");
f = makeFUNCTION("printf", t, d, NULL);
f->formals = d;
d->next = d1;
f->signature = codeSignature(f->formals,f->type);
s = NEW(SYMBOL);
s->name = "getsum";
s->kind = functionSym;
s->val.functionS = f;
s->next = s_SysFun;
s_SysFun = s;
}
SYMBOL *getSymbol_SysFun(char *name)
{
SYMBOL *s;
for (s = s_SysFun; s; s = s->next) {
if (strcmp(s->name,name)==0)
return s;
}
return NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -