-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Map剖析 | ||
=== | ||
## 初始化 | ||
## 编译时的map | ||
节点的op类型 | ||
ir.OMAPLIT | ||
walk.maplit | ||
```Go | ||
func maplit(n *ir.CompLitExpr, m ir.Node, init *ir.Nodes) { | ||
// make the map var | ||
// 虽然这里传入的op类型为ir.OMAKE,但最终生成代码时并 | ||
// 不一定会有makemap,比如当map被分配至栈上,详细请看 | ||
// walk.walkMakeMap | ||
a := ir.NewCallExpr(base.Pos, ir.OMAKE, nil, nil) | ||
... | ||
// 如果要初始化的条目大于25,则将其放入数组循环赋值 | ||
if len(entries) > 25 { | ||
|
||
// for i = 0; i < len(vstatk); i++ { | ||
// map[vstatk[i]] = vstate[i] | ||
// } | ||
return | ||
} | ||
// 对于很少数量的条目,直接赋值 | ||
|
||
// Build list of var[c] = expr. | ||
} | ||
``` |