-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from CASC-Lang/trait-impl
Trait implmplemtation phase I: Refactor top-level parsing scheme
- Loading branch information
Showing
16 changed files
with
366 additions
and
242 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.casc.lang.ast | ||
|
||
import org.casc.lang.table.HasFlag | ||
import org.casc.lang.table.Reference | ||
import org.casc.lang.utils.getOrElse | ||
import org.objectweb.asm.Opcodes | ||
|
||
data class ClassInstance( | ||
override val packageReference: Reference?, | ||
val accessorToken: Token?, | ||
val mutKeyword: Token?, | ||
val classKeyword: Token?, | ||
override val typeReference: Reference, | ||
override val fields: List<Field>, | ||
override val accessor: Accessor = Accessor.fromString(accessorToken?.literal) | ||
) : TypeInstance(packageReference, typeReference), HasFlag { | ||
override val flag: Int by lazy { | ||
var flag = Opcodes.ACC_SUPER | ||
flag += accessor.access | ||
flag += mutKeyword.getOrElse(0, Opcodes.ACC_FINAL) | ||
flag | ||
} | ||
|
||
val parentClassReference: Reference by lazy { | ||
impl?.parentClassReference ?: Reference.OBJECT_TYPE_REFERENCE | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
package org.casc.lang.ast | ||
|
||
data class File(val path: String, val relativeFilePath: String, var clazz: Class) | ||
import org.casc.lang.table.Reference | ||
|
||
data class File(val path: String, val relativeFilePath: String, val usages: List<Reference>, var typeInstance: TypeInstance) { | ||
val fileName: String by lazy { | ||
relativeFilePath.split('\\', '/').last() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.casc.lang.ast | ||
|
||
import org.casc.lang.table.Reference | ||
|
||
data class Impl( | ||
val implKeyword: Token, | ||
val parentClassReference: Reference?, | ||
var companionBlock: List<Statement>, | ||
var constructors: List<Constructor>, | ||
var functions: List<Function> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.casc.lang.ast | ||
|
||
data class TraitImpl(val implKeyword: Token, val functions: List<Function>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.casc.lang.ast | ||
|
||
import org.casc.lang.table.Reference | ||
|
||
sealed class TypeInstance(open val packageReference: Reference?, open val typeReference: Reference) { | ||
abstract val fields: List<Field> | ||
var impl: Impl? = null | ||
var traitImpls: List<TraitImpl>? = null | ||
var memberTypeInstances: List<TypeInstance>? = null | ||
abstract val accessor: Accessor | ||
|
||
val reference: Reference by lazy { | ||
Reference(packageReference?.fullQualifiedPath, typeReference.fullQualifiedPath) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.