|
@@ -29,6 +29,7 @@ Const DECL_FINAL:Int= $080000
|
|
|
|
|
|
Const DECL_SEMANTED:Int= $100000
|
|
Const DECL_SEMANTED:Int= $100000
|
|
Const DECL_SEMANTING:Int= $200000
|
|
Const DECL_SEMANTING:Int= $200000
|
|
|
|
+Const DECL_CYCLIC:Int= $8000000
|
|
|
|
|
|
Const DECL_POINTER:Int= $400000
|
|
Const DECL_POINTER:Int= $400000
|
|
|
|
|
|
@@ -45,6 +46,7 @@ Const DECL_API_DEFAULT:Int=DECL_API_CDECL
|
|
Const CLASS_INTERFACE:Int= $002000
|
|
Const CLASS_INTERFACE:Int= $002000
|
|
Const CLASS_THROWABLE:Int= $004000
|
|
Const CLASS_THROWABLE:Int= $004000
|
|
Const CLASS_STRUCT:Int= $008000
|
|
Const CLASS_STRUCT:Int= $008000
|
|
|
|
+Const CLASS_GENERIC:Int= $001000
|
|
|
|
|
|
Const SCOPE_FUNC:Int = 0
|
|
Const SCOPE_FUNC:Int = 0
|
|
Const SCOPE_CLASS_LOCAL:Int = 1
|
|
Const SCOPE_CLASS_LOCAL:Int = 1
|
|
@@ -225,7 +227,12 @@ Type TDecl
|
|
|
|
|
|
If IsSemanted() Return
|
|
If IsSemanted() Return
|
|
|
|
|
|
- If IsSemanting() Err "Cyclic declaration of '"+ident+"'."
|
|
|
|
|
|
+ If IsSemanting() Then
|
|
|
|
+ If attrs & DECL_CYCLIC Then
|
|
|
|
+ Return
|
|
|
|
+ End If
|
|
|
|
+ Err "Cyclic declaration of '"+ident+"'."
|
|
|
|
+ End If
|
|
|
|
|
|
If actual<>Self
|
|
If actual<>Self
|
|
actual.Semant
|
|
actual.Semant
|
|
@@ -336,7 +343,7 @@ Type TValDecl Extends TDecl
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method OnSemant()
|
|
Method OnSemant()
|
|
-
|
|
|
|
|
|
+'DebugStop
|
|
If declTy
|
|
If declTy
|
|
|
|
|
|
Local at:TType = TArrayType(declTy)
|
|
Local at:TType = TArrayType(declTy)
|
|
@@ -562,8 +569,10 @@ Type TLocalDecl Extends TVarDecl
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method OnCopy:TDecl(deep:Int = True)
|
|
Method OnCopy:TDecl(deep:Int = True)
|
|
- Local decl:TLocalDecl = New TLocalDecl.Create( ident,ty,CopyInit(),attrs &~ DECL_SEMANTED, generated, volatile )
|
|
|
|
|
|
+ Local decl:TLocalDecl = New TLocalDecl.Create( ident,declTy,declInit,attrs &~ DECL_SEMANTED, generated, volatile )
|
|
decl.scope = scope
|
|
decl.scope = scope
|
|
|
|
+ decl.ty = ty
|
|
|
|
+ decl.init = init
|
|
Return decl
|
|
Return decl
|
|
End Method
|
|
End Method
|
|
|
|
|
|
@@ -604,9 +613,9 @@ Type TArgDecl Extends TLocalDecl
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method OnCopy:TDecl(deep:Int = True)
|
|
Method OnCopy:TDecl(deep:Int = True)
|
|
- Local d:TArgDecl = New TArgDecl.Create( ident,ty,CopyInit(),attrs,generated,volatile )
|
|
|
|
- d.ty = d.declTy
|
|
|
|
- d.init = d.declInit
|
|
|
|
|
|
+ Local d:TArgDecl = New TArgDecl.Create( ident,declTy,declInit,attrs,generated,volatile )
|
|
|
|
+ d.ty = ty
|
|
|
|
+ d.init = init
|
|
Return d
|
|
Return d
|
|
End Method
|
|
End Method
|
|
|
|
|
|
@@ -636,7 +645,10 @@ Type TGlobalDecl Extends TVarDecl
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method OnCopy:TDecl(deep:Int = True)
|
|
Method OnCopy:TDecl(deep:Int = True)
|
|
- Return New TGlobalDecl.Create( ident,ty,CopyInit(),attrs,funcGlobal )
|
|
|
|
|
|
+ Local g:TGlobalDecl = New TGlobalDecl.Create( ident,declTy,declInit,attrs,funcGlobal )
|
|
|
|
+ g.ty = ty
|
|
|
|
+ g.init = init
|
|
|
|
+ Return g
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method ToString$()
|
|
Method ToString$()
|
|
@@ -683,7 +695,9 @@ Type TFieldDecl Extends TVarDecl
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method OnCopy:TDecl(deep:Int = True)
|
|
Method OnCopy:TDecl(deep:Int = True)
|
|
- Local f:TFieldDecl = New TFieldDecl.Create( ident,ty,CopyInit(),attrs )
|
|
|
|
|
|
+ Local f:TFieldDecl = New TFieldDecl.Create( ident,declTy,declInit,attrs )
|
|
|
|
+ f.ty = ty
|
|
|
|
+ f.init = init
|
|
f.metadata = metadata
|
|
f.metadata = metadata
|
|
Return f
|
|
Return f
|
|
End Method
|
|
End Method
|
|
@@ -803,14 +817,14 @@ Type TScopeDecl Extends TDecl
|
|
Return fdecls
|
|
Return fdecls
|
|
End Method
|
|
End Method
|
|
|
|
|
|
- Method InsertDecl( decl:TDecl )
|
|
|
|
|
|
+ Method InsertDecl( decl:TDecl, isCopy:Int = False )
|
|
|
|
|
|
- If decl.scope And Not (decl.attrs & DECL_INITONLY) InternalErr
|
|
|
|
|
|
+ If decl.scope And Not (decl.attrs & DECL_INITONLY) And Not isCopy InternalErr
|
|
|
|
|
|
'Local ident$=decl.ident
|
|
'Local ident$=decl.ident
|
|
If Not decl.ident Return
|
|
If Not decl.ident Return
|
|
|
|
|
|
- If Not decl.scope Then
|
|
|
|
|
|
+ If Not decl.scope Or isCopy Then
|
|
decl.scope=Self
|
|
decl.scope=Self
|
|
End If
|
|
End If
|
|
_decls.AddLast decl
|
|
_decls.AddLast decl
|
|
@@ -949,7 +963,7 @@ Type TScopeDecl Extends TDecl
|
|
End If
|
|
End If
|
|
|
|
|
|
' if scope is an interface, also check implemented/extended interfaces?
|
|
' if scope is an interface, also check implemented/extended interfaces?
|
|
- If TClassDecl(tscope) And TClassDecl(tscope).IsInterface() Then
|
|
|
|
|
|
+ If TClassDecl(tscope) Then'And TClassDecl(tscope).IsInterface() Then
|
|
If TClassDecl(tscope).implments Then
|
|
If TClassDecl(tscope).implments Then
|
|
For Local idecl:TScopeDecl = EachIn TClassDecl(tscope).implments
|
|
For Local idecl:TScopeDecl = EachIn TClassDecl(tscope).implments
|
|
Local decl:Object=idecl.GetDeclList( ident, declList, maxSearchDepth )
|
|
Local decl:Object=idecl.GetDeclList( ident, declList, maxSearchDepth )
|
|
@@ -1059,8 +1073,10 @@ Type TScopeDecl Extends TDecl
|
|
Local cdecl:TClassDecl=TClassDecl( decl )
|
|
Local cdecl:TClassDecl=TClassDecl( decl )
|
|
If cdecl
|
|
If cdecl
|
|
cdecl.AssertAccess
|
|
cdecl.AssertAccess
|
|
- cdecl=cdecl.GenClassInstance( args )
|
|
|
|
- cdecl.Semant
|
|
|
|
|
|
+ If Not cdecl.instanceof Then
|
|
|
|
+ cdecl=cdecl.GenClassInstance( args )
|
|
|
|
+ cdecl.Semant
|
|
|
|
+ End If
|
|
Return cdecl.objectType
|
|
Return cdecl.objectType
|
|
EndIf
|
|
EndIf
|
|
EndIf
|
|
EndIf
|
|
@@ -1630,6 +1646,7 @@ Type TFuncDecl Extends TBlockDecl
|
|
Next
|
|
Next
|
|
End If
|
|
End If
|
|
t.retType = retType
|
|
t.retType = retType
|
|
|
|
+ t.retTypeExpr = retTypeExpr
|
|
t.scope = scope
|
|
t.scope = scope
|
|
t.overrides = overrides
|
|
t.overrides = overrides
|
|
t.superCtor = superCtor
|
|
t.superCtor = superCtor
|
|
@@ -2016,7 +2033,7 @@ Type TNewDecl Extends TFuncDecl
|
|
Local t:TNewDecl = TNewDecl(New TNewDecl.CreateF( ident,retType,args,attrs &~DECL_SEMANTED ))
|
|
Local t:TNewDecl = TNewDecl(New TNewDecl.CreateF( ident,retType,args,attrs &~DECL_SEMANTED ))
|
|
If deep Then
|
|
If deep Then
|
|
For Local stmt:TStmt=EachIn stmts
|
|
For Local stmt:TStmt=EachIn stmts
|
|
- t.AddStmt stmt.Copy( t )
|
|
|
|
|
|
+ t.AddStmt stmt.Copy(Null)
|
|
Next
|
|
Next
|
|
End If
|
|
End If
|
|
t.retType = retType
|
|
t.retType = retType
|
|
@@ -2054,7 +2071,7 @@ Type TClassDecl Extends TScopeDecl
|
|
|
|
|
|
Field lastOffset:Int
|
|
Field lastOffset:Int
|
|
|
|
|
|
- Field args:String[]
|
|
|
|
|
|
+ Field args:TTemplateArg[]
|
|
Field superTy:TIdentType
|
|
Field superTy:TIdentType
|
|
Field impltys:TIdentType[]
|
|
Field impltys:TIdentType[]
|
|
|
|
|
|
@@ -2069,10 +2086,11 @@ Type TClassDecl Extends TScopeDecl
|
|
|
|
|
|
Field objectType:TObjectType '"canned" objectType
|
|
Field objectType:TObjectType '"canned" objectType
|
|
Field globInit:Int
|
|
Field globInit:Int
|
|
|
|
+ Field templateSource:TTemplateRecord
|
|
|
|
|
|
'Global nullObjectClass:TClassDecl=New TNullDecl.Create( "{NULL}",Null,Null,Null,DECL_ABSTRACT|DECL_EXTERN )
|
|
'Global nullObjectClass:TClassDecl=New TNullDecl.Create( "{NULL}",Null,Null,Null,DECL_ABSTRACT|DECL_EXTERN )
|
|
|
|
|
|
- Method Create:TClassDecl( ident$,args:String[],superTy:TIdentType,impls:TIdentType[],attrs:Int )
|
|
|
|
|
|
+ Method Create:TClassDecl( ident$,args:TTemplateArg[],superTy:TIdentType,impls:TIdentType[],attrs:Int )
|
|
Self.ident=ident
|
|
Self.ident=ident
|
|
Self.args=args
|
|
Self.args=args
|
|
Self.superTy=superTy
|
|
Self.superTy=superTy
|
|
@@ -2081,7 +2099,6 @@ Type TClassDecl Extends TScopeDecl
|
|
Self.objectType=New TObjectType.Create( Self )
|
|
Self.objectType=New TObjectType.Create( Self )
|
|
If args
|
|
If args
|
|
instances=New TList
|
|
instances=New TList
|
|
- instances.AddLast Self
|
|
|
|
EndIf
|
|
EndIf
|
|
Return Self
|
|
Return Self
|
|
End Method
|
|
End Method
|
|
@@ -2092,19 +2109,28 @@ Type TClassDecl Extends TScopeDecl
|
|
|
|
|
|
Method ToString$()
|
|
Method ToString$()
|
|
Local t$
|
|
Local t$
|
|
|
|
+
|
|
If args Then
|
|
If args Then
|
|
- For Local i:Int=0 Until args.Length
|
|
|
|
- If i t:+","
|
|
|
|
|
|
+ For Local i:Int=0 Until args.Length
|
|
|
|
+ If i Then
|
|
|
|
+ t :+ ","
|
|
|
|
+ End If
|
|
t:+args[i].ToString()
|
|
t:+args[i].ToString()
|
|
Next
|
|
Next
|
|
ElseIf instargs
|
|
ElseIf instargs
|
|
|
|
+ For Local i:Int=0 Until instargs.Length
|
|
|
|
+ If i Then
|
|
|
|
+ t :+ ","
|
|
|
|
+ End If
|
|
|
|
+ t :+ instargs[i].ToString()
|
|
|
|
+ Next
|
|
End If
|
|
End If
|
|
If t t="<"+t+">"
|
|
If t t="<"+t+">"
|
|
Return ident+t
|
|
Return ident+t
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method ToTypeString:String()
|
|
Method ToTypeString:String()
|
|
- Return ident
|
|
|
|
|
|
+ Return ToString()
|
|
End Method
|
|
End Method
|
|
Rem
|
|
Rem
|
|
Method GenClassInstance:TClassDecl( instArgs:TClassDecl[] )
|
|
Method GenClassInstance:TClassDecl( instArgs:TClassDecl[] )
|
|
@@ -2165,7 +2191,7 @@ Rem
|
|
Return inst
|
|
Return inst
|
|
End Method
|
|
End Method
|
|
End Rem
|
|
End Rem
|
|
- Method GenClassInstance:TClassDecl( instArgs:TType[] )
|
|
|
|
|
|
+ Method GenClassInstance:TClassDecl( instArgs:TType[], declImported:Int = False )
|
|
|
|
|
|
If instanceof InternalErr
|
|
If instanceof InternalErr
|
|
|
|
|
|
@@ -2193,25 +2219,42 @@ End Rem
|
|
Next
|
|
Next
|
|
If equal Return inst
|
|
If equal Return inst
|
|
Next
|
|
Next
|
|
-
|
|
|
|
|
|
+
|
|
Local inst:TClassDecl=New TClassDecl.Create( ident,Null,superTy,impltys, attrs )
|
|
Local inst:TClassDecl=New TClassDecl.Create( ident,Null,superTy,impltys, attrs )
|
|
|
|
|
|
inst.attrs:&~DECL_SEMANTED
|
|
inst.attrs:&~DECL_SEMANTED
|
|
|
|
+
|
|
inst.munged=munged
|
|
inst.munged=munged
|
|
inst.errInfo=errInfo
|
|
inst.errInfo=errInfo
|
|
inst.scope=scope
|
|
inst.scope=scope
|
|
inst.instanceof=Self
|
|
inst.instanceof=Self
|
|
inst.instArgs=instArgs
|
|
inst.instArgs=instArgs
|
|
|
|
+ inst.templateSource = templateSource
|
|
instances.AddLast inst
|
|
instances.AddLast inst
|
|
|
|
|
|
|
|
+ inst.declImported = declImported
|
|
|
|
+
|
|
For Local i:Int=0 Until args.Length
|
|
For Local i:Int=0 Until args.Length
|
|
- inst.InsertDecl New TAliasDecl.Create( args[i].ToString(),instArgs[i],0 )
|
|
|
|
- Next
|
|
|
|
|
|
|
|
|
|
+ ' ensure parameter types are compatible
|
|
|
|
+ If args[i].superTy Then
|
|
|
|
+ args[i].superTy = args[i].superTy.Semant()
|
|
|
|
+ If Not instArgs[i].EqualsType(args[i].superTy) And Not instArgs[i].ExtendsType(args[i].superTy) Then
|
|
|
|
+ Err "Type parameter '" + instArgs[i].ToString() + "' is not within its bound; should extend '" + args[i].superTy.ToString() + "'"
|
|
|
|
+ End If
|
|
|
|
+ End If
|
|
|
|
+
|
|
|
|
+ inst.InsertDecl New TAliasDecl.Create( args[i].ident,instArgs[i],0 )
|
|
|
|
+ Next
|
|
|
|
+
|
|
For Local decl:TDecl=EachIn _decls
|
|
For Local decl:TDecl=EachIn _decls
|
|
- inst.InsertDecl decl.Copy()
|
|
|
|
|
|
+ inst.InsertDecl decl.Copy(), True
|
|
Next
|
|
Next
|
|
|
|
|
|
|
|
+ If Not declImported Then
|
|
|
|
+ inst.scope = _env.ModuleScope()
|
|
|
|
+ End If
|
|
|
|
+
|
|
Return inst
|
|
Return inst
|
|
End Method
|
|
End Method
|
|
|
|
|
|
@@ -2456,11 +2499,12 @@ End Rem
|
|
If func.IdentLower() = fdecl.IdentLower() And func.EqualsArgs(fdecl) Then
|
|
If func.IdentLower() = fdecl.IdentLower() And func.EqualsArgs(fdecl) Then
|
|
Return func
|
|
Return func
|
|
End If
|
|
End If
|
|
-
|
|
|
|
|
|
+
|
|
Next
|
|
Next
|
|
|
|
|
|
Return fdecl
|
|
Return fdecl
|
|
End Method
|
|
End Method
|
|
|
|
+
|
|
|
|
|
|
Method ExtendsClass:Int( cdecl:TClassDecl )
|
|
Method ExtendsClass:Int( cdecl:TClassDecl )
|
|
'If Self=nullObjectClass Return True
|
|
'If Self=nullObjectClass Return True
|
|
@@ -2484,6 +2528,10 @@ End Rem
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method OnSemant()
|
|
Method OnSemant()
|
|
|
|
+
|
|
|
|
+ If args Then
|
|
|
|
+ Return
|
|
|
|
+ End If
|
|
|
|
|
|
PushEnv Self
|
|
PushEnv Self
|
|
|
|
|
|
@@ -2509,7 +2557,9 @@ End Rem
|
|
Local impls:TClassDecl[]=New TClassDecl[impltys.Length]
|
|
Local impls:TClassDecl[]=New TClassDecl[impltys.Length]
|
|
Local implsall:TStack=New TStack
|
|
Local implsall:TStack=New TStack
|
|
For Local i:Int=0 Until impltys.Length
|
|
For Local i:Int=0 Until impltys.Length
|
|
|
|
+ attrs :| DECL_CYCLIC
|
|
Local cdecl:TClassDecl=impltys[i].SemantClass()
|
|
Local cdecl:TClassDecl=impltys[i].SemantClass()
|
|
|
|
+ attrs :~ DECL_CYCLIC
|
|
If Not cdecl.IsInterface()
|
|
If Not cdecl.IsInterface()
|
|
Err cdecl.ToString()+" is a type, not an interface."
|
|
Err cdecl.ToString()+" is a type, not an interface."
|
|
EndIf
|
|
EndIf
|
|
@@ -2597,6 +2647,7 @@ End Rem
|
|
EndIf
|
|
EndIf
|
|
|
|
|
|
'NOTE: do this AFTER super semant so UpdateAttrs order is cool.
|
|
'NOTE: do this AFTER super semant so UpdateAttrs order is cool.
|
|
|
|
+
|
|
If AppScope() Then
|
|
If AppScope() Then
|
|
AppScope().semantedClasses.AddLast Self
|
|
AppScope().semantedClasses.AddLast Self
|
|
End If
|
|
End If
|
|
@@ -2606,6 +2657,9 @@ End Rem
|
|
' If IsSemanted() Return
|
|
' If IsSemanted() Return
|
|
|
|
|
|
' Super.Semant()
|
|
' Super.Semant()
|
|
|
|
+ If args Then
|
|
|
|
+ Return
|
|
|
|
+ End If
|
|
|
|
|
|
For Local decl:TConstDecl = EachIn Decls()
|
|
For Local decl:TConstDecl = EachIn Decls()
|
|
decl.Semant()
|
|
decl.Semant()
|
|
@@ -2792,7 +2846,7 @@ End Rem
|
|
Local found:Int
|
|
Local found:Int
|
|
For Local decl2:TFuncDecl=EachIn impls
|
|
For Local decl2:TFuncDecl=EachIn impls
|
|
If decl.IdentLower() = decl2.IdentLower()
|
|
If decl.IdentLower() = decl2.IdentLower()
|
|
- If Not decl2.EqualsFunc( decl )
|
|
|
|
|
|
+ If decl2.argDecls.Length = decl.argDecls.Length And Not decl2.EqualsFunc( decl )
|
|
Err "Cannot mix incompatible method signatures." + decl2.ToString() + " vs " + decl.ToString() + "."
|
|
Err "Cannot mix incompatible method signatures." + decl2.ToString() + " vs " + decl.ToString() + "."
|
|
Else
|
|
Else
|
|
found = True
|
|
found = True
|
|
@@ -2840,6 +2894,16 @@ End Rem
|
|
lastOffset :+ modifier
|
|
lastOffset :+ modifier
|
|
End Method
|
|
End Method
|
|
|
|
|
|
|
|
+ Method ImplementsInterface:Int(ident:String)
|
|
|
|
+ ident = ident.ToLower()
|
|
|
|
+ For Local iface:TClassDecl = EachIn implmentsAll
|
|
|
|
+ If iface.IdentLower() = ident Then
|
|
|
|
+ Return True
|
|
|
|
+ End If
|
|
|
|
+ Next
|
|
|
|
+ Return False
|
|
|
|
+ End Method
|
|
|
|
+
|
|
' returns a map of all interfaces implemented in this hierarchy
|
|
' returns a map of all interfaces implemented in this hierarchy
|
|
Method GetInterfaces:TMap(map:TMap = Null)
|
|
Method GetInterfaces:TMap(map:TMap = Null)
|
|
If Not map Then
|
|
If Not map Then
|
|
@@ -3022,7 +3086,7 @@ Type TModuleDecl Extends TScopeDecl
|
|
Self.filepath=filepath
|
|
Self.filepath=filepath
|
|
Self.attrs=attrs
|
|
Self.attrs=attrs
|
|
|
|
|
|
- If ident.Find(".") <> -1 Then
|
|
|
|
|
|
+ If ident.Find(".") <> -1 And ident.find("/") = -1 And ident.find("\") = -1 Then
|
|
Local m:String = ident[..ident.Find(".")]
|
|
Local m:String = ident[..ident.Find(".")]
|
|
Local ns:TNamespaceDecl = TNamespaceDecl(_appInstance.GetDecl(m.ToLower()))
|
|
Local ns:TNamespaceDecl = TNamespaceDecl(_appInstance.GetDecl(m.ToLower()))
|
|
If Not ns Then
|
|
If Not ns Then
|
|
@@ -3239,7 +3303,16 @@ Type TModuleDecl Extends TScopeDecl
|
|
Next
|
|
Next
|
|
|
|
|
|
For Local cdecl:TClassDecl=EachIn _decls
|
|
For Local cdecl:TClassDecl=EachIn _decls
|
|
- cdecl.Semant
|
|
|
|
|
|
+ If cdecl.args Then
|
|
|
|
+ For Local inst:TClassDecl = EachIn cdecl.instances
|
|
|
|
+ For Local idecl:TDecl = EachIn inst.Decls()
|
|
|
|
+ If TAliasDecl( idecl ) Continue
|
|
|
|
+ idecl.Semant()
|
|
|
|
+ Next
|
|
|
|
+ Next
|
|
|
|
+ Else
|
|
|
|
+ cdecl.Semant
|
|
|
|
+ End If
|
|
Next
|
|
Next
|
|
|
|
|
|
For Local fdecl:TFuncDecl=EachIn _decls
|
|
For Local fdecl:TFuncDecl=EachIn _decls
|