Browse Source

More String Var/String conversion enhancements.
Support for passing a function by reference (function pointer).
Interface files now correctly include imported files.

woollybah 11 years ago
parent
commit
6fd32eb2e2
6 changed files with 367 additions and 260 deletions
  1. 75 34
      ctranslator.bmx
  2. 26 10
      decl.bmx
  3. 211 1
      expr.bmx
  4. 53 16
      iparser.bmx
  5. 1 199
      parser.bmx
  6. 1 0
      translator.bmx

+ 75 - 34
ctranslator.bmx

@@ -38,6 +38,7 @@ Type TCTranslator Extends TTranslator
 		If TDoubleType( ty ) Return "BBDOUBLE"
 		If TLongType( ty ) Return "BBLONG"
 		If TStringType( ty ) Return "BBSTRING"
+		If TStringVarPtrType( ty ) Return "BBSTRING *"
 		If TArrayType( ty ) Return "BBARRAY"
 		If TObjectType( ty ) Return "BBOBJECT"
 		If TBytePtrType( ty ) Return "BBBYTE *"
@@ -161,6 +162,16 @@ Type TCTranslator Extends TTranslator
 		For Local i:Int=0 Until decl.argDecls.Length
 			If t t:+","
 			If i < args.length
+				If TStringVarPtrType(TArgDecl(decl.argDecls[i].actual).ty) Then
+					If TCastExpr(args[i]) And TStringType(TCastExpr(args[i]).expr.exprType) Then
+						t:+ "&"
+					End If
+				Else If TFunctionPtrType(TArgDecl(decl.argDecls[i].actual).ty) Then
+					If TInvokeExpr(args[i]) Then
+						t:+ "&" + TInvokeExpr(args[i]).decl.munged
+						Continue
+					End If
+				End If
 				t:+TransTemplateCast( TArgDecl(decl.argDecls[i].actual).ty,args[i].exprType,args[i].Trans() )
 			Else
 				decl.argDecls[i].Semant()
@@ -306,9 +317,9 @@ Type TCTranslator Extends TTranslator
 	
 	Method TransField$( decl:TFieldDecl,lhs:TExpr )
 		If lhs Then
-			Return TransFieldRef(decl, TransSubExpr( lhs ))
+			Return TransFieldRef(decl, TransSubExpr( lhs ), lhs.exprType)
 		Else
-			Return TransFieldRef(decl, "o")
+			Return TransFieldRef(decl, "o", Null)
 		End If
 '		Local swiz$
 '		If TObjectType( decl.ty )
@@ -319,12 +330,16 @@ Type TCTranslator Extends TTranslator
 	End Method
 		
 	Method TransFunc$( decl:TFuncDecl,args:TExpr[],lhs:TExpr )
+If decl.ident = "AddHook" DebugStop
 		If decl.IsMethod()
 			If lhs And Not TSelfExpr(lhs) Then
 				If lhs.exprType = TType.stringType Then
 					Return decl.munged + TransArgs(args, decl, TransSubExpr( lhs ))
 'If decl.ident = "Print" DebugStop
-'DebugStop				
+'DebugStop		
+				Else If lhs.exprType = TType.stringVarPointerType Then
+'DebugStop
+					Return decl.munged + TransArgs(args, decl, "*" + TransSubExpr( lhs ))
 				End If
 'If decl.ident = "Eof" DebugStop
 				
@@ -522,6 +537,9 @@ Type TCTranslator Extends TTranslator
 			If TFloatType( src ) Return "bbStringFromFloat"+Bra( t )
 			If TDoubleType( src ) Return "bbStringFromDouble"+Bra( t )
 			If TStringType( src ) Return t
+			If TStringVarPtrType( src ) Return "*" + t
+		Else If TStringVarPtrType( dst )
+'DebugStop
 		Else If TByteType( dst )
 			If TByteType( src) Return t
 			If TIntType( src ) Return Bra("(BBBYTE)"+t)
@@ -616,6 +634,7 @@ Type TCTranslator Extends TTranslator
 	End Method
 	
 	Method TransSliceExpr$( expr:TSliceExpr )
