Commits

kevinclancy  committed 0eaa4ae

added some comments

  • Participants
  • Parent commits 4cbf4d8

Comments (0)

Files changed (6)

File LoveStudio/DebugProxy.cs

             }
           }
 
-          if (_state == State.RUNNING)
+          if (_state == State.RUNNING || _state == State.STEPPING_OVER || _state == State.STEPPING_IN)
           {
             BeginDebuggerReceive();
           }

File LoveStudio/LuaAnalyzer/LuaAnalyzer.fs

                 yield fileName,modName,fileContents,timeStamp
     }   
     
-    let errors,_,_ = (LuaAnalyzer.ProjectChecker.typeCheckProject modules' typeCheck)
+    let errors = (LuaAnalyzer.ProjectChecker.typeCheckProject modules' typeCheck)
     errors
 
 let isFileCollectedBy (modName : string) (fileName : string) (typeCollectorName : string) =

File LoveStudio/LuaAnalyzer/ProjectChecker.fs

 ///
 /// astMap - Maps each module to a typed ast for that module's code
 ///
-/// Iterates through each module mentioned in the subtype graph contained in env,
+/// Iterates through each module mentioned in the subtype graph contained in tenv,
 /// collecting an instance and a constructor type from each one, accumulating these
 /// types into the consMap and typeMap fields of the environment.
 let buildExternalTypes (tenv : TypeEnvironment) 
 /// name/field pairs of all globals which are assigned in this module,
 /// adding them to ctxt, replacing any existing entries with identical names.
 /// Returns the resulting context.
-let buildBaseCtxt (ctxt : Context) (modules : seq<string*string*TypedStatement*int64>) (globalsModName : string) =
+let buildGlobalCtxt (ctxt : Context) (modules : seq<string*string*TypedStatement*int64>) (globalsModName : string) =
     
     Contract.Ensures(ctxt.tenv.typeMap.Count = Contract.OldValue(ctxt.tenv.typeMap.Count))
     Contract.Ensures(ctxt.venv.Count >= Contract.OldValue(ctxt.venv.Count))
 /// for the contents.
 let astCache = ref (new Map<string, int64*TypedStatement>([]))
 
+/// Gets an ast for the given module. If 
 let getAST ((fileName,modName,modContents,lastMod) : string*string*string*int64) =
     let ast =
         if (!astCache).ContainsKey fileName then
     
     (fileName,modName,ast,lastMod), (modName,ast) 
 
-let runTypeCollectors (modules : seq<string*string*string*int64>) (targetFile : Option<string>) (queryPos : Option<int>) : Option<TypeEnvironment> =
+/// modules - a sequence of all modules in the project
+///
+/// targetFile - None signifies that the entire project should be typechecked. 
+/// Otherwise, we only check the specified file (but still collect from the entire project)
+///
+/// queryPos - If targetFile is used, we may be checking it so that information about some
+/// word in the program can be retrieved. If so, the some position in the word is used as this argument.
+///
+/// Runs the typechecker--either for generating type checking errors or querying information
+/// about the program. Note that this function performs everything needed for typechecking, 
+/// including type collection.
+let runTypeCollectors (modules : seq<LuaModule>) (targetFile : Option<string>) (queryPos : Option<int>) : Option<TypeEnvironment> =
+
+    Contract.Requires(targetFile.IsSome || (not queryPos.IsSome))
 
     let mapped = (Seq.map getAST modules)
     let modules = Seq.map fst mapped
                 tenv = tenv
             }
 
-        let baseCtxt = buildBaseCtxt preGlobalsCtxt modules "globals"
-        let baseCtxt = buildInternalTypes baseCtxt collectorMap astMap
-        baseCtxt.tenv.CheckStructuralSubtyping()
+        let ctxt = buildGlobalCtxt preGlobalsCtxt modules "globals"
+        let ctxt = buildInternalTypes ctxt collectorMap astMap
+        ctxt.tenv.CheckStructuralSubtyping()
         
         let modules = 
             if targetFile.IsSome then
             else
                 modules
         
-        let baseCtxt = { baseCtxt with queryPos = queryPos }
-        runTypeChecker collectorMap preGlobalsCtxt baseCtxt modules
+        let ctxt = { ctxt with queryPos = queryPos }
+        runTypeChecker collectorMap preGlobalsCtxt ctxt modules
 
         Some tenv
     with
         System.Console.WriteLine("collection error: " + msg)
         failwith msg
 
-let typeCheckProject (modules : seq<string*string*string*int64>) (typeCheck : bool) : GenList<string*string*Range>*Option<TypeEnvironment>*Context =
+/// modules - sequence of all lua modules in the project
+/// typeCheck - whether or not to generate type errors
+///
+/// Generates a list of errors in the project. If typeCheck is true, it generates syntax
+/// errors and type errors. If typeCheck is false, it generates syntax errors only.
+let typeCheckProject (modules : seq<LuaModule>) (typeCheck : bool) : GenList<string*string*Range> =
     errors.Clear()
     let env =
         if typeCheck then
             Seq.iter (getAST >> ignore) modules
             None
 
-    errors, env, !refStubContext
+    errors
 
-let queryDesc (modules : seq<string*string*string*int64>) (targetFile : string) (queryPos : int) =
+/// modules - a sequence of all modules in the project
+/// targetFile - the full path name of the file to query from
+/// queryPos - the position (char index) in the target file which we are querying
+///
+/// Retrieves a description (and definition location) of the program element containing 
+/// the specified position in the specified file. This description is generated from the 
+/// element's type and/or field when possible.
+///
+/// Returns a (identifier description, definition location, type description) triple.
+/// When any of the aforementioned items cannot be obtained, it returns "",NoLocation, and ""
+/// respectively.  
+let queryDescAndLoc (modules : seq<LuaModule>) (targetFile : string) (queryPos : int) =
     refStubDesc := ""
     refStubDefLoc := NoLocation
     refStubTy := UnknownTy
 
     !refStubDesc,!refStubDefLoc,(!refStubTy).ToStringElaborate()
 
-let getStubContextInProject (modules : seq<string*string*string*int64>) (targetFile : string) =
+/// modules - a sequence of all lua modules in the project
+/// targetFile - the full path of the lua file containing the context 
+/// stub (a call to lucbdnioua) to extract from.
+///
+/// Given a project and a file within that project, typechecks the specified
+/// file, recording the context when the typechecker reach a call to "lucbdnioua",
+/// It is assumed that exactly one call to lucbdnioua exists in the file.
+let getStubContextInProject (modules : seq<LuaModule>) (targetFile : string) =
     let env = runTypeCollectors modules (Some(targetFile)) None
     env,!refStubContext
     

File LoveStudio/LuaAnalyzer/ProjectChecker.fsi

 
 type GenList<'T> = System.Collections.Generic.List<'T>
 
-/// typeCheckProject project typecheck - where project is the sequence of all 
-/// fileName,moduleName,fileContents,timeStamp quadruples in the project we wish to check.
-///
-/// If typecheck is true, we do a full typecheck. Otherwise, we only detect parse errors. 
-///
-/// Typechecks the specified project, returning a list of all errors encountered,
-/// an optional type environment containing the final result of type collection
-/// (or None if any type collection errors were encountered), and the context
-/// extracted at the position of a specially planted stub (a call to a function
-/// called lucbdnioua).
-val typeCheckProject : seq<string*string*string*int64> -> bool -> GenList<string*string*Range>*Option<TypeEnvironment>*Context
+val typeCheckProject : seq<string*string*string*int64> -> bool -> GenList<string*string*Range>
 
-val queryDesc : seq<string*string*string*int64> -> string -> int -> string*DefinitionLocation*string
+val queryDescAndLoc : seq<string*string*string*int64> -> string -> int -> string*DefinitionLocation*string
 
 val getStubContextInProject : seq<string*string*string*int64> -> string -> Option<TypeEnvironment>*Context
 

File LoveStudio/LuaAnalyzer/SubtypeGraphBuilder.fs

 open TypedSyntax
 open TypeCollector
 
+/// The data we need to track during the construction of the
+/// subtype graph.
 type TypeGraphBuilderState = {
 
+    /// the type environment containing the graph we are building
     tenv : TypeEnvironment
     
+    /// all type names collected so far
     allTypeNames : Set<string>
 
     //TODO: perhaps this should be included in type environment
     //except that would have to map module names to type collector names
+    /// maps module names to the collectors which collected them
     collectedFrom : Map<string,TypeCollector>
 }
 
     for typeName in state.allTypeNames do
         checkStructureErrors state.tenv state.collectedFrom typeName
 
+/// modules - a sequence of (filename,modulename,ast,timestamp) quadruples
+/// for all modules in the project
 ///
+/// tyenv0 - The type environment after having read in all API data from XML files
 ///
+/// typeNames0 - The names of all types read from API definitions in XML files
+///
+/// Starting with the subtypegraph in tenv0, accumulates a subject graph computed
+/// from the lua project whose modules are all included in the modules sequence.
+/// Returns the resulting type environment, along with a map which record which
+/// modules were collected by which type collectors.
 let buildSubtypeGraph (modules : seq<string*string*TypedStatement*int64>) 
                       (tenv0 : TypeEnvironment) 
                       (typeNames0 : Set<string>)

File LoveStudio/LuaAnalyzer/Utils.fs

 [<AutoOpen>]
 module LuaAnalyzer.Utils
+
 open System.Diagnostics.Contracts
 
 type Range = int*int
 
+/// (fullPathName,moduleName,contents,lastModifiedTime)
+type LuaModule = string*string*string*int64
+
 /// Returns a string describing the order of the given integer
 let orderStr (i : int) =
     let iStr = i.ToString()