public void CGenDecln(Env env, CGenState state) { // .text // [.globl <func>] // <func>: // pushl %ebp // movl %esp, %ebp // state.TEXT(); Env.Entry entry = env.Find(this.name).Value; state.COMMENT(ToString()); switch (entry.Kind) { case Env.EntryKind.GLOBAL: switch (this.scs) { case StorageClass.AUTO: case StorageClass.EXTERN: state.GLOBL(this.name); break; case StorageClass.STATIC: // static definition break; default: throw new InvalidOperationException(); } break; default: throw new InvalidOperationException(); } state.CGenFuncStart(this.name); state.InFunction(GotoLabelsGrabber.GrabLabels(this.stmt)); this.stmt.CGenStmt(env, state); state.CGenLabel(state.ReturnLabel); state.OutFunction(); // leave // ret state.LEAVE(); state.RET(); state.NEWLINE(); }
public void CGenDecln(Env env, CGenState state) { // .text // [.globl <func>] // <func>: // pushl %ebp // movl %esp, %ebp // state.TEXT(); Env.Entry entry = env.Find(name).Value; state.COMMENT(ToString()); switch (entry.kind) { case Env.EntryKind.GLOBAL: switch (scs) { case Decln.SCS.AUTO: case Decln.SCS.EXTERN: state.GLOBL(name); break; case Decln.SCS.STATIC: // static definition break; default: throw new InvalidOperationException(); } break; default: throw new InvalidOperationException(); } state.CGenFuncStart(name); state.InFunction(GotoLabelsGrabber.GrabLabels(this.stmt)); stmt.CGenStmt(env, state); state.CGenLabel(state.ReturnLabel); state.OutFunction(); // leave // ret state.LEAVE(); state.RET(); state.NEWLINE(); }