+'DebugStop
 		Local t_expr:String=TransSubExpr( expr.expr )
 		Local t_args$
 		If expr.from Then
@@ -628,6 +647,8 @@ Type TCTranslator Extends TTranslator
 		Else
 			If TArrayType(expr.exprType) Then
 				t_args :+ "," + t_expr + "->scales[0]"
+			Else If TStringVarPtrType(expr.exprType) Then
+				t_args :+ ",(*" + t_expr + ")->length"
 			Else
 				t_args :+ "," + t_expr + "->length"
 			End If
@@ -635,6 +656,8 @@ Type TCTranslator Extends TTranslator
 		
 		If TArrayType(expr.exprType) Then
 			Return "bbArraySlice" + Bra(TransArrayType(TArrayType(expr.exprType).elemType) + "," + t_expr + "," + t_args)
+		Else If TStringVarPtrType(expr.exprType) Then
+			Return "bbStringSlice" + Bra("*" + t_expr + "," + t_args)
 		Else
 			Return "bbStringSlice" + Bra(t_expr + "," + t_args)
 		End If
@@ -732,7 +755,7 @@ Type TCTranslator Extends TTranslator
 
 	Method TransAssignStmt$( stmt:TAssignStmt )
 		If Not stmt.rhs Return stmt.lhs.Trans()
-'DebugStop
+
 		Local rhs$=stmt.rhs.Trans()
 		Local lhs$=stmt.lhs.TransVar()
 		
@@ -756,10 +779,10 @@ Type TCTranslator Extends TTranslator
 '			s :+ "BBRELEASE(tmp)~n"
 			
 '			s:+ "}"
+		Else If TStringVarPtrType(stmt.lhs.exprType) Then
+			s :+ "*" + lhs+TransAssignOp( stmt.op )+rhs
 		Else
-		
-				s :+ lhs+TransAssignOp( stmt.op )+rhs
-
+			s :+ lhs+TransAssignOp( stmt.op )+rhs
 		End If
 		
 		Return s
@@ -1666,7 +1689,7 @@ End Rem
 		Emit "}"
 	End Method
 
-	Method TransFieldRef:String(decl:TFieldDecl, variable:String)
+	Method TransFieldRef:String(decl:TFieldDecl, variable:String, exprType:TType = Null)
 		Local s:String = variable
 
 		' array.length
@@ -1679,7 +1702,11 @@ End Rem
 		' string methods
 		If decl.scope And decl.scope.ident = "String" Then
 			If decl.ident = "length" Then
-				Return Bra(variable + "->length")
+				If TStringVarPtrType(exprType) Then
+					Return Bra("(*" + variable + ")->length")
+				Else
+					Return Bra(variable + "->length")
+				End If
 			End If
 		End If
 
@@ -1789,7 +1816,12 @@ End Rem
 		End If
 
 		If TNumericType(expr.exprType) Then
-			Return expr.Eval()
+			Local s:String = expr.Eval()
+			If Not s Then
+				Return "0"
+			Else
+				Return s
+			End If
 		EndIf
 
 		If TStringType(expr.exprType) Then
@@ -2022,30 +2054,32 @@ DebugLog mdecl.munged
 
 		' strings
 		For Local s:String = EachIn app.stringConsts.Keys()
-			Local key:TStringConst = TStringConst(app.stringConsts.ValueForKey(s))
-
-			Emit "static BBString " + key.id + "={"
-			Emit "&bbStringClass,"
-			Emit "2147483647,"
-			Emit s.length + ","
-			
-			Local t:String = "{"
-			
-			For Local i:Int = 0 Until s.length
-				If i Then
-					t:+ ","
-				End If
-				t:+ s[i]
+			If s Then
+				Local key:TStringConst = TStringConst(app.stringConsts.ValueForKey(s))
+	
+				Emit "static BBString " + key.id + "={"
+				Emit "&bbStringClass,"
+				Emit "2147483647,"
+				Emit s.length + ","
 				
-				If i And Not (i Mod 16) Then
-					Emit t
-					t = ""
-				End If
-			Next
-			
-			Emit t + "}"
-			
-			Emit "};"
+				Local t:String = "{"
+				
+				For Local i:Int = 0 Until s.length
+					If i Then
+						t:+ ","
+					End If
+					t:+ s[i]
+					
+					If i And Not (i Mod 16) Then
+						Emit t
+						t = ""
+					End If
+				Next
+				
+				Emit t + "}"
+				
+				Emit "};"
+			End If
 		Next
 		
 		'definitions!
@@ -2086,7 +2120,7 @@ DebugLog mdecl.munged
 		' call any imported mod inits
 		For Local decl:TModuleDecl=EachIn app.imported.Values()
 			For Local mdecl:TDecl=EachIn decl.imported.Values()
-				If TModuleDecl(mdecl) And app.mainModule <> mdecl And mdecl.ident <> "brl.classes" Then
+				If TModuleDecl(mdecl) And app.mainModule <> mdecl And mdecl.ident <> "brl.classes" And mdecl.ident <> "brl.blitzkeywords" Then
 					EmitModuleInit(TModuleDecl(mdecl))
 				End If
 			Next
@@ -2148,10 +2182,17 @@ DebugLog mdecl.munged
 			If mdecl Then
 				If mdecl.IsActualModule() Then
 					Emit "import " + mdecl.ident
+				Else If Not opt_ismain And mdecl.filepath.EndsWith(".bmx") And app.mainModule<>mdecl
+					Emit "import " + Enquote(StripDir(mdecl.filepath))
 				End If
 			End If
 		Next
 		
+		' module imports from other files?
+		If opt_buildtype = BUILDTYPE_MODULE And opt_ismain Then
+			
+		End If
+		
 		' other imports
 		For Local s:String = EachIn app.fileImports
 			Emit "import ~q" + s + "~q"

+ 26 - 10
decl.bmx

@@ -622,9 +622,9 @@ End Rem
 		Return decl
 	End Method
 	
-	Method FindFuncDecl:TFuncDecl( ident$,argExprs:TExpr[] = Null,explicit:Int=False )
+	Method FindFuncDecl:TFuncDecl( ident$,argExprs:TExpr[] = Null,explicit:Int=False, isArg:Int = False )
 'DebugLog "FindFuncDecl : " + ident
-'If ident = "OpenStream" Then DebugStop
+'If ident = "Hook" Then DebugStop
 		'Local funcs:TFuncDeclList=TFuncDeclList( FindDecl( ident ) )
 		Local f:TDecl = TDecl(findDecl(ident))
 		If Not f Then Return Null
@@ -664,6 +664,12 @@ End Rem
 			Local exact:Int=True
 			Local possible:Int=True
 			
+			' we found a matching name - this is probably the one we mean...
+			If isArg Then
+				match=func
+				Exit
+			End If
+			
 			For Local i:Int=0 Until argDecls.Length
 
 				If i<argExprs.Length And argExprs[i]
@@ -1192,7 +1198,7 @@ End Rem
 		Return Super.GetDecl( ident )
 	End Method
 	
-	Method FindFuncDecl:TFuncDecl( ident$,args:TExpr[] = Null ,explicit:Int=False )
+	Method FindFuncDecl:TFuncDecl( ident$,args:TExpr[] = Null ,explicit:Int=False, isArg:Int = False )
 	
 		If args = Null Then
 			args = New TExpr[0]
@@ -1585,6 +1591,8 @@ Type TModuleDecl Extends TScopeDecl
 	Field relpath$
 	Field imported:TMap=New TMap'<TModuleDecl>		'Maps filepath to modules
 	Field pubImported:TMap=New TMap'<TModuleDecl>	'Ditto for publicly imported modules
+
+	Field fileImports:TList=New TList'StringList
 	
 	' cache of ModuleInfo lines
 	Field modInfo:TList = New TList
@@ -1774,22 +1782,30 @@ pushenv Self
 			Local sc:TStringConst = New TStringConst
 			sc.count = 1
 		
-			sc.id = "_s" + stringConstCount
+			If value Then
+				sc.id = "_s" + stringConstCount
+			Else
+				sc.id = "bbEmptyString"
+			End If
 
 			stringConsts.Insert(value, sc)
 
