mirror of
https://github.com/irmen/prog8.git
synced 2024-06-10 05:29:29 +00:00
reducing dependencies
This commit is contained in:
parent
9a798360f4
commit
e75d0c58a9
42
codeAst/build.gradle
Normal file
42
codeAst/build.gradle
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
id 'application'
|
||||||
|
id "org.jetbrains.kotlin.jvm"
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(javaVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlin {
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = javaVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileTestKotlin {
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = javaVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation project(':codeCore')
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
java {
|
||||||
|
srcDirs = ["${project.projectDir}/src"]
|
||||||
|
}
|
||||||
|
resources {
|
||||||
|
srcDirs = ["${project.projectDir}/res"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// note: there are no unit tests in this module!
|
|
@ -1,4 +1,5 @@
|
||||||
package prog8.compilerinterface
|
package prog8.code
|
||||||
|
|
||||||
|
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
import prog8.code.core.Encoding
|
import prog8.code.core.Encoding
|
||||||
|
@ -32,7 +33,7 @@ class SymbolTable : StNode("", StNodeType.GLOBAL, Position.DUMMY) {
|
||||||
val vars = mutableListOf<StStaticVariable>()
|
val vars = mutableListOf<StStaticVariable>()
|
||||||
fun collect(node: StNode) {
|
fun collect(node: StNode) {
|
||||||
for(child in node.children) {
|
for(child in node.children) {
|
||||||
if(child.value.type==StNodeType.STATICVAR)
|
if(child.value.type== StNodeType.STATICVAR)
|
||||||
vars.add(child.value as StStaticVariable)
|
vars.add(child.value as StStaticVariable)
|
||||||
else
|
else
|
||||||
collect(child.value)
|
collect(child.value)
|
||||||
|
@ -93,7 +94,7 @@ open class StNode(val name: String,
|
||||||
private fun lookupQualified(scopedName: List<String>): StNode? {
|
private fun lookupQualified(scopedName: List<String>): StNode? {
|
||||||
// a scoped name refers to a name in another namespace, and always stars from the root.
|
// a scoped name refers to a name in another namespace, and always stars from the root.
|
||||||
var node = this
|
var node = this
|
||||||
while(node.type!=StNodeType.GLOBAL)
|
while(node.type!= StNodeType.GLOBAL)
|
||||||
node = node.parent
|
node = node.parent
|
||||||
|
|
||||||
for(name in scopedName) {
|
for(name in scopedName) {
|
||||||
|
@ -108,10 +109,10 @@ open class StNode(val name: String,
|
||||||
private fun lookupUnqualified(name: String): StNode? {
|
private fun lookupUnqualified(name: String): StNode? {
|
||||||
// first consider the builtin functions
|
// first consider the builtin functions
|
||||||
var globalscope = this
|
var globalscope = this
|
||||||
while(globalscope.type!=StNodeType.GLOBAL)
|
while(globalscope.type!= StNodeType.GLOBAL)
|
||||||
globalscope = globalscope.parent
|
globalscope = globalscope.parent
|
||||||
val globalNode = globalscope.children[name]
|
val globalNode = globalscope.children[name]
|
||||||
if(globalNode!=null && globalNode.type==StNodeType.BUILTINFUNC)
|
if(globalNode!=null && globalNode.type== StNodeType.BUILTINFUNC)
|
||||||
return globalNode
|
return globalNode
|
||||||
|
|
||||||
// search for the unqualified name in the current scope or its parent scopes
|
// search for the unqualified name in the current scope or its parent scopes
|
||||||
|
@ -120,7 +121,7 @@ open class StNode(val name: String,
|
||||||
val node = scope.children[name]
|
val node = scope.children[name]
|
||||||
if(node!=null)
|
if(node!=null)
|
||||||
return node
|
return node
|
||||||
if(scope.type==StNodeType.GLOBAL)
|
if(scope.type== StNodeType.GLOBAL)
|
||||||
return null
|
return null
|
||||||
else
|
else
|
||||||
scope = scope.parent
|
scope = scope.parent
|
|
@ -4,7 +4,7 @@ import prog8.code.core.IMemSizer
|
||||||
import prog8.code.core.IStringEncoding
|
import prog8.code.core.IStringEncoding
|
||||||
import prog8.code.core.Position
|
import prog8.code.core.Position
|
||||||
|
|
||||||
|
// New (work-in-progress) simplified AST for the code generator.
|
||||||
// TODO : once the CodeGen doesn't need the old Ast anymore, get rid of the 'Pt' prefixes ?
|
// TODO : once the CodeGen doesn't need the old Ast anymore, get rid of the 'Pt' prefixes ?
|
||||||
|
|
||||||
|
|
||||||
|
|
41
codeCore/build.gradle
Normal file
41
codeCore/build.gradle
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
id 'application'
|
||||||
|
id "org.jetbrains.kotlin.jvm"
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(javaVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlin {
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = javaVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileTestKotlin {
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = javaVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
java {
|
||||||
|
srcDirs = ["${project.projectDir}/src"]
|
||||||
|
}
|
||||||
|
resources {
|
||||||
|
srcDirs = ["${project.projectDir}/res"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// note: there are no unit tests in this module!
|
|
@ -151,3 +151,24 @@ val Cx16VirtualRegisters = arrayOf(
|
||||||
RegisterOrPair.R8, RegisterOrPair.R9, RegisterOrPair.R10, RegisterOrPair.R11,
|
RegisterOrPair.R8, RegisterOrPair.R9, RegisterOrPair.R10, RegisterOrPair.R11,
|
||||||
RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, RegisterOrPair.R15
|
RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, RegisterOrPair.R15
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum class OutputType {
|
||||||
|
RAW,
|
||||||
|
PRG,
|
||||||
|
XEX
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class CbmPrgLauncherType {
|
||||||
|
BASIC,
|
||||||
|
NONE
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class ZeropageType {
|
||||||
|
BASICSAFE,
|
||||||
|
FLOATSAFE,
|
||||||
|
KERNALSAFE,
|
||||||
|
FULL,
|
||||||
|
DONTUSE
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package prog8.compilerinterface
|
package prog8.code.core
|
||||||
|
|
||||||
class InternalCompilerException(message: String?) : Exception(message)
|
class InternalCompilerException(message: String?) : Exception(message)
|
||||||
|
|
||||||
class AbortCompilation(message: String?) : Exception(message)
|
|
||||||
|
|
||||||
class AssemblyError(msg: String) : RuntimeException(msg)
|
class AssemblyError(msg: String) : RuntimeException(msg)
|
||||||
|
|
||||||
|
class ErrorsReportedException(message: String?) : Exception(message)
|
23
codeCore/src/prog8/code/core/IAssemblyGenerator.kt
Normal file
23
codeCore/src/prog8/code/core/IAssemblyGenerator.kt
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package prog8.code.core
|
||||||
|
|
||||||
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
|
||||||
|
interface IAssemblyGenerator {
|
||||||
|
fun compileToAssembly(): IAssemblyProgram?
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IAssemblyProgram {
|
||||||
|
val name: String
|
||||||
|
fun assemble(options: AssemblerOptions): Boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
fun viceMonListName(baseFilename: String) = "$baseFilename.vice-mon-list"
|
||||||
|
|
||||||
|
|
||||||
|
class AssemblerOptions(
|
||||||
|
val output: OutputType,
|
||||||
|
var asmQuiet: Boolean = false,
|
||||||
|
var asmListfile: Boolean = false,
|
||||||
|
var outputDir: Path
|
||||||
|
)
|
|
@ -1,6 +1,4 @@
|
||||||
package prog8.compilerinterface
|
package prog8.code.core
|
||||||
|
|
||||||
import prog8.code.core.Position
|
|
||||||
|
|
||||||
interface IErrorReporter {
|
interface IErrorReporter {
|
||||||
fun err(msg: String, position: Position)
|
fun err(msg: String, position: Position)
|
||||||
|
@ -9,7 +7,6 @@ interface IErrorReporter {
|
||||||
fun report()
|
fun report()
|
||||||
fun finalizeNumErrors(numErrors: Int, numWarnings: Int) {
|
fun finalizeNumErrors(numErrors: Int, numWarnings: Int) {
|
||||||
if(numErrors>0)
|
if(numErrors>0)
|
||||||
throw AbortCompilation("There are $numErrors errors and $numWarnings warnings.")
|
throw ErrorsReportedException("There are $numErrors errors and $numWarnings warnings.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,10 @@ compileTestKotlin {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':compilerInterfaces')
|
implementation project(':codeAst')
|
||||||
|
implementation project(':codeCore')
|
||||||
implementation project(':compilerAst')
|
implementation project(':compilerAst')
|
||||||
|
implementation project(':compilerInterfaces')
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
// implementation "org.jetbrains.kotlin:kotlin-reflect"
|
// implementation "org.jetbrains.kotlin:kotlin-reflect"
|
||||||
implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.14"
|
implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.14"
|
||||||
|
|
|
@ -9,9 +9,10 @@
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
|
<orderEntry type="module" module-name="codeAst" />
|
||||||
|
<orderEntry type="module" module-name="codeCore" />
|
||||||
<orderEntry type="module" module-name="compilerAst" />
|
<orderEntry type="module" module-name="compilerAst" />
|
||||||
<orderEntry type="module" module-name="compilerInterfaces" />
|
<orderEntry type="module" module-name="compilerInterfaces" />
|
||||||
<orderEntry type="library" name="michael.bull.kotlin.result.jvm" level="project" />
|
<orderEntry type="library" name="michael.bull.kotlin.result.jvm" level="project" />
|
||||||
<orderEntry type="module" module-name="codeCore" />
|
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -5,6 +5,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.SymbolTable
|
||||||
import prog8.code.core.*
|
import prog8.code.core.*
|
||||||
import prog8.codegen.cpu6502.assignment.*
|
import prog8.codegen.cpu6502.assignment.*
|
||||||
import prog8.compilerinterface.*
|
import prog8.compilerinterface.*
|
||||||
|
|
|
@ -3,6 +3,7 @@ package prog8.codegen.cpu6502
|
||||||
import com.github.michaelbull.result.Ok
|
import com.github.michaelbull.result.Ok
|
||||||
import com.github.michaelbull.result.Result
|
import com.github.michaelbull.result.Result
|
||||||
import com.github.michaelbull.result.mapError
|
import com.github.michaelbull.result.mapError
|
||||||
|
import prog8.code.core.*
|
||||||
import prog8.compilerinterface.*
|
import prog8.compilerinterface.*
|
||||||
import prog8.parser.SourceCode
|
import prog8.parser.SourceCode
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -23,7 +24,7 @@ internal class AssemblyProgram(
|
||||||
private val viceMonListFile = outputDir.resolve(viceMonListName(name))
|
private val viceMonListFile = outputDir.resolve(viceMonListName(name))
|
||||||
private val listFile = outputDir.resolve("$name.list")
|
private val listFile = outputDir.resolve("$name.list")
|
||||||
|
|
||||||
override fun assemble(options: CompilationOptions): Boolean {
|
override fun assemble(options: AssemblerOptions): Boolean {
|
||||||
|
|
||||||
val assemblerCommand: List<String>
|
val assemblerCommand: List<String>
|
||||||
|
|
||||||
|
|
|
@ -1606,7 +1606,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program,
|
||||||
|
|
||||||
private fun translateArguments(args: MutableList<Expression>, signature: FSignature, scope: Subroutine?) {
|
private fun translateArguments(args: MutableList<Expression>, signature: FSignature, scope: Subroutine?) {
|
||||||
val callConv = signature.callConvention(args.map {
|
val callConv = signature.callConvention(args.map {
|
||||||
it.inferType(program).getOrElse { throw AssemblyError("unknown dt")}
|
it.inferType(program).getOrElse { throw AssemblyError("unknown dt") }
|
||||||
})
|
})
|
||||||
|
|
||||||
fun getSourceForFloat(value: Expression): AsmAssignSource {
|
fun getSourceForFloat(value: Expression): AsmAssignSource {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package prog8.codegen.cpu6502
|
||||||
import prog8.ast.Program
|
import prog8.ast.Program
|
||||||
import prog8.ast.expressions.*
|
import prog8.ast.expressions.*
|
||||||
import prog8.code.core.*
|
import prog8.code.core.*
|
||||||
import prog8.compilerinterface.AssemblyError
|
import prog8.code.core.AssemblyError
|
||||||
import prog8.compilerinterface.CpuType
|
import prog8.compilerinterface.CpuType
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import prog8.code.core.ArrayToElementTypes
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
import prog8.code.core.RegisterOrPair
|
import prog8.code.core.RegisterOrPair
|
||||||
import prog8.code.core.toHex
|
import prog8.code.core.toHex
|
||||||
import prog8.compilerinterface.AssemblyError
|
import prog8.code.core.AssemblyError
|
||||||
import prog8.compilerinterface.Zeropage
|
import prog8.compilerinterface.Zeropage
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import prog8.codegen.cpu6502.assignment.AsmAssignSource
|
||||||
import prog8.codegen.cpu6502.assignment.AsmAssignTarget
|
import prog8.codegen.cpu6502.assignment.AsmAssignTarget
|
||||||
import prog8.codegen.cpu6502.assignment.AsmAssignment
|
import prog8.codegen.cpu6502.assignment.AsmAssignment
|
||||||
import prog8.codegen.cpu6502.assignment.TargetStorageKind
|
import prog8.codegen.cpu6502.assignment.TargetStorageKind
|
||||||
import prog8.compilerinterface.AssemblyError
|
import prog8.code.core.AssemblyError
|
||||||
|
|
||||||
|
|
||||||
internal class FunctionCallAsmGen(private val program: Program, private val asmgen: AsmGen) {
|
internal class FunctionCallAsmGen(private val program: Program, private val asmgen: AsmGen) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import prog8.ast.expressions.IdentifierReference
|
||||||
import prog8.ast.expressions.NumericLiteral
|
import prog8.ast.expressions.NumericLiteral
|
||||||
import prog8.ast.statements.PostIncrDecr
|
import prog8.ast.statements.PostIncrDecr
|
||||||
import prog8.code.core.*
|
import prog8.code.core.*
|
||||||
import prog8.compilerinterface.AssemblyError
|
import prog8.code.core.AssemblyError
|
||||||
|
|
||||||
|
|
||||||
internal class PostIncrDecrAsmGen(private val program: Program, private val asmgen: AsmGen) {
|
internal class PostIncrDecrAsmGen(private val program: Program, private val asmgen: AsmGen) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package prog8.codegen.cpu6502
|
||||||
import prog8.ast.Program
|
import prog8.ast.Program
|
||||||
import prog8.ast.antlr.escape
|
import prog8.ast.antlr.escape
|
||||||
import prog8.ast.statements.*
|
import prog8.ast.statements.*
|
||||||
|
import prog8.code.*
|
||||||
import prog8.code.core.*
|
import prog8.code.core.*
|
||||||
import prog8.codegen.cpu6502.assignment.AsmAssignTarget
|
import prog8.codegen.cpu6502.assignment.AsmAssignTarget
|
||||||
import prog8.codegen.cpu6502.assignment.TargetStorageKind
|
import prog8.codegen.cpu6502.assignment.TargetStorageKind
|
||||||
|
|
|
@ -2,15 +2,15 @@ package prog8.codegen.cpu6502
|
||||||
|
|
||||||
import com.github.michaelbull.result.fold
|
import com.github.michaelbull.result.fold
|
||||||
import com.github.michaelbull.result.onSuccess
|
import com.github.michaelbull.result.onSuccess
|
||||||
import prog8.code.core.ArrayDatatypes
|
import prog8.code.*
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.*
|
||||||
import prog8.code.core.IntegerDatatypes
|
|
||||||
import prog8.compilerinterface.*
|
import prog8.compilerinterface.*
|
||||||
|
|
||||||
|
|
||||||
internal class VariableAllocator(private val symboltable: SymbolTable,
|
internal class VariableAllocator(private val symboltable: SymbolTable,
|
||||||
private val options: CompilationOptions,
|
private val options: CompilationOptions,
|
||||||
private val errors: IErrorReporter) {
|
private val errors: IErrorReporter
|
||||||
|
) {
|
||||||
|
|
||||||
private val zeropage = options.compTarget.machine.zeropage
|
private val zeropage = options.compTarget.machine.zeropage
|
||||||
private val memorySlabsInternal = mutableMapOf<String, Pair<UInt, UInt>>()
|
private val memorySlabsInternal = mutableMapOf<String, Pair<UInt, UInt>>()
|
||||||
|
@ -126,7 +126,7 @@ internal class VariableAllocator(private val symboltable: SymbolTable,
|
||||||
val vars = mutableListOf<StStaticVariable>()
|
val vars = mutableListOf<StStaticVariable>()
|
||||||
fun collect(node: StNode) {
|
fun collect(node: StNode) {
|
||||||
for(child in node.children) {
|
for(child in node.children) {
|
||||||
if(child.value.type==StNodeType.STATICVAR)
|
if(child.value.type == StNodeType.STATICVAR)
|
||||||
vars.add(child.value as StStaticVariable)
|
vars.add(child.value as StStaticVariable)
|
||||||
else
|
else
|
||||||
collect(child.value)
|
collect(child.value)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import prog8.ast.expressions.*
|
||||||
import prog8.ast.statements.*
|
import prog8.ast.statements.*
|
||||||
import prog8.code.core.*
|
import prog8.code.core.*
|
||||||
import prog8.codegen.cpu6502.AsmGen
|
import prog8.codegen.cpu6502.AsmGen
|
||||||
import prog8.compilerinterface.AssemblyError
|
import prog8.code.core.AssemblyError
|
||||||
|
|
||||||
|
|
||||||
internal enum class TargetStorageKind {
|
internal enum class TargetStorageKind {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import prog8.ast.statements.*
|
||||||
import prog8.code.core.*
|
import prog8.code.core.*
|
||||||
import prog8.codegen.cpu6502.AsmGen
|
import prog8.codegen.cpu6502.AsmGen
|
||||||
import prog8.codegen.cpu6502.VariableAllocator
|
import prog8.codegen.cpu6502.VariableAllocator
|
||||||
import prog8.compilerinterface.AssemblyError
|
import prog8.code.core.AssemblyError
|
||||||
import prog8.compilerinterface.CpuType
|
import prog8.compilerinterface.CpuType
|
||||||
import prog8.compilerinterface.builtinFunctionReturnType
|
import prog8.compilerinterface.builtinFunctionReturnType
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import prog8.ast.statements.Subroutine
|
||||||
import prog8.code.core.*
|
import prog8.code.core.*
|
||||||
import prog8.codegen.cpu6502.AsmGen
|
import prog8.codegen.cpu6502.AsmGen
|
||||||
import prog8.codegen.cpu6502.VariableAllocator
|
import prog8.codegen.cpu6502.VariableAllocator
|
||||||
import prog8.compilerinterface.AssemblyError
|
import prog8.code.core.AssemblyError
|
||||||
import prog8.compilerinterface.CpuType
|
import prog8.compilerinterface.CpuType
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,8 @@ compileTestKotlin {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':compilerInterfaces')
|
implementation project(':codeAst')
|
||||||
|
implementation project(':codeCore')
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
// implementation "org.jetbrains.kotlin:kotlin-reflect"
|
// implementation "org.jetbrains.kotlin:kotlin-reflect"
|
||||||
implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.14"
|
implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.14"
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
<orderEntry type="module" module-name="compilerInterfaces" />
|
|
||||||
<orderEntry type="library" name="michael.bull.kotlin.result.jvm" level="project" />
|
<orderEntry type="library" name="michael.bull.kotlin.result.jvm" level="project" />
|
||||||
<orderEntry type="module" module-name="codeAst" />
|
<orderEntry type="module" module-name="codeAst" />
|
||||||
|
<orderEntry type="module" module-name="codeCore" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -1,13 +1,26 @@
|
||||||
package prog8.codegen.experimental6502
|
package prog8.codegen.experimental6502
|
||||||
|
|
||||||
|
import prog8.code.SymbolTable
|
||||||
import prog8.code.ast.PtProgram
|
import prog8.code.ast.PtProgram
|
||||||
import prog8.compilerinterface.*
|
import prog8.code.core.AssemblerOptions
|
||||||
|
import prog8.code.core.IAssemblyGenerator
|
||||||
|
import prog8.code.core.IAssemblyProgram
|
||||||
|
import prog8.code.core.IErrorReporter
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
NOTE: The goal is to keep the dependencies as lean as possible! For now, we depend only on:
|
||||||
|
- codeAst (the 'lean' new AST and the SymbolTable)
|
||||||
|
- codeCore (various base enums and interfaces)
|
||||||
|
|
||||||
|
This *should* be enough to build a complete code generator with. But we'll see :)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
class AsmGen(internal val program: PtProgram,
|
class AsmGen(internal val program: PtProgram,
|
||||||
internal val errors: IErrorReporter,
|
internal val errors: IErrorReporter,
|
||||||
internal val symbolTable: SymbolTable,
|
internal val symbolTable: SymbolTable,
|
||||||
internal val options: CompilationOptions
|
internal val options: AssemblerOptions // TODO this may not be enough, maybe we actually need the other CompilationOptions as well
|
||||||
): IAssemblyGenerator {
|
): IAssemblyGenerator {
|
||||||
|
|
||||||
override fun compileToAssembly(): IAssemblyProgram? {
|
override fun compileToAssembly(): IAssemblyProgram? {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package prog8.codegen.experimental6502
|
package prog8.codegen.experimental6502
|
||||||
|
|
||||||
import prog8.compilerinterface.CompilationOptions
|
import prog8.code.core.AssemblerOptions
|
||||||
import prog8.compilerinterface.IAssemblyProgram
|
import prog8.code.core.IAssemblyProgram
|
||||||
|
|
||||||
|
|
||||||
internal class AssemblyProgram(override val name: String) : IAssemblyProgram
|
internal class AssemblyProgram(override val name: String) : IAssemblyProgram
|
||||||
{
|
{
|
||||||
override fun assemble(options: CompilationOptions): Boolean {
|
override fun assemble(options: AssemblerOptions): Boolean {
|
||||||
println("..todo: assemble code into binary..")
|
println("..todo: assemble code into binary..")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,9 @@ compileTestKotlin {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':compilerInterfaces')
|
implementation project(':codeCore')
|
||||||
implementation project(':compilerAst')
|
implementation project(':compilerAst')
|
||||||
|
implementation project(':compilerInterfaces')
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
// implementation "org.jetbrains.kotlin:kotlin-reflect"
|
// implementation "org.jetbrains.kotlin:kotlin-reflect"
|
||||||
implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.14"
|
implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.14"
|
||||||
|
|
|
@ -6,7 +6,7 @@ import prog8.code.core.IStringEncoding
|
||||||
import prog8.codegen.target.cbm.AtasciiEncoding
|
import prog8.codegen.target.cbm.AtasciiEncoding
|
||||||
import prog8.codegen.target.cbm.IsoEncoding
|
import prog8.codegen.target.cbm.IsoEncoding
|
||||||
import prog8.codegen.target.cbm.PetsciiEncoding
|
import prog8.codegen.target.cbm.PetsciiEncoding
|
||||||
import prog8.compilerinterface.InternalCompilerException
|
import prog8.code.core.InternalCompilerException
|
||||||
|
|
||||||
|
|
||||||
internal object Encoder: IStringEncoding {
|
internal object Encoder: IStringEncoding {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package prog8.codegen.target.atari
|
package prog8.codegen.target.atari
|
||||||
|
|
||||||
|
import prog8.code.core.CbmPrgLauncherType
|
||||||
|
import prog8.code.core.OutputType
|
||||||
import prog8.codegen.target.c64.normal6502instructions
|
import prog8.codegen.target.c64.normal6502instructions
|
||||||
import prog8.compilerinterface.*
|
import prog8.compilerinterface.*
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package prog8.codegen.target.atari
|
package prog8.codegen.target.atari
|
||||||
|
|
||||||
|
import prog8.code.core.ZeropageType
|
||||||
import prog8.compilerinterface.CompilationOptions
|
import prog8.compilerinterface.CompilationOptions
|
||||||
import prog8.compilerinterface.InternalCompilerException
|
import prog8.code.core.InternalCompilerException
|
||||||
import prog8.compilerinterface.Zeropage
|
import prog8.compilerinterface.Zeropage
|
||||||
import prog8.compilerinterface.ZeropageType
|
|
||||||
|
|
||||||
class AtariZeropage(options: CompilationOptions) : Zeropage(options) {
|
class AtariZeropage(options: CompilationOptions) : Zeropage(options) {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package prog8.codegen.target.c128
|
package prog8.codegen.target.c128
|
||||||
|
|
||||||
|
import prog8.code.core.CbmPrgLauncherType
|
||||||
|
import prog8.code.core.OutputType
|
||||||
|
import prog8.code.core.viceMonListName
|
||||||
import prog8.codegen.target.c64.normal6502instructions
|
import prog8.codegen.target.c64.normal6502instructions
|
||||||
import prog8.codegen.target.cbm.Mflpt5
|
import prog8.codegen.target.cbm.Mflpt5
|
||||||
import prog8.compilerinterface.*
|
import prog8.compilerinterface.*
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package prog8.codegen.target.c128
|
package prog8.codegen.target.c128
|
||||||
|
|
||||||
|
import prog8.code.core.ZeropageType
|
||||||
import prog8.compilerinterface.CompilationOptions
|
import prog8.compilerinterface.CompilationOptions
|
||||||
import prog8.compilerinterface.InternalCompilerException
|
import prog8.code.core.InternalCompilerException
|
||||||
import prog8.compilerinterface.Zeropage
|
import prog8.compilerinterface.Zeropage
|
||||||
import prog8.compilerinterface.ZeropageType
|
|
||||||
|
|
||||||
class C128Zeropage(options: CompilationOptions) : Zeropage(options) {
|
class C128Zeropage(options: CompilationOptions) : Zeropage(options) {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package prog8.codegen.target.c64
|
package prog8.codegen.target.c64
|
||||||
|
|
||||||
|
import prog8.code.core.CbmPrgLauncherType
|
||||||
|
import prog8.code.core.OutputType
|
||||||
|
import prog8.code.core.viceMonListName
|
||||||
import prog8.codegen.target.cbm.Mflpt5
|
import prog8.codegen.target.cbm.Mflpt5
|
||||||
import prog8.compilerinterface.*
|
import prog8.compilerinterface.*
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package prog8.codegen.target.c64
|
package prog8.codegen.target.c64
|
||||||
|
|
||||||
|
import prog8.code.core.ZeropageType
|
||||||
import prog8.compilerinterface.CompilationOptions
|
import prog8.compilerinterface.CompilationOptions
|
||||||
import prog8.compilerinterface.InternalCompilerException
|
import prog8.code.core.InternalCompilerException
|
||||||
import prog8.compilerinterface.Zeropage
|
import prog8.compilerinterface.Zeropage
|
||||||
import prog8.compilerinterface.ZeropageType
|
|
||||||
|
|
||||||
class C64Zeropage(options: CompilationOptions) : Zeropage(options) {
|
class C64Zeropage(options: CompilationOptions) : Zeropage(options) {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package prog8.codegen.target.cbm
|
package prog8.codegen.target.cbm
|
||||||
|
|
||||||
import prog8.compilerinterface.IMachineFloat
|
import prog8.compilerinterface.IMachineFloat
|
||||||
import prog8.compilerinterface.InternalCompilerException
|
import prog8.code.core.InternalCompilerException
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package prog8.codegen.target.cx16
|
package prog8.codegen.target.cx16
|
||||||
|
|
||||||
|
import prog8.code.core.CbmPrgLauncherType
|
||||||
|
import prog8.code.core.OutputType
|
||||||
|
import prog8.code.core.viceMonListName
|
||||||
import prog8.codegen.target.cbm.Mflpt5
|
import prog8.codegen.target.cbm.Mflpt5
|
||||||
import prog8.compilerinterface.*
|
import prog8.compilerinterface.*
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package prog8.codegen.target.cx16
|
package prog8.codegen.target.cx16
|
||||||
|
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
|
import prog8.code.core.ZeropageType
|
||||||
import prog8.compilerinterface.CompilationOptions
|
import prog8.compilerinterface.CompilationOptions
|
||||||
import prog8.compilerinterface.InternalCompilerException
|
import prog8.code.core.InternalCompilerException
|
||||||
import prog8.compilerinterface.Zeropage
|
import prog8.compilerinterface.Zeropage
|
||||||
import prog8.compilerinterface.ZeropageType
|
|
||||||
|
|
||||||
|
|
||||||
class CX16Zeropage(options: CompilationOptions) : Zeropage(options) {
|
class CX16Zeropage(options: CompilationOptions) : Zeropage(options) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ compileTestKotlin {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation project(':codeCore')
|
||||||
implementation project(':compilerInterfaces')
|
implementation project(':compilerInterfaces')
|
||||||
implementation project(':compilerAst')
|
implementation project(':compilerAst')
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
<orderEntry type="module" module-name="compilerInterfaces" />
|
|
||||||
<orderEntry type="module" module-name="compilerAst" />
|
|
||||||
<orderEntry type="module" module-name="codeCore" />
|
<orderEntry type="module" module-name="codeCore" />
|
||||||
|
<orderEntry type="module" module-name="compilerAst" />
|
||||||
|
<orderEntry type="module" module-name="compilerInterfaces" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -10,8 +10,8 @@ import prog8.ast.walk.AstWalker
|
||||||
import prog8.ast.walk.IAstModification
|
import prog8.ast.walk.IAstModification
|
||||||
import prog8.code.core.*
|
import prog8.code.core.*
|
||||||
import prog8.compilerinterface.ICompilationTarget
|
import prog8.compilerinterface.ICompilationTarget
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
import prog8.compilerinterface.InternalCompilerException
|
import prog8.code.core.InternalCompilerException
|
||||||
|
|
||||||
// Fix up the literal value's type to match that of the vardecl
|
// Fix up the literal value's type to match that of the vardecl
|
||||||
// (also check range literal operands types before they get expanded into arrays for instance)
|
// (also check range literal operands types before they get expanded into arrays for instance)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import prog8.ast.walk.IAstModification
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
import prog8.code.core.IntegerDatatypes
|
import prog8.code.core.IntegerDatatypes
|
||||||
import prog8.code.core.NumericDatatypes
|
import prog8.code.core.NumericDatatypes
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.log2
|
import kotlin.math.log2
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
|
|
@ -4,7 +4,7 @@ import prog8.ast.IBuiltinFunctions
|
||||||
import prog8.ast.Program
|
import prog8.ast.Program
|
||||||
import prog8.compilerinterface.CompilationOptions
|
import prog8.compilerinterface.CompilationOptions
|
||||||
import prog8.compilerinterface.ICompilationTarget
|
import prog8.compilerinterface.ICompilationTarget
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
|
|
||||||
|
|
||||||
fun Program.constantFold(errors: IErrorReporter, compTarget: ICompilationTarget) {
|
fun Program.constantFold(errors: IErrorReporter, compTarget: ICompilationTarget) {
|
||||||
|
|
|
@ -9,14 +9,14 @@ import prog8.code.core.ArrayDatatypes
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
import prog8.code.core.IntegerDatatypes
|
import prog8.code.core.IntegerDatatypes
|
||||||
import prog8.compilerinterface.ICompilationTarget
|
import prog8.compilerinterface.ICompilationTarget
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
import kotlin.math.floor
|
import kotlin.math.floor
|
||||||
|
|
||||||
|
|
||||||
class StatementOptimizer(private val program: Program,
|
class StatementOptimizer(private val program: Program,
|
||||||
private val errors: IErrorReporter,
|
private val errors: IErrorReporter,
|
||||||
private val functions: IBuiltinFunctions,
|
private val functions: IBuiltinFunctions,
|
||||||
private val compTarget: ICompilationTarget
|
private val compTarget: ICompilationTarget
|
||||||
) : AstWalker() {
|
) : AstWalker() {
|
||||||
|
|
||||||
override fun before(functionCallExpr: FunctionCallExpression, parent: Node): Iterable<IAstModification> {
|
override fun before(functionCallExpr: FunctionCallExpression, parent: Node): Iterable<IAstModification> {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import prog8.ast.walk.IAstModification
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
import prog8.compilerinterface.CallGraph
|
import prog8.compilerinterface.CallGraph
|
||||||
import prog8.compilerinterface.ICompilationTarget
|
import prog8.compilerinterface.ICompilationTarget
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
import prog8.compilerinterface.isIOAddress
|
import prog8.compilerinterface.isIOAddress
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@ compileTestKotlin {
|
||||||
def prog8version = rootProject.file('compiler/res/version.txt').text.trim()
|
def prog8version = rootProject.file('compiler/res/version.txt').text.trim()
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation project(':codeAst')
|
||||||
|
implementation project(':codeCore')
|
||||||
implementation project(':compilerInterfaces')
|
implementation project(':compilerInterfaces')
|
||||||
implementation project(':codeOptimizers')
|
implementation project(':codeOptimizers')
|
||||||
implementation project(':compilerAst')
|
implementation project(':compilerAst')
|
||||||
|
|
|
@ -11,19 +11,18 @@
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
<orderEntry type="module" module-name="compilerAst" />
|
|
||||||
<orderEntry type="library" name="jetbrains.kotlinx.cli.jvm" level="project" />
|
<orderEntry type="library" name="jetbrains.kotlinx.cli.jvm" level="project" />
|
||||||
<orderEntry type="library" name="michael.bull.kotlin.result.jvm" level="project" />
|
<orderEntry type="library" name="michael.bull.kotlin.result.jvm" level="project" />
|
||||||
<orderEntry type="module" module-name="codeOptimizers" />
|
|
||||||
<orderEntry type="module" module-name="compilerInterfaces" />
|
|
||||||
<orderEntry type="module" module-name="codeGenTargets" />
|
|
||||||
<orderEntry type="library" name="io.kotest.assertions.core.jvm" level="project" />
|
<orderEntry type="library" name="io.kotest.assertions.core.jvm" level="project" />
|
||||||
<orderEntry type="library" name="io.kotest.runner.junit5.jvm" level="project" />
|
<orderEntry type="library" name="io.kotest.runner.junit5.jvm" level="project" />
|
||||||
<orderEntry type="library" name="antlr.antlr4" level="project" />
|
<orderEntry type="library" name="antlr.antlr4" level="project" />
|
||||||
<orderEntry type="module" module-name="codeGenCpu6502" />
|
|
||||||
<orderEntry type="module" module-name="codeGenExperimental6502" />
|
|
||||||
<orderEntry type="module" module-name="codeCore" />
|
<orderEntry type="module" module-name="codeCore" />
|
||||||
<orderEntry type="module" module-name="codeAst" />
|
<orderEntry type="module" module-name="codeAst" />
|
||||||
<orderEntry type="module" module-name="codeAst" />
|
<orderEntry type="module" module-name="compilerAst" />
|
||||||
|
<orderEntry type="module" module-name="compilerInterfaces" />
|
||||||
|
<orderEntry type="module" module-name="codeOptimizers" />
|
||||||
|
<orderEntry type="module" module-name="codeGenTargets" />
|
||||||
|
<orderEntry type="module" module-name="codeGenCpu6502" />
|
||||||
|
<orderEntry type="module" module-name="codeGenExperimental6502" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -2,6 +2,7 @@ package prog8
|
||||||
|
|
||||||
import kotlinx.cli.*
|
import kotlinx.cli.*
|
||||||
import prog8.ast.base.AstException
|
import prog8.ast.base.AstException
|
||||||
|
import prog8.code.core.CbmPrgLauncherType
|
||||||
import prog8.codegen.target.AtariTarget
|
import prog8.codegen.target.AtariTarget
|
||||||
import prog8.codegen.target.C128Target
|
import prog8.codegen.target.C128Target
|
||||||
import prog8.codegen.target.C64Target
|
import prog8.codegen.target.C64Target
|
||||||
|
@ -9,7 +10,6 @@ import prog8.codegen.target.Cx16Target
|
||||||
import prog8.compiler.CompilationResult
|
import prog8.compiler.CompilationResult
|
||||||
import prog8.compiler.CompilerArguments
|
import prog8.compiler.CompilerArguments
|
||||||
import prog8.compiler.compileProgram
|
import prog8.compiler.compileProgram
|
||||||
import prog8.compilerinterface.CbmPrgLauncherType
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.FileSystems
|
import java.nio.file.FileSystems
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
|
@ -11,7 +11,8 @@ import prog8.ast.expressions.NumericLiteral
|
||||||
import prog8.ast.statements.Directive
|
import prog8.ast.statements.Directive
|
||||||
import prog8.ast.statements.VarDecl
|
import prog8.ast.statements.VarDecl
|
||||||
import prog8.ast.walk.IAstVisitor
|
import prog8.ast.walk.IAstVisitor
|
||||||
import prog8.code.core.Position
|
import prog8.code.SymbolTable
|
||||||
|
import prog8.code.core.*
|
||||||
import prog8.codegen.target.AtariTarget
|
import prog8.codegen.target.AtariTarget
|
||||||
import prog8.codegen.target.C128Target
|
import prog8.codegen.target.C128Target
|
||||||
import prog8.codegen.target.C64Target
|
import prog8.codegen.target.C64Target
|
||||||
|
@ -117,7 +118,7 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
|
||||||
System.err.print("\n\u001b[91m") // bright red
|
System.err.print("\n\u001b[91m") // bright red
|
||||||
System.err.println("${px.position.toClickableStr()} parse error: ${px.message}".trim())
|
System.err.println("${px.position.toClickableStr()} parse error: ${px.message}".trim())
|
||||||
System.err.print("\u001b[0m") // reset
|
System.err.print("\u001b[0m") // reset
|
||||||
} catch (ac: AbortCompilation) {
|
} catch (ac: ErrorsReportedException) {
|
||||||
if(!ac.message.isNullOrEmpty()) {
|
if(!ac.message.isNullOrEmpty()) {
|
||||||
System.err.print("\n\u001b[91m") // bright red
|
System.err.print("\n\u001b[91m") // bright red
|
||||||
System.err.println(ac.message)
|
System.err.println(ac.message)
|
||||||
|
@ -360,7 +361,13 @@ private fun createAssemblyAndAssemble(program: Program,
|
||||||
errors.report()
|
errors.report()
|
||||||
|
|
||||||
return if(assembly!=null && errors.noErrors()) {
|
return if(assembly!=null && errors.noErrors()) {
|
||||||
assembly.assemble(compilerOptions)
|
val options = AssemblerOptions(
|
||||||
|
compilerOptions.output,
|
||||||
|
compilerOptions.asmQuiet,
|
||||||
|
compilerOptions.asmListfile,
|
||||||
|
compilerOptions.outputDir
|
||||||
|
)
|
||||||
|
assembly.assemble(options)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -403,7 +410,13 @@ internal fun asmGeneratorFor(program: Program,
|
||||||
|
|
||||||
// TODO for now, only use the new Intermediary Ast for this experimental codegen:
|
// TODO for now, only use the new Intermediary Ast for this experimental codegen:
|
||||||
val intermediateAst = IntermediateAstMaker(program).transform()
|
val intermediateAst = IntermediateAstMaker(program).transform()
|
||||||
return prog8.codegen.experimental6502.AsmGen(intermediateAst, errors, symbolTable, options)
|
val asmOptions = AssemblerOptions(
|
||||||
|
options.output,
|
||||||
|
options.asmQuiet,
|
||||||
|
options.asmListfile,
|
||||||
|
options.outputDir
|
||||||
|
)
|
||||||
|
return prog8.codegen.experimental6502.AsmGen(intermediateAst, errors, symbolTable, asmOptions)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (options.compTarget.machine.cpu in arrayOf(CpuType.CPU6502, CpuType.CPU65c02))
|
if (options.compTarget.machine.cpu in arrayOf(CpuType.CPU6502, CpuType.CPU65c02))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package prog8.compiler
|
package prog8.compiler
|
||||||
|
|
||||||
import prog8.code.core.Position
|
import prog8.code.core.Position
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
|
|
||||||
|
|
||||||
internal class ErrorReporter: IErrorReporter {
|
internal class ErrorReporter: IErrorReporter {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import prog8.ast.base.SyntaxError
|
||||||
import prog8.ast.statements.Directive
|
import prog8.ast.statements.Directive
|
||||||
import prog8.ast.statements.DirectiveArg
|
import prog8.ast.statements.DirectiveArg
|
||||||
import prog8.code.core.Position
|
import prog8.code.core.Position
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
import prog8.parser.Prog8Parser
|
import prog8.parser.Prog8Parser
|
||||||
import prog8.parser.SourceCode
|
import prog8.parser.SourceCode
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
|
@ -13,7 +13,7 @@ import prog8.code.core.DataType
|
||||||
import prog8.code.core.Encoding
|
import prog8.code.core.Encoding
|
||||||
import prog8.compilerinterface.CompilationOptions
|
import prog8.compilerinterface.CompilationOptions
|
||||||
import prog8.compilerinterface.ICompilationTarget
|
import prog8.compilerinterface.ICompilationTarget
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
|
|
||||||
|
|
||||||
internal fun Program.checkValid(errors: IErrorReporter, compilerOptions: CompilationOptions) {
|
internal fun Program.checkValid(errors: IErrorReporter, compilerOptions: CompilationOptions) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import prog8.ast.walk.IAstVisitor
|
||||||
import prog8.code.core.Position
|
import prog8.code.core.Position
|
||||||
import prog8.compilerinterface.BuiltinFunctions
|
import prog8.compilerinterface.BuiltinFunctions
|
||||||
import prog8.compilerinterface.ICompilationTarget
|
import prog8.compilerinterface.ICompilationTarget
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
|
|
||||||
|
|
||||||
internal class AstIdentifiersChecker(private val errors: IErrorReporter,
|
internal class AstIdentifiersChecker(private val errors: IErrorReporter,
|
||||||
|
|
|
@ -11,8 +11,8 @@ import prog8.ast.walk.IAstModification
|
||||||
import prog8.code.core.Encoding
|
import prog8.code.core.Encoding
|
||||||
import prog8.code.core.NumericDatatypes
|
import prog8.code.core.NumericDatatypes
|
||||||
import prog8.compilerinterface.ICompilationTarget
|
import prog8.compilerinterface.ICompilationTarget
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
import prog8.compilerinterface.InternalCompilerException
|
import prog8.code.core.InternalCompilerException
|
||||||
|
|
||||||
|
|
||||||
class AstPreprocessor(val program: Program, val errors: IErrorReporter, val compTarget: ICompilationTarget) : AstWalker() {
|
class AstPreprocessor(val program: Program, val errors: IErrorReporter, val compTarget: ICompilationTarget) : AstWalker() {
|
||||||
|
|
|
@ -7,9 +7,7 @@ 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.ast.walk.IAstVisitor
|
import prog8.ast.walk.IAstVisitor
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.*
|
||||||
import prog8.code.core.NumericDatatypes
|
|
||||||
import prog8.code.core.Position
|
|
||||||
import prog8.compilerinterface.*
|
import prog8.compilerinterface.*
|
||||||
|
|
||||||
internal class BeforeAsmAstChanger(val program: Program,
|
internal class BeforeAsmAstChanger(val program: Program,
|
||||||
|
|
|
@ -12,7 +12,7 @@ import prog8.code.core.ByteDatatypes
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
import prog8.code.core.PassByReferenceDatatypes
|
import prog8.code.core.PassByReferenceDatatypes
|
||||||
import prog8.code.core.WordDatatypes
|
import prog8.code.core.WordDatatypes
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
|
|
||||||
|
|
||||||
internal class BeforeAsmTypecastCleaner(val program: Program,
|
internal class BeforeAsmTypecastCleaner(val program: Program,
|
||||||
|
|
|
@ -9,7 +9,7 @@ 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.Position
|
import prog8.code.core.Position
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
|
|
||||||
|
|
||||||
private var generatedLabelSequenceNumber: Int = 0
|
private var generatedLabelSequenceNumber: Int = 0
|
||||||
|
|
|
@ -14,12 +14,13 @@ import prog8.ast.walk.IAstModification
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
import prog8.code.core.Encoding
|
import prog8.code.core.Encoding
|
||||||
import prog8.compilerinterface.ICompilationTarget
|
import prog8.compilerinterface.ICompilationTarget
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
|
|
||||||
|
|
||||||
internal class LiteralsToAutoVars(private val program: Program,
|
internal class LiteralsToAutoVars(private val program: Program,
|
||||||
private val target: ICompilationTarget,
|
private val target: ICompilationTarget,
|
||||||
private val errors: IErrorReporter) : AstWalker() {
|
private val errors: IErrorReporter
|
||||||
|
) : AstWalker() {
|
||||||
|
|
||||||
override fun after(string: StringLiteral, parent: Node): Iterable<IAstModification> {
|
override fun after(string: StringLiteral, parent: Node): Iterable<IAstModification> {
|
||||||
if(string.encoding != Encoding.DEFAULT && string.encoding !in target.supportedEncodings) {
|
if(string.encoding != Encoding.DEFAULT && string.encoding !in target.supportedEncodings) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import prog8.code.core.*
|
||||||
import prog8.compilerinterface.BuiltinFunctions
|
import prog8.compilerinterface.BuiltinFunctions
|
||||||
import prog8.compilerinterface.CompilationOptions
|
import prog8.compilerinterface.CompilationOptions
|
||||||
import prog8.compilerinterface.ICompilationTarget
|
import prog8.compilerinterface.ICompilationTarget
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
|
|
||||||
internal class StatementReorderer(val program: Program,
|
internal class StatementReorderer(val program: Program,
|
||||||
val errors: IErrorReporter,
|
val errors: IErrorReporter,
|
||||||
|
|
|
@ -5,8 +5,8 @@ import prog8.ast.base.FatalAstException
|
||||||
import prog8.ast.expressions.*
|
import prog8.ast.expressions.*
|
||||||
import prog8.ast.statements.*
|
import prog8.ast.statements.*
|
||||||
import prog8.ast.walk.IAstVisitor
|
import prog8.ast.walk.IAstVisitor
|
||||||
|
import prog8.code.*
|
||||||
import prog8.code.core.Position
|
import prog8.code.core.Position
|
||||||
import prog8.compilerinterface.*
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
internal class SymbolTableMaker: IAstVisitor {
|
internal class SymbolTableMaker: IAstVisitor {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import prog8.code.core.IterableDatatypes
|
||||||
import prog8.code.core.PassByReferenceDatatypes
|
import prog8.code.core.PassByReferenceDatatypes
|
||||||
import prog8.compilerinterface.BuiltinFunctions
|
import prog8.compilerinterface.BuiltinFunctions
|
||||||
import prog8.compilerinterface.CompilationOptions
|
import prog8.compilerinterface.CompilationOptions
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
|
|
||||||
|
|
||||||
class TypecastsAdder(val program: Program, val options: CompilationOptions, val errors: IErrorReporter) : AstWalker() {
|
class TypecastsAdder(val program: Program, val options: CompilationOptions, val errors: IErrorReporter) : AstWalker() {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import prog8.ast.walk.IAstModification
|
||||||
import prog8.code.core.ArrayDatatypes
|
import prog8.code.core.ArrayDatatypes
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
import prog8.compilerinterface.CompilationOptions
|
import prog8.compilerinterface.CompilationOptions
|
||||||
import prog8.compilerinterface.IErrorReporter
|
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() {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import prog8.ast.walk.IAstVisitor
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
import prog8.code.core.Position
|
import prog8.code.core.Position
|
||||||
import prog8.compilerinterface.BuiltinFunctions
|
import prog8.compilerinterface.BuiltinFunctions
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
import prog8.compilerinterface.builtinFunctionReturnType
|
import prog8.compilerinterface.builtinFunctionReturnType
|
||||||
|
|
||||||
internal class VerifyFunctionArgTypes(val program: Program, val errors: IErrorReporter) : IAstVisitor {
|
internal class VerifyFunctionArgTypes(val program: Program, val errors: IErrorReporter) : IAstVisitor {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import io.kotest.matchers.string.shouldContain
|
||||||
import prog8.ast.Program
|
import prog8.ast.Program
|
||||||
import prog8.ast.internedStringsModuleName
|
import prog8.ast.internedStringsModuleName
|
||||||
import prog8.compiler.ModuleImporter
|
import prog8.compiler.ModuleImporter
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
import prog8.parser.ParseError
|
import prog8.parser.ParseError
|
||||||
import prog8.parser.SourceCode
|
import prog8.parser.SourceCode
|
||||||
import prog8tests.helpers.*
|
import prog8tests.helpers.*
|
||||||
|
|
|
@ -5,10 +5,10 @@ import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
import io.kotest.matchers.string.shouldStartWith
|
import io.kotest.matchers.string.shouldStartWith
|
||||||
import prog8.ast.internedStringsModuleName
|
import prog8.ast.internedStringsModuleName
|
||||||
|
import prog8.code.core.ZeropageType
|
||||||
import prog8.codegen.target.C64Target
|
import prog8.codegen.target.C64Target
|
||||||
import prog8.compiler.determineCompilationOptions
|
import prog8.compiler.determineCompilationOptions
|
||||||
import prog8.compiler.parseImports
|
import prog8.compiler.parseImports
|
||||||
import prog8.compilerinterface.ZeropageType
|
|
||||||
import prog8tests.helpers.ErrorReporterForTests
|
import prog8tests.helpers.ErrorReporterForTests
|
||||||
import prog8tests.helpers.compileText
|
import prog8tests.helpers.compileText
|
||||||
import prog8tests.helpers.outputDir
|
import prog8tests.helpers.outputDir
|
||||||
|
|
|
@ -9,7 +9,7 @@ import io.kotest.matchers.string.shouldContain
|
||||||
import prog8.code.core.toHex
|
import prog8.code.core.toHex
|
||||||
import prog8.codegen.target.C64Target
|
import prog8.codegen.target.C64Target
|
||||||
import prog8.codegen.target.cbm.Mflpt5
|
import prog8.codegen.target.cbm.Mflpt5
|
||||||
import prog8.compilerinterface.InternalCompilerException
|
import prog8.code.core.InternalCompilerException
|
||||||
import prog8tests.helpers.ErrorReporterForTests
|
import prog8tests.helpers.ErrorReporterForTests
|
||||||
import prog8tests.helpers.compileText
|
import prog8tests.helpers.compileText
|
||||||
|
|
||||||
|
|
|
@ -13,15 +13,11 @@ import prog8.ast.ParentSentinel
|
||||||
import prog8.ast.Program
|
import prog8.ast.Program
|
||||||
import prog8.ast.expressions.*
|
import prog8.ast.expressions.*
|
||||||
import prog8.ast.statements.*
|
import prog8.ast.statements.*
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.*
|
||||||
import prog8.code.core.Position
|
|
||||||
import prog8.codegen.target.C64Target
|
import prog8.codegen.target.C64Target
|
||||||
import prog8.compiler.astprocessing.processAstBeforeAsmGeneration
|
import prog8.compiler.astprocessing.processAstBeforeAsmGeneration
|
||||||
import prog8.compiler.printProgram
|
import prog8.compiler.printProgram
|
||||||
import prog8.compilerinterface.CbmPrgLauncherType
|
|
||||||
import prog8.compilerinterface.CompilationOptions
|
import prog8.compilerinterface.CompilationOptions
|
||||||
import prog8.compilerinterface.OutputType
|
|
||||||
import prog8.compilerinterface.ZeropageType
|
|
||||||
import prog8tests.helpers.*
|
import prog8tests.helpers.*
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ import io.kotest.assertions.fail
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
import io.kotest.matchers.shouldNotBe
|
import io.kotest.matchers.shouldNotBe
|
||||||
|
import prog8.code.*
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.DataType
|
||||||
import prog8.code.core.Position
|
import prog8.code.core.Position
|
||||||
import prog8.compilerinterface.*
|
|
||||||
|
|
||||||
class TestSymbolTable: FunSpec({
|
class TestSymbolTable: FunSpec({
|
||||||
test("empty symboltable") {
|
test("empty symboltable") {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import io.kotest.matchers.collections.shouldNotBeIn
|
||||||
import io.kotest.matchers.comparables.shouldBeGreaterThan
|
import io.kotest.matchers.comparables.shouldBeGreaterThan
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
import io.kotest.matchers.shouldNotBe
|
import io.kotest.matchers.shouldNotBe
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.*
|
||||||
import prog8.codegen.target.C64Target
|
import prog8.codegen.target.C64Target
|
||||||
import prog8.codegen.target.Cx16Target
|
import prog8.codegen.target.Cx16Target
|
||||||
import prog8.codegen.target.c64.C64Zeropage
|
import prog8.codegen.target.c64.C64Zeropage
|
||||||
|
|
|
@ -8,17 +8,12 @@ import prog8.ast.expressions.AddressOf
|
||||||
import prog8.ast.expressions.IdentifierReference
|
import prog8.ast.expressions.IdentifierReference
|
||||||
import prog8.ast.expressions.NumericLiteral
|
import prog8.ast.expressions.NumericLiteral
|
||||||
import prog8.ast.statements.*
|
import prog8.ast.statements.*
|
||||||
import prog8.code.core.DataType
|
import prog8.code.core.*
|
||||||
import prog8.code.core.Position
|
|
||||||
import prog8.code.core.RegisterOrPair
|
|
||||||
import prog8.codegen.cpu6502.AsmGen
|
import prog8.codegen.cpu6502.AsmGen
|
||||||
import prog8.codegen.target.C64Target
|
import prog8.codegen.target.C64Target
|
||||||
import prog8.codegen.target.c64.C64Zeropage
|
import prog8.codegen.target.c64.C64Zeropage
|
||||||
import prog8.compiler.astprocessing.SymbolTableMaker
|
import prog8.compiler.astprocessing.SymbolTableMaker
|
||||||
import prog8.compilerinterface.CbmPrgLauncherType
|
|
||||||
import prog8.compilerinterface.CompilationOptions
|
import prog8.compilerinterface.CompilationOptions
|
||||||
import prog8.compilerinterface.OutputType
|
|
||||||
import prog8.compilerinterface.ZeropageType
|
|
||||||
import prog8.parser.SourceCode
|
import prog8.parser.SourceCode
|
||||||
import prog8tests.helpers.DummyFunctions
|
import prog8tests.helpers.DummyFunctions
|
||||||
import prog8tests.helpers.DummyMemsizer
|
import prog8tests.helpers.DummyMemsizer
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package prog8tests.helpers
|
package prog8tests.helpers
|
||||||
|
|
||||||
import prog8.code.core.Position
|
import prog8.code.core.Position
|
||||||
import prog8.compilerinterface.IErrorReporter
|
import prog8.code.core.IErrorReporter
|
||||||
|
|
||||||
internal class ErrorReporterForTests(private val throwExceptionAtReportIfErrors: Boolean=true, private val keepMessagesAfterReporting: Boolean=false): IErrorReporter {
|
internal class ErrorReporterForTests(private val throwExceptionAtReportIfErrors: Boolean=true, private val keepMessagesAfterReporting: Boolean=false):
|
||||||
|
IErrorReporter {
|
||||||
|
|
||||||
val errors = mutableListOf<String>()
|
val errors = mutableListOf<String>()
|
||||||
val warnings = mutableListOf<String>()
|
val warnings = mutableListOf<String>()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package prog8tests.helpers
|
package prog8tests.helpers
|
||||||
|
|
||||||
import prog8.ast.Program
|
import prog8.ast.Program
|
||||||
|
import prog8.code.core.*
|
||||||
import prog8.codegen.cpu6502.AsmGen
|
import prog8.codegen.cpu6502.AsmGen
|
||||||
import prog8.codegen.target.C64Target
|
import prog8.codegen.target.C64Target
|
||||||
import prog8.codegen.target.c64.C64Zeropage
|
import prog8.codegen.target.c64.C64Zeropage
|
||||||
|
|
|
@ -22,6 +22,7 @@ compileTestKotlin {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation project(':codeCore')
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
implementation 'org.antlr:antlr4-runtime:4.9.3'
|
implementation 'org.antlr:antlr4-runtime:4.9.3'
|
||||||
implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.14"
|
implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.14"
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
<orderEntry type="module" module-name="parser" />
|
<orderEntry type="module" module-name="parser" />
|
||||||
|
<orderEntry type="module" module-name="codeCore" />
|
||||||
<orderEntry type="library" name="antlr.antlr4" level="project" />
|
<orderEntry type="library" name="antlr.antlr4" level="project" />
|
||||||
<orderEntry type="library" name="michael.bull.kotlin.result.jvm" level="project" />
|
<orderEntry type="library" name="michael.bull.kotlin.result.jvm" level="project" />
|
||||||
<orderEntry type="module" module-name="codeCore" />
|
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -24,6 +24,7 @@ compileTestKotlin {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation project(':codeCore')
|
||||||
implementation project(':compilerAst')
|
implementation project(':compilerAst')
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.14"
|
implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.14"
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
|
<orderEntry type="module" module-name="codeCore" />
|
||||||
<orderEntry type="module" module-name="compilerAst" />
|
<orderEntry type="module" module-name="compilerAst" />
|
||||||
<orderEntry type="library" name="michael.bull.kotlin.result.jvm" level="project" />
|
<orderEntry type="library" name="michael.bull.kotlin.result.jvm" level="project" />
|
||||||
<orderEntry type="module" module-name="codeCore" />
|
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -9,6 +9,7 @@ import prog8.ast.expressions.FunctionCallExpression
|
||||||
import prog8.ast.expressions.IdentifierReference
|
import prog8.ast.expressions.IdentifierReference
|
||||||
import prog8.ast.statements.*
|
import prog8.ast.statements.*
|
||||||
import prog8.ast.walk.IAstVisitor
|
import prog8.ast.walk.IAstVisitor
|
||||||
|
import prog8.code.core.IErrorReporter
|
||||||
|
|
||||||
|
|
||||||
class CallGraph(private val program: Program, private val allowMissingIdentifierTargetVarDecls: Boolean=false) : IAstVisitor {
|
class CallGraph(private val program: Program, private val allowMissingIdentifierTargetVarDecls: Boolean=false) : IAstVisitor {
|
||||||
|
|
|
@ -1,26 +1,11 @@
|
||||||
package prog8.compilerinterface
|
package prog8.compilerinterface
|
||||||
|
|
||||||
|
import prog8.code.core.CbmPrgLauncherType
|
||||||
|
import prog8.code.core.OutputType
|
||||||
|
import prog8.code.core.ZeropageType
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.io.path.Path
|
import kotlin.io.path.Path
|
||||||
|
|
||||||
enum class OutputType {
|
|
||||||
RAW,
|
|
||||||
PRG,
|
|
||||||
XEX
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class CbmPrgLauncherType {
|
|
||||||
BASIC,
|
|
||||||
NONE
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class ZeropageType {
|
|
||||||
BASICSAFE,
|
|
||||||
FLOATSAFE,
|
|
||||||
KERNALSAFE,
|
|
||||||
FULL,
|
|
||||||
DONTUSE
|
|
||||||
}
|
|
||||||
|
|
||||||
class CompilationOptions(val output: OutputType,
|
class CompilationOptions(val output: OutputType,
|
||||||
val launcher: CbmPrgLauncherType,
|
val launcher: CbmPrgLauncherType,
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package prog8.compilerinterface
|
|
||||||
|
|
||||||
|
|
||||||
interface IAssemblyGenerator {
|
|
||||||
fun compileToAssembly(): IAssemblyProgram?
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IAssemblyProgram {
|
|
||||||
val name: String
|
|
||||||
fun assemble(options: CompilationOptions): Boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
fun viceMonListName(baseFilename: String) = "$baseFilename.vice-mon-list"
|
|
|
@ -46,7 +46,8 @@ abstract class Zeropage(protected val options: CompilationOptions) {
|
||||||
datatype: DataType,
|
datatype: DataType,
|
||||||
numElements: Int?,
|
numElements: Int?,
|
||||||
position: Position?,
|
position: Position?,
|
||||||
errors: IErrorReporter): Result<Pair<UInt, Int>, ZeropageAllocationError> {
|
errors: IErrorReporter
|
||||||
|
): Result<Pair<UInt, Int>, ZeropageAllocationError> {
|
||||||
|
|
||||||
require(name.isEmpty() || name !in allocatedVariables) {"name can't be allocated twice"}
|
require(name.isEmpty() || name !in allocatedVariables) {"name can't be allocated twice"}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ compileTestKotlin {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation project(':codeCore')
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
// implementation "org.jetbrains.kotlin:kotlin-reflect"
|
// implementation "org.jetbrains.kotlin:kotlin-reflect"
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-cli:0.3.4'
|
implementation 'org.jetbrains.kotlinx:kotlinx-cli:0.3.4'
|
||||||
|
|
|
@ -12,5 +12,6 @@
|
||||||
<orderEntry type="library" name="jetbrains.kotlinx.cli.jvm" level="project" />
|
<orderEntry type="library" name="jetbrains.kotlinx.cli.jvm" level="project" />
|
||||||
<orderEntry type="library" name="github.hypfvieh.dbus.java" level="project" />
|
<orderEntry type="library" name="github.hypfvieh.dbus.java" level="project" />
|
||||||
<orderEntry type="library" name="slf4j.simple" level="project" />
|
<orderEntry type="library" name="slf4j.simple" level="project" />
|
||||||
|
<orderEntry type="module" module-name="codeCore" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -3,10 +3,6 @@ TODO
|
||||||
|
|
||||||
For next release
|
For next release
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
- make an intermediate representation containing the SymbolTable and dumbed down version of the Ast.
|
|
||||||
no vardecls in it anymore (these are part of the symboltable) and baked types, so no inferType too.
|
|
||||||
no name lookup in the Ast, always do this in the symbol table.
|
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ compileTestKotlin {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation project(':codeCore')
|
||||||
implementation project(':compilerInterfaces')
|
implementation project(':compilerInterfaces')
|
||||||
implementation project(':compiler')
|
implementation project(':compiler')
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
|
|
|
@ -9,11 +9,12 @@
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
<orderEntry type="module" module-name="compiler" />
|
|
||||||
<orderEntry type="library" name="jetbrains.kotlinx.cli.jvm" level="project" />
|
<orderEntry type="library" name="jetbrains.kotlinx.cli.jvm" level="project" />
|
||||||
<orderEntry type="library" name="glassfish.javax.json" level="project" />
|
<orderEntry type="library" name="glassfish.javax.json" level="project" />
|
||||||
<orderEntry type="library" name="takes" level="project" />
|
<orderEntry type="library" name="takes" level="project" />
|
||||||
<orderEntry type="library" name="slf4j.simple" level="project" />
|
<orderEntry type="library" name="slf4j.simple" level="project" />
|
||||||
|
<orderEntry type="module" module-name="codeCore" />
|
||||||
<orderEntry type="module" module-name="compilerInterfaces" />
|
<orderEntry type="module" module-name="compilerInterfaces" />
|
||||||
|
<orderEntry type="module" module-name="compiler" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -1,7 +1,9 @@
|
||||||
include(
|
include(
|
||||||
':parser',
|
':parser',
|
||||||
':compilerInterfaces',
|
':codeCore',
|
||||||
|
':codeAst',
|
||||||
':compilerAst',
|
':compilerAst',
|
||||||
|
':compilerInterfaces',
|
||||||
':codeOptimizers',
|
':codeOptimizers',
|
||||||
':codeGenTargets',
|
':codeGenTargets',
|
||||||
':codeGenCpu6502',
|
':codeGenCpu6502',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user