[Instructions] [Search] [Current] [Syllabus] [Handouts] [Outlines] [Assignments]
Held Friday, November 13, 1998
Notes
str = "hello"
MEM operation).
Frame module.
And and Or to
If.
And, you branch based on the
first part of the And. If it's true, you do the
second part of the And. If the first part is false,
you branch to the false label.
Or, you again branch based on the
first part of the Or. If the first part is true, you
branch to the true label. If the first part is false, you branch to
the second half of the Or.
translate(IfExp(int pos, Abs.Exp test, Abs.Exp texp, Abs.Exp fexp)) =
Label tlab = new Label();
Label flab = new Label();
Label endlab = new Label();
Tree.Exp cond = translate(test);
Tree.Exp tcode = translate(texp);
Tree.Exp fcode = translate(fexp);
return SEQ(cond.cx(tlab,flab),
SEQ(Label(tlab),
SEQ(tcode,
SEQ(JUMP(Name endlab), ExpList(endlab, null),
SEQ(Label(flab),
SEQ(fcode,
SEQ(JUMP(Name endlab), ExpList(endlab, null),
SEQ(Label(endlab)
))))))))
History
Back to Translating variables and data. On to More control structures.
[Instructions] [Search] [Current] [Syllabus] [Handouts] [Outlines] [Assignments]
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Mon Nov 16 09:17:17 1998.
This page generated on Mon Nov 16 09:29:09 1998 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu