Skip to content

Commit

Permalink
Added a high-level comment to each module
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Feb 20, 2024
1 parent 71bc411 commit d8607ce
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/analysis/typepal/AType.rsc
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module analysis::typepal::AType

/*
Foundation of ATypes, to be extended for different type systems
*/

import List;

extend analysis::typepal::GetLoc;
extend analysis::typepal::TModel;

// Foundation of ATypes, will be extended for different type systems

data AType
= tvar(loc tname) // type variable, used for type inference
| lazyLub(list[AType] atypes) // lazily computed LUB of a list of types
Expand Down
5 changes: 4 additions & 1 deletion src/analysis/typepal/Collector.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Redistribution and use in source and binary forms, with or without modification,
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}
module analysis::typepal::Collector

/*
Implementation of the ICollector interface; this is the API of TypePal's fact and constraint collector
*/

import Node;
import Map;
Expand Down Expand Up @@ -133,7 +137,6 @@ void print(reqUnify(str rname, value l, value r, list[loc] dependsOn, FailMessag
if(full) printDeps(dependsOn, indent, facts);
}
void print(reqError (loc src, list[loc] dependsOn, FailMessage fm), str indent, map[loc,AType] facts, bool full=true){
println("<indent>requ for <src>");
if(full) printDeps(dependsOn, indent, facts);
Expand Down
14 changes: 6 additions & 8 deletions src/analysis/typepal/ConfigurableScopeGraph.rsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module analysis::typepal::ConfigurableScopeGraph

/*
A ScopeGraph is the basis for TypePal's operations. It acts as a lookup function for names.
It is highly parameterized to reflect properties of different type systems and name binding mechanisms.
ScopeGraphs are inspired by Kastens & Waite, Name analysis for modern languages: a general solution, SP&E, 2017
*/
extend analysis::typepal::Exception;
extend analysis::typepal::ISolver;

Expand Down Expand Up @@ -132,12 +138,6 @@ data TypePalConfig(

loc (str id, IdRole idRole, loc physicalLoc, str modelName, PathConfig pcfg) createLogicalLoc = defaultLogicalLoc
);


// ScopeGraphs inspired by Kastens & Waite, Name analysis for modern languages: a general solution, SP&E, 2017


//data Tree; // workaround for bug in interpreter


// Language-specific acceptance in case of multiple outcomes of a lookup
Expand Down Expand Up @@ -444,8 +444,6 @@ ScopeGraph newScopeGraph(TModel tm, TypePalConfig config){
return res;
}



public set[loc] lookupWide(Use u){

// Update current paths and pathRoles
Expand Down
6 changes: 4 additions & 2 deletions src/analysis/typepal/Exception.rsc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module analysis::typepal::Exception

extend analysis::typepal::FailMessage;
/*
Exceptions that are used by TypePal
*/

// --- Exceptions
extend analysis::typepal::FailMessage;

data RuntimeException
= TypePalUsage(str reason) // TypePal used incorrectly
Expand Down
4 changes: 4 additions & 0 deletions src/analysis/typepal/FailMessage.rsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module analysis::typepal::FailMessage

/*
FailMessages provide a convenient variation on Rascal's standard Message datatype.
In the end, FailMessages are reduced to standard Messages.
*/
import Message;
import String;

Expand Down
3 changes: 3 additions & 0 deletions src/analysis/typepal/GetLoc.rsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module analysis::typepal::GetLoc

/*
Convenience functions to get the location of a Tree
*/
import List;
import ParseTree;
import IO;
Expand Down
6 changes: 4 additions & 2 deletions src/analysis/typepal/ICollector.rsc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module analysis::typepal::ICollector

extend analysis::typepal::ConfigurableScopeGraph;
/*
Declaration of the ICollector interface; this is the API of TypePal's fact and constraint collector
*/

// The API of TypePal's fact and constraint collector
extend analysis::typepal::ConfigurableScopeGraph;

data Collector
= collector(
Expand Down
6 changes: 4 additions & 2 deletions src/analysis/typepal/ISolver.rsc
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module analysis::typepal::ISolver

/*
Declaration of the ISolver interface; this is the API of TypePal's constraint solver
*/

extend analysis::typepal::AType;
extend analysis::typepal::FailMessage;
import ParseTree;

// The API of TypePal's constraint solver

data Solver
= solver(
/* Lifecycle */ TModel () run,
Expand Down
3 changes: 3 additions & 0 deletions src/analysis/typepal/Messenger.rsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module analysis::typepal::Messenger

/*
Utilities for formatting Messages
*/
import ParseTree;
import Message;
import Exception;
Expand Down
3 changes: 3 additions & 0 deletions src/analysis/typepal/Solver.rsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module analysis::typepal::Solver

/*
Implementation of the ISolver interface; this is the API of TypePal's constraint solver
*/
import Set;
import Node;
import Map;
Expand Down
5 changes: 4 additions & 1 deletion src/analysis/typepal/TModel.rsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module analysis::typepal::TModel

/*
A TModel (for Type Model) is the basic data structure to represent type information.
It can be extended to suit the needs of a specific type checker.
*/
import String;
import Message;
import List;
Expand Down Expand Up @@ -98,7 +102,6 @@ data TModel (
map[str,value] store = (),
map[loc, Define] definitions = (),
map[loc,loc] logical2physical = (),
//rel[loc,loc] logical2physical = {},
TypePalConfig config = tconfig()
) = tmodel();

Expand Down
5 changes: 5 additions & 0 deletions src/analysis/typepal/TypePal.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Redistribution and use in source and binary forms, with or without modification,
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}
module analysis::typepal::TypePal

/*
Top level module that provides all TypePal functionality to its clients
and also declares some convenience functions.
*/

import ParseTree;
import Message;
Expand Down

0 comments on commit d8607ce

Please sign in to comment.