Analyze for loops
This commit is contained in:
parent
24bfb30a24
commit
86d4f21036
@ -816,7 +816,42 @@ func (this *Tree) analyzeFor (
|
||||
entity.Expression,
|
||||
error,
|
||||
) {
|
||||
// TODO
|
||||
loop.Ty = into
|
||||
|
||||
this.pushScope(loop)
|
||||
defer this.popScope()
|
||||
|
||||
// index
|
||||
if loop.Index != nil {
|
||||
index, err := this.analyzeDeclaration (
|
||||
builtinType("Index"),
|
||||
strict, loop.Index)
|
||||
if err != nil { return nil, err }
|
||||
loop.Index = index.(*entity.Declaration)
|
||||
}
|
||||
|
||||
// element
|
||||
element, err := this.analyzeDeclaration(nil, strict, loop.Element)
|
||||
if err != nil { return nil, err }
|
||||
loop.Element = element.(*entity.Declaration)
|
||||
|
||||
// over
|
||||
over, err := this.analyzeExpression (
|
||||
&entity.TypeSlice {
|
||||
Pos: loop.Position(),
|
||||
Element: element.Type(),
|
||||
}, weak, loop.Over)
|
||||
if err != nil { return nil, err }
|
||||
loop.Over = over
|
||||
|
||||
this.pushLoop(loop)
|
||||
defer this.popLoop()
|
||||
|
||||
body, err := this.analyzeExpression(nil, strict, loop.Body)
|
||||
if err != nil { return nil, err }
|
||||
loop.Body = body
|
||||
|
||||
return loop, nil
|
||||
}
|
||||
|
||||
func (this *Tree) analyzeBreak (
|
||||
|
@ -493,6 +493,7 @@ type For struct {
|
||||
|
||||
// Semantics
|
||||
Ty Type
|
||||
Scope
|
||||
}
|
||||
func (*For) expression(){}
|
||||
func (*For) breakable(){}
|
||||
|
Loading…
Reference in New Issue
Block a user