You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functraverseAndReplaceIntegerNodesWithIntegerNodes(node*ast.Node, newType reflect.Type) {
switch (*node).(type) {
case*ast.IntegerNode:
(*node).SetType(newType)
case*ast.UnaryNode:
(*node).SetType(newType)
unaryNode:= (*node).(*ast.UnaryNode)
traverseAndReplaceIntegerNodesWithIntegerNodes(&unaryNode.Node, newType)
case*ast.BinaryNode:
// TODO: Binary node return type is dependent on the type of the operands. We can't just change the type of the node.binaryNode:= (*node).(*ast.BinaryNode)
switchbinaryNode.Operator {
case"+", "-", "*":
traverseAndReplaceIntegerNodesWithIntegerNodes(&binaryNode.Left, newType)
traverseAndReplaceIntegerNodesWithIntegerNodes(&binaryNode.Right, newType)
}
}
}
And replace it with implicit added calls to int*.
NOTE
We should check for overflows on conversion in checkers!
The text was updated successfully, but these errors were encountered:
We already have int() and float() builtins. Let's add others as well: uint8, byte, int64, float64, etc.
And we can change compiler to compile int for IntegerNode, and remove this code:
And for function calls we can delete this code:
And replace it with implicit added calls to int*.
The text was updated successfully, but these errors were encountered: