80 lines
2.6 KiB
Go
80 lines
2.6 KiB
Go
package analyzer
|
|
|
|
import "fmt"
|
|
import "git.tebibyte.media/fspl/fspl/entity"
|
|
|
|
func (this *Tree) analyzeExpression (
|
|
into entity.Type,
|
|
mode strictness,
|
|
expression entity.Expression,
|
|
) (
|
|
entity.Expression,
|
|
error,
|
|
) {
|
|
switch expression := expression.(type) {
|
|
case *entity.Assignment:
|
|
return this.analyzeAssignment(expression)
|
|
case *entity.Variable:
|
|
return this.analyzeVariable(into, mode, expression)
|
|
case *entity.Declaration:
|
|
return this.analyzeDeclaration(into, mode, expression)
|
|
case *entity.Call:
|
|
return this.analyzeCall(into, mode, expression)
|
|
case *entity.MethodCall:
|
|
return this.analyzeMethodCall(into, mode, expression)
|
|
case *entity.Subscript:
|
|
return this.analyzeSubscript(into, mode, expression)
|
|
case *entity.Slice:
|
|
return this.analyzeSlice(into, mode, expression)
|
|
case *entity.Length:
|
|
return this.analyzeLength(into, mode, expression)
|
|
case *entity.Dereference:
|
|
return this.analyzeDereference(into, mode, expression)
|
|
case *entity.Reference:
|
|
return this.analyzeReference(into, mode, expression)
|
|
case *entity.ValueCast:
|
|
return this.analyzeValueCast(into, mode, expression)
|
|
case *entity.BitCast:
|
|
return this.analyzeBitCast(into, mode, expression)
|
|
case *entity.Operation:
|
|
return this.analyzeOperation(into, mode, expression)
|
|
case *entity.Block:
|
|
return this.analyzeBlock(into, mode, expression)
|
|
case *entity.MemberAccess:
|
|
return this.analyzeMemberAccess(into, mode, expression)
|
|
case *entity.IfElse:
|
|
return this.analyzeIfElse(into, mode, expression)
|
|
case *entity.Match:
|
|
return this.analyzeMatch(into, mode, expression)
|
|
case *entity.Switch:
|
|
return this.analyzeSwitch(into, mode, expression)
|
|
case *entity.Loop:
|
|
return this.analyzeLoop(into, mode, expression)
|
|
case *entity.For:
|
|
return this.analyzeFor(into, mode, expression)
|
|
case *entity.Break:
|
|
return this.analyzeBreak(into, mode, expression)
|
|
case *entity.Return:
|
|
return this.analyzeReturn(into, mode, expression)
|
|
|
|
case *entity.LiteralInt:
|
|
return this.analyzeLiteralInt(into, mode, expression)
|
|
case *entity.LiteralFloat:
|
|
return this.analyzeLiteralFloat(into, mode, expression)
|
|
case *entity.LiteralArray:
|
|
return this.analyzeLiteralArray(into, mode, expression)
|
|
case *entity.LiteralString:
|
|
return this.analyzeLiteralString(into, mode, expression)
|
|
case *entity.LiteralStruct:
|
|
return this.analyzeLiteralStruct(into, mode, expression)
|
|
case *entity.LiteralBoolean:
|
|
return this.analyzeLiteralBoolean(into, mode, expression)
|
|
case *entity.LiteralNil:
|
|
return this.analyzeLiteralNil(into, mode, expression)
|
|
default:
|
|
panic(fmt.Sprintf (
|
|
"BUG: analyzer doesnt know about expression %v, ty: %T",
|
|
expression, expression))
|
|
}
|
|
}
|