-			stringConstCount:+ 1
+			If value Then
+				stringConstCount:+ 1
+			End If
 		Else
 			sc.count :+ 1
 		End If
 	End Method
 	
 	Method removeStringConst(value:String)
-		Local sc:TStringConst = TStringConst(stringConsts.ValueForKey(value))
-		If sc Then
-			sc.count :- 1
-			If sc.count = 0 Then
-				stringConsts.Remove(value)
+		If value Then
+			Local sc:TStringConst = TStringConst(stringConsts.ValueForKey(value))
+			If sc Then
+				sc.count :- 1
+				If sc.count = 0 Then
+					stringConsts.Remove(value)
+				End If
 			End If
 		End If
 	End Method

+ 211 - 1
expr.bmx

@@ -71,7 +71,12 @@ Type TExpr
 	Method SemantArgs:TExpr[]( args:TExpr[] )
 		args=args[..]
 		For Local i:Int=0 Until args.Length
-			If args[i] args[i]=args[i].Semant()
+			If args[i] Then
+				If TIdentExpr(args[i]) Then
+					TIdentExpr(args[i]).isArg = True
+				End If
+				args[i]=args[i].Semant()
+			End If
 		Next
 		Return args
 	End Method
@@ -725,6 +730,11 @@ Type TCastExpr Extends TExpr
 '			exprType = ty
 '			Return expr
 '		End If
+
+		If TFunctionPtrType(ty) And TInvokeExpr(expr) Then
+			exprType = ty
+			Return expr
+		End If
 		
 		If TIntType(ty) And TPointerType(src) Then
 			exprType = ty
@@ -1254,3 +1264,203 @@ Type TIdentTypeExpr Extends TExpr
 	End	Method
 
 End Type
+
+Type TIdentExpr Extends TExpr
+	Field ident$
+	Field expr:TExpr
+	Field scope:TScopeDecl
+	Field static:Int
+	Field isArg:Int
+
+	Method Create:TIdentExpr( ident$,expr:TExpr=Null )
+		Self.ident=ident
+		Self.expr=expr
+		Return Self
+	End Method
+
+	Method Copy:TExpr()
+		Return New TIdentExpr.Create( ident,CopyExpr(expr) )
+	End Method
+
+	Method ToString$()
+		Local t$="TIdentExpr(~q"+ident+"~q"
+		If expr t:+","+expr.ToString()
+		Return t+")"
+	End Method
+
+	Method _Semant()
+		If scope Return
+
+		If expr Then
+			scope=expr.SemantScope()
+			If scope
+				static=True
+			Else
+				expr=expr.Semant()
+				scope=expr.exprType.GetClass()
+				If Not scope Err "Expression has no scope"
+			End If
+		Else
+			scope=_env
+			static=_env.FuncScope()=Null Or _env.FuncScope().IsStatic()
+		End If
+		
+	End Method
+
+	Method IdentScope:TScopeDecl()
+		If Not expr Return _env
+
+		Local scope:TScopeDecl=expr.SemantScope()
+		If scope
+			expr=Null
+		Else
+			expr=expr.Semant()
+			scope=expr.exprType.GetClass()
+			If Not scope Err "Expression has no scope."
+		EndIf
+		Return scope
+	End Method
+
+	Method IdentErr( )
+		If scope
+			Local close$
+			For Local decl:TDecl=EachIn scope.Decls()
+				If ident.ToLower()=decl.ident.ToLower()
+					close=decl.ident
+				EndIf
+			Next
+			If close And ident<>close Then
+				Err "Identifier '"+ident+"' not found - perhaps you meant '"+close+"'?"
+			EndIf
+		EndIf
+		Err "Identifier '"+ident+"' not found."
+	End Method
+
+	Method IdentNotFound()
+	End Method
+
+	Method IsVar()
+		InternalErr
+	End Method
+
+	Method Semant:TExpr()
+'DebugStop
+		Return SemantSet( "",Null )
+	End Method
+
+	Method SemantSet:TExpr( op$,rhs:TExpr )
+	
+		_Semant
+		
+		'Local scope:TScopeDecl=IdentScope()
+'DebugStop
+		Local vdecl:TValDecl=scope.FindValDecl( ident )
+		If vdecl
+
+			If TConstDecl( vdecl )
+'				If rhs Err "Constant '"+ident+"' cannot be modified."
+'				Return New TConstExpr.Create( vdecl.ty,TConstDecl( vdecl ).value ).Semant()
+				If rhs Err "Constant '"+ident+"' cannot be modified."
+				Local cexpr:TConstExpr =New TConstExpr.Create( vdecl.ty,TConstDecl( vdecl ).value )
+				If Not static And (TInvokeExpr( expr ) Or TInvokeMemberExpr( expr )) Return New TStmtExpr.Create( New TExprStmt.Create( expr ),cexpr ).Semant()
+				Return cexpr.Semant()
+
+			Else If TFieldDecl( vdecl )
+				If static Err "Field '"+ident+"' cannot be accessed from here."
+				If expr Return New TMemberVarExpr.Create( expr,TVarDecl( vdecl ) ).Semant()
+'				If expr Return New TMemberVarExpr.Create( expr,TVarDecl( vdecl ) ).Semant()
+'				If scope<>_env Or Not _env.FuncScope() Or _env.FuncScope().IsStatic() Err "Field '"+ident+"' cannot be accessed from here."
+			EndIf
+
+			Return New TVarExpr.Create( TVarDecl( vdecl ) ).Semant()
+		EndIf
+
+		If op And op<>"="
+
+			Local fdecl:TFuncDecl=scope.FindFuncDecl( ident )
+			If Not fdecl IdentErr
+
+			If _env.ModuleScope().IsStrict() And Not fdecl.IsProperty() Err "Identifier '"+ident+"' cannot be used in this way."
+
+			Local lhs:TExpr
+
+			If fdecl.IsStatic() Or (scope=_env And Not _env.FuncScope().IsStatic())
+				lhs=New TInvokeExpr.Create( fdecl )
+			Else If expr
+				Local tmp:TLocalDecl=New TLocalDecl.Create( "",Null,expr )
+				lhs=New TInvokeMemberExpr.Create( New TVarExpr.Create( tmp ),fdecl )
+				lhs=New TStmtExpr.Create( New TDeclStmt.Create( tmp ),lhs )
+			Else
+				Return Null
+			EndIf
+
+			Local bop$=op[..1]
+			Select bop
+			Case "*","/","shl","shr","+","-","&","|","~~"
+				rhs=New TBinaryMathExpr.Create( bop,lhs,rhs )
+			Default
+				InternalErr
+			End Select
+			rhs=rhs.Semant()
+		EndIf
+
+		Local args:TExpr[]
+		If rhs args=[rhs]
+
+		Local fdecl:TFuncDecl=scope.FindFuncDecl( ident,args, , isArg )
+		
+		If fdecl
+			If _env.ModuleScope().IsStrict() And Not fdecl.IsProperty() And Not isArg Err "Identifier '"+ident+"' cannot be used in this way."
+	
+			If Not fdecl.IsStatic()
+				If expr Return New TInvokeMemberExpr.Create( expr,fdecl,args ).Semant()
+				If scope<>_env Or Not _env.FuncScope() Or _env.FuncScope().IsStatic() Err "Method '"+ident+"' cannot be accessed from here."
+			EndIf
+	
+			Return New TInvokeExpr.Create( fdecl,args ).Semant()
+		End If
+		
+		IdentErr
+	End Method
+
+	Method SemantFunc:TExpr( args:TExpr[] )
+
+		_Semant
+
+		'Local scope:TScopeDecl=IdentScope()
+		Local fdecl:TFuncDecl=scope.FindFuncDecl( ident,args )
+
+		If fdecl
+			If Not fdecl.IsStatic()
+				If static Err "Method '"+ident+"' cannot be accessed from here."
+				If expr Return New TInvokeMemberExpr.Create( expr,fdecl,args ).Semant()
+				'If scope<>_env Or _env.FuncScope().IsStatic() Err "Method '"+ident+"' cannot be accessed from here."
+			EndIf
+			Return New TInvokeExpr.Create( fdecl,args ).Semant()
+		EndIf
+
+		'If args.Length=1 And args[0] And TObjectType( args[0].exprType )
+		'	Local cdecl:TClassDecl=TClassDecl( scope.FindScopeDecl( ident ) )
+		'	If cdecl Return args[0].Cast( New TObjectType.Create(cdecl),CAST_EXPLICIT )
+		'EndIf
+
+		Local ty:TType=scope.FindType( ident,Null )
+		If ty Then
+			If args.Length=1 And args[0] Return args[0].Cast( ty,CAST_EXPLICIT )
+			Err "Illegal number of arguments for type conversion"
+		End If
+
+		IdentErr
+	End Method
+
+	Method SemantScope:TScopeDecl()
+		If Not expr Return _env.FindScopeDecl( ident )
+		Local scope:TScopeDecl=expr.SemantScope()
+		If scope Return scope.FindScopeDecl( ident )
+	End Method
+
+'	Method Trans$()
+'		Return _trans.TransIdentExpr( Self )
+'	End Method
+
+End Type

+ 53 - 16
iparser.bmx

@@ -126,27 +126,64 @@ DebugLog "FILE NOT FOUND : " + ipath
 				
 				' skip non-module imports
 				If toker.TokeType()=TOKE_STRINGLIT
-					Continue
-				End If
-				
 
-				Local m:String = toker._toke
-				toker.NextToke()
-				
-				Parse(".")
+					Local iRelPath:String = ParseStringLit()
+					
+					If iRelPath.EndsWith(".bmx") Then
+							
+						Local origPath:String = RealPath(ExtractDir(path) + "/" + iRelPath)
+						Local iPath:String = OutputFilePath(origPath, FileMung(), "i")
 				
-				m :+ "." + toker._toke
+						If FileType( iPath )<>FILETYPE_FILE
+							Err "File '"+ iPath +"' not found."
+						EndIf
+	
+	
+						If _mod.imported.Contains( iPath ) Continue
 				
-				Local mdecl:TDecl=TDecl(pmod.GetDecl( m ))
-'DebugStop
+						Local modpath:String
+						If opt_buildtype = BUILDTYPE_MODULE Then
+							modpath = opt_modulename + "_" + StripExt(iRelPath)
+							modpath = modpath.ToLower().Replace(".", "_")
+						Else
+							' todo file imports for apps
+							internalErr
+						End If
+
 
-				If Not mdecl
-					Local path:String = modulepath(m)
-					' parse the imported module
-					New TIParser.ParseModuleImport( _mod, m, path )
+'					Local mdecl:TDecl=TDecl(pmod.GetDecl( modpath ))
+	
+'					If Not mdecl
+						New TIParser.ParseModuleImport( _mod, modpath, origPath, iPath, , , iRelPath)
+'					Else
+'						_mod.imported.Insert(modpath, mdecl)
+'					EndIf
+					Else
+DebugStop
+						Local p:String = ParseStringLit()
+						_mod.fileImports.AddLast(p)
+					End If
 				Else
-					_mod.imported.Insert(m, mdecl)
-				EndIf
+				
+
+					Local m:String = toker._toke
+					toker.NextToke()
+					
+					Parse(".")
+					
+					m :+ "." + toker._toke
+					
+					Local mdecl:TDecl=TDecl(pmod.GetDecl( m ))
+	
+					If Not mdecl
+						Local path:String = modulepath(m)
+						' parse the imported module
+						New TIParser.ParseModuleImport( _mod, m, path )
+					Else
+						_mod.imported.Insert(m, mdecl)
+					EndIf
+
+				End If
 				
 				Continue
 				

+ 1 - 199
parser.bmx

@@ -120,204 +120,6 @@ Type TForEachinStmt Extends TStmt
 End Type
 
 
-Type TIdentExpr Extends TExpr
-	Field ident$
-	Field expr:TExpr
-	Field scope:TScopeDecl
-	Field static:Int
-
-	Method Create:TIdentExpr( ident$,expr:TExpr=Null )
-		Self.ident=ident
-		Self.expr=expr
-		Return Self
-	End Method
-
-	Method Copy:TExpr()
-		Return New TIdentExpr.Create( ident,CopyExpr(expr) )
-	End Method
-
-	Method ToString$()
-		Local t$="TIdentExpr(~q"+ident+"~q"
-		If expr t:+","+expr.ToString()
-		Return t+")"
-	End Method
-
-	Method _Semant()
-		If scope Return
-
-		If expr Then
-			scope=expr.SemantScope()
-			If scope
-				static=True
-			Else
-				expr=expr.Semant()
-				scope=expr.exprType.GetClass()
-				If Not scope Err "Expression has no scope"
-			End If
-		Else
-			scope=_env
-			static=_env.FuncScope()=Null Or _env.FuncScope().IsStatic()
-		End If
-		
-	End Method
-
-	Method IdentScope:TScopeDecl()
-		If Not expr Return _env
-
-		Local scope:TScopeDecl=expr.SemantScope()
-		If scope
-			expr=Null
-		Else
-			expr=expr.Semant()
-			scope=expr.exprType.GetClass()
-			If Not scope Err "Expression has no scope."
-		EndIf
-		Return scope
-	End Method
-
-	Method IdentErr( )
-		If scope
-			Local close$
-			For Local decl:TDecl=EachIn scope.Decls()
-				If ident.ToLower()=decl.ident.ToLower()
-					close=decl.ident
-				EndIf
-			Next
-			If close And ident<>close Then
-				Err "Identifier '"+ident+"' not found - perhaps you meant '"+close+"'?"
-			EndIf
-		EndIf
-		Err "Identifier '"+ident+"' not found."
-	End Method
-
-	Method IdentNotFound()
-	End Method
-
-	Method IsVar()
-		InternalErr
-	End Method
-
-	Method Semant:TExpr()
-'DebugStop
-		Return SemantSet( "",Null )
-	End Method
-
-	Method SemantSet:TExpr( op$,rhs:TExpr )
-	
-		_Semant
-		
-		'Local scope:TScopeDecl=IdentScope()
-'DebugStop
-		Local vdecl:TValDecl=scope.FindValDecl( ident )
-		If vdecl
-
-			If TConstDecl( vdecl )
-'				If rhs Err "Constant '"+ident+"' cannot be modified."
-'				Return New TConstExpr.Create( vdecl.ty,TConstDecl( vdecl ).value ).Semant()
-				If rhs Err "Constant '"+ident+"' cannot be modified."
-				Local cexpr:TConstExpr =New TConstExpr.Create( vdecl.ty,TConstDecl( vdecl ).value )
-				If Not static And (TInvokeExpr( expr ) Or TInvokeMemberExpr( expr )) Return New TStmtExpr.Create( New TExprStmt.Create( expr ),cexpr ).Semant()
-				Return cexpr.Semant()
-
-			Else If TFieldDecl( vdecl )
-				If static Err "Field '"+ident+"' cannot be accessed from here."
-				If expr Return New TMemberVarExpr.Create( expr,TVarDecl( vdecl ) ).Semant()
-'				If expr Return New TMemberVarExpr.Create( expr,TVarDecl( vdecl ) ).Semant()
-'				If scope<>_env Or Not _env.FuncScope() Or _env.FuncScope().IsStatic() Err "Field '"+ident+"' cannot be accessed from here."
-			EndIf
-
-			Return New TVarExpr.Create( TVarDecl( vdecl ) ).Semant()
-		EndIf
-
-		If op And op<>"="
-
-			Local fdecl:TFuncDecl=scope.FindFuncDecl( ident )
-			If Not fdecl IdentErr
-
-			If _env.ModuleScope().IsStrict() And Not fdecl.IsProperty() Err "Identifier '"+ident+"' cannot be used in this way."
-
-			Local lhs:TExpr
-
-			If fdecl.IsStatic() Or (scope=_env And Not _env.FuncScope().IsStatic())
-				lhs=New TInvokeExpr.Create( fdecl )
-			Else If expr
-				Local tmp:TLocalDecl=New TLocalDecl.Create( "",Null,expr )
-				lhs=New TInvokeMemberExpr.Create( New TVarExpr.Create( tmp ),fdecl )
-				lhs=New TStmtExpr.Create( New TDeclStmt.Create( tmp ),lhs )
-			Else
-				Return Null
-			EndIf
-
-			Local bop$=op[..1]
-			Select bop
-			Case "*","/","shl","shr","+","-","&","|","~~"
-				rhs=New TBinaryMathExpr.Create( bop,lhs,rhs )
-			Default
-				InternalErr
-			End Select
-			rhs=rhs.Semant()
-		EndIf
-
-		Local args:TExpr[]
-		If rhs args=[rhs]
-
-		Local fdecl:TFuncDecl=scope.FindFuncDecl( ident,args )
-		
-		If fdecl
-			If _env.ModuleScope().IsStrict() And Not fdecl.IsProperty() Err "Identifier '"+ident+"' cannot be used in this way."
-	
-			If Not fdecl.IsStatic()
-				If expr Return New TInvokeMemberExpr.Create( expr,fdecl,args ).Semant()
-				If scope<>_env Or Not _env.FuncScope() Or _env.FuncScope().IsStatic() Err "Method '"+ident+"' cannot be accessed from here."
-			EndIf
-	
-			Return New TInvokeExpr.Create( fdecl,args ).Semant()
-		End If
-		
-		IdentErr
-	End Method
-
-	Method SemantFunc:TExpr( args:TExpr[] )
-
-		_Semant
-
-		'Local scope:TScopeDecl=IdentScope()
-		Local fdecl:TFuncDecl=scope.FindFuncDecl( ident,args )
-
-		If fdecl
-			If Not fdecl.IsStatic()
-				If static Err "Method '"+ident+"' cannot be accessed from here."
-				If expr Return New TInvokeMemberExpr.Create( expr,fdecl,args ).Semant()
-				'If scope<>_env Or _env.FuncScope().IsStatic() Err "Method '"+ident+"' cannot be accessed from here."
-			EndIf
-			Return New TInvokeExpr.Create( fdecl,args ).Semant()
-		EndIf
-
-		'If args.Length=1 And args[0] And TObjectType( args[0].exprType )
-		'	Local cdecl:TClassDecl=TClassDecl( scope.FindScopeDecl( ident ) )
-		'	If cdecl Return args[0].Cast( New TObjectType.Create(cdecl),CAST_EXPLICIT )
-		'EndIf
-
-		Local ty:TType=scope.FindType( ident,Null )
-		If ty Then
-			If args.Length=1 And args[0] Return args[0].Cast( ty,CAST_EXPLICIT )
-			Err "Illegal number of arguments for type conversion"
-		End If
-
-		IdentErr
-	End Method
-
-	Method SemantScope:TScopeDecl()
-		If Not expr Return _env.FindScopeDecl( ident )
-		Local scope:TScopeDecl=expr.SemantScope()
-		If scope Return scope.FindScopeDecl( ident )
-	End Method
-
-'	Method Trans$()
-'		Return _trans.TransIdentExpr( Self )
-'	End Method
-
-End Type
 
 Type TFuncCallExpr Extends TExpr
 	Field expr:TExpr
@@ -2348,7 +2150,7 @@ End Rem
 		If opt_buildtype = BUILDTYPE_MODULE And opt_modulename = "brl.blitz" Then
 			' import Object and String definitions
 			Local par:TIParser = New TIParser
-			par.ParseModuleImport(_module, "brl.classes", modulepath("brl.blitz"), "blitz_classes.i")
+			par.ParseModuleImport(_module, "brl.classes", modulepath("brl.blitz"), modulepath("brl.blitz") + "\blitz_classes.i")
 	
 			' set up built-in keywords
 			par = New TIParser

+ 1 - 0
translator.bmx

@@ -135,6 +135,7 @@ Type TTranslator
 			Until Not mungScope.Contains( t )
 			munged=t
 		EndIf
+
 		mungScope.Insert munged,decl
 		decl.munged=munged