<编译器> 7. 中间代码 | 4. 主要语句的IR树

1. 调用 output := concat(output,s)

image

image

2. 数组,赋值

a[i+1] := 0
数组变量 a[i]为 a(基地址) + i*w(偏移量)

image

3. while 循环

伪代码:

while cnd do body
start: 
        if not cnd goto done
        body
        goto start
done

两种实现:

image
image

4. for 循环: 变量声明 + while 循环 + 变量++

image
image

条件语句 if...then... , if... then ... else ...

if 语句分为有返回值 和 无返回值,有返回值的 类似于三元表达式 a := if xxx then 1 else 2

无 else 分支

image

有 else 分支

image

posted @ 2024-06-19 16:04  Leon大帝  阅读(10)  评论(0)    收藏  举报