mirror of
https://github.com/irmen/prog8.git
synced 2025-02-20 18:29:06 +00:00
move operator lists
This commit is contained in:
parent
a0face4a28
commit
207a7e5160
18
codeCore/src/prog8/code/core/Operators.kt
Normal file
18
codeCore/src/prog8/code/core/Operators.kt
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package prog8.code.core
|
||||||
|
|
||||||
|
val AssociativeOperators = setOf("+", "*", "&", "|", "^", "or", "and", "xor", "==", "!=")
|
||||||
|
val ComparisonOperators = setOf("==", "!=", "<", ">", "<=", ">=")
|
||||||
|
val AugmentAssignmentOperators = setOf("+", "-", "/", "*", "&", "|", "^", "<<", ">>", "%", "and", "or", "xor")
|
||||||
|
val LogicalOperators = setOf("and", "or", "xor", "not")
|
||||||
|
val BitwiseOperators = setOf("&", "|", "^")
|
||||||
|
|
||||||
|
fun invertedComparisonOperator(operator: String) =
|
||||||
|
when (operator) {
|
||||||
|
"==" -> "!="
|
||||||
|
"!=" -> "=="
|
||||||
|
"<" -> ">="
|
||||||
|
">" -> "<="
|
||||||
|
"<=" -> ">"
|
||||||
|
">=" -> "<"
|
||||||
|
else -> null
|
||||||
|
}
|
@ -10,6 +10,7 @@ import prog8.ast.statements.Assignment
|
|||||||
import prog8.ast.statements.AssignmentOrigin
|
import prog8.ast.statements.AssignmentOrigin
|
||||||
import prog8.ast.walk.AstWalker
|
import prog8.ast.walk.AstWalker
|
||||||
import prog8.ast.walk.IAstModification
|
import prog8.ast.walk.IAstModification
|
||||||
|
import prog8.code.core.AugmentAssignmentOperators
|
||||||
import prog8.code.core.CompilationOptions
|
import prog8.code.core.CompilationOptions
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
import prog8.code.target.VMTarget
|
import prog8.code.target.VMTarget
|
||||||
|
@ -11,6 +11,7 @@ import prog8.ast.statements.VarDecl
|
|||||||
import prog8.ast.statements.VarDeclType
|
import prog8.ast.statements.VarDeclType
|
||||||
import prog8.ast.walk.AstWalker
|
import prog8.ast.walk.AstWalker
|
||||||
import prog8.ast.walk.IAstModification
|
import prog8.ast.walk.IAstModification
|
||||||
|
import prog8.code.core.AssociativeOperators
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
import prog8.code.core.IntegerDatatypes
|
import prog8.code.core.IntegerDatatypes
|
||||||
|
|
||||||
|
@ -6,10 +6,7 @@ import prog8.ast.expressions.*
|
|||||||
import prog8.ast.statements.*
|
import prog8.ast.statements.*
|
||||||
import prog8.ast.walk.AstWalker
|
import prog8.ast.walk.AstWalker
|
||||||
import prog8.ast.walk.IAstModification
|
import prog8.ast.walk.IAstModification
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.*
|
||||||
import prog8.code.core.IErrorReporter
|
|
||||||
import prog8.code.core.IntegerDatatypes
|
|
||||||
import prog8.code.core.NumericDatatypes
|
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.log2
|
import kotlin.math.log2
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
@ -11,10 +11,7 @@ import prog8.ast.statements.Assignment
|
|||||||
import prog8.ast.statements.FunctionCallStatement
|
import prog8.ast.statements.FunctionCallStatement
|
||||||
import prog8.ast.walk.AstWalker
|
import prog8.ast.walk.AstWalker
|
||||||
import prog8.ast.walk.IAstModification
|
import prog8.ast.walk.IAstModification
|
||||||
import prog8.code.core.ArrayDatatypes
|
import prog8.code.core.*
|
||||||
import prog8.code.core.CompilationOptions
|
|
||||||
import prog8.code.core.DataType
|
|
||||||
import prog8.code.core.IErrorReporter
|
|
||||||
|
|
||||||
|
|
||||||
internal class VariousCleanups(val program: Program, val errors: IErrorReporter, val options: CompilationOptions): AstWalker() {
|
internal class VariousCleanups(val program: Program, val errors: IErrorReporter, val options: CompilationOptions): AstWalker() {
|
||||||
|
@ -13,23 +13,6 @@ import java.util.*
|
|||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.round
|
import kotlin.math.round
|
||||||
|
|
||||||
val AssociativeOperators = setOf("+", "*", "&", "|", "^", "or", "and", "xor", "==", "!=")
|
|
||||||
val ComparisonOperators = setOf("==", "!=", "<", ">", "<=", ">=")
|
|
||||||
val AugmentAssignmentOperators = setOf("+", "-", "/", "*", "&", "|", "^", "<<", ">>", "%", "and", "or", "xor")
|
|
||||||
val LogicalOperators = setOf("and", "or", "xor", "not")
|
|
||||||
val BitwiseOperators = setOf("&", "|", "^")
|
|
||||||
|
|
||||||
fun invertedComparisonOperator(operator: String) =
|
|
||||||
when (operator) {
|
|
||||||
"==" -> "!="
|
|
||||||
"!=" -> "=="
|
|
||||||
"<" -> ">="
|
|
||||||
">" -> "<="
|
|
||||||
"<=" -> ">"
|
|
||||||
">=" -> "<"
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sealed class Expression: Node {
|
sealed class Expression: Node {
|
||||||
abstract override fun copy(): Expression
|
abstract override fun copy(): Expression
|
||||||
|
@ -4,6 +4,7 @@ import prog8.ast.*
|
|||||||
import prog8.ast.base.FatalAstException
|
import prog8.ast.base.FatalAstException
|
||||||
import prog8.ast.expressions.*
|
import prog8.ast.expressions.*
|
||||||
import prog8.ast.statements.*
|
import prog8.ast.statements.*
|
||||||
|
import prog8.code.core.AssociativeOperators
|
||||||
|
|
||||||
|
|
||||||
interface IAstModification {
|
interface IAstModification {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user