fix symbol usage tracking, also track scopes themselves.

Fix directive option comparisons.
Vars cannot overwrite builtin functions.
This commit is contained in:
Irmen de Jong 2018-09-05 23:14:08 +02:00
parent 28ab7bbe34
commit 831d41dbc6
3 changed files with 12 additions and 6 deletions

View File

@ -3,8 +3,14 @@
%import c64lib
~ main $c003 {
~ not_main $d000 {
const float len1 = 111 ;len([1,2,3])
const float round1 = 111 ;len([1,2,3])
const float sin1 = 111 ;len([1,2,3])
float cos1 = 111 ;len([1,2,3])
}
~ main $c003 {
const word len1 = len([1,2,3,wa1, wa2, ws1, all1])
const word wa1 = ceil(abs(-999.22))
const byte wa2 = abs(-99)
@ -145,10 +151,6 @@ some_label_def: A=44
%asmbinary "derp", 0, 200
}
%option enable_floats
%option enable_floats
%option enable_floats
%import imported
%import imported
%import imported2

View File

@ -53,6 +53,10 @@ class AstIdentifiersChecker : IAstProcessor {
}
override fun process(decl: VarDecl): IStatement {
if(BuiltinFunctionNames.contains(decl.name))
// the builtin functions can't be redefined
checkResult.add(NameError("builtin function cannot be redefined", decl.position))
val scopedName = decl.scopedname.joinToString(".")
val existing = symbols[scopedName]
if(existing!=null) {

View File

@ -30,7 +30,7 @@ fun Number.toHex(): String {
}
data class Mflpt5(val b0: Short, val b1: Short, val b2: Short, val b3: Short, val b4: Short){
data class Mflpt5(val b0: Short, val b1: Short, val b2: Short, val b3: Short, val b4: Short) {
companion object {
val zero = Mflpt5(0, 0,0,0,0)