Add generateStatement routine
This commit is contained in:
parent
32ce14f032
commit
f827bfeb7a
@ -20,7 +20,7 @@ func (this *generator) locationToValue (pointer llvm.Value, ty entity.Type) (llv
|
|||||||
// representing the result, or a register containing the location of the result,
|
// representing the result, or a register containing the location of the result,
|
||||||
// whichever will generate the least IR. In the latter case, the boolean
|
// whichever will generate the least IR. In the latter case, the boolean
|
||||||
// "location" will be true.
|
// "location" will be true.
|
||||||
func (this *generator) generateExpression (expression entity.Expression) (value llvm.Value, location bool, err error) {
|
func (this *generator) generateExpression (expression entity.Expression) (register llvm.Value, location bool, err error) {
|
||||||
// TODO: some of these could stand to know that they have a choice in
|
// TODO: some of these could stand to know that they have a choice in
|
||||||
// the matter.
|
// the matter.
|
||||||
|
|
||||||
@ -182,10 +182,23 @@ func (this *generator) generateExpressionLoc (expression entity.Expression) (llv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *generator) generateStatementVal (statement entity.Statement) (llvm.Value, error) {
|
func (this *generator) generateStatement (statement entity.Statement) (register llvm.Value, location bool, err error) {
|
||||||
switch statement := statement.(type) {
|
switch statement := statement.(type) {
|
||||||
case *entity.Assignment:
|
case *entity.Assignment:
|
||||||
return this.generateAssignment(statement)
|
_, err := this.generateAssignment(statement)
|
||||||
|
return nil, false, err
|
||||||
|
|
||||||
|
case entity.Expression:
|
||||||
|
return this.generateExpression(statement)
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf (
|
||||||
|
"BUG: generator doesnt know about statement %v, ty: %T",
|
||||||
|
statement, statement))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *generator) generateStatementVal (statement entity.Statement) (llvm.Value, error) {
|
||||||
|
switch statement := statement.(type) {
|
||||||
case entity.Expression:
|
case entity.Expression:
|
||||||
return this.generateExpressionVal(statement)
|
return this.generateExpressionVal(statement)
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user