mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
Merge branch 'master' into evaluate-to-values
This commit is contained in:
commit
35fd93be1c
@ -216,33 +216,33 @@ message FloorDivision {
|
||||
}
|
||||
|
||||
message BOr {
|
||||
GoDiff left = 1;
|
||||
GoDiff right = 2;
|
||||
GoDiff lhs = 1;
|
||||
GoDiff rhs = 2;
|
||||
}
|
||||
|
||||
message BAnd {
|
||||
GoDiff left = 1;
|
||||
GoDiff right = 2;
|
||||
GoDiff lhs = 1;
|
||||
GoDiff rhs = 2;
|
||||
}
|
||||
|
||||
message BXOr {
|
||||
GoDiff left = 1;
|
||||
GoDiff right = 2;
|
||||
GoDiff lhs = 1;
|
||||
GoDiff rhs = 2;
|
||||
}
|
||||
|
||||
message LShift {
|
||||
GoDiff left = 1;
|
||||
GoDiff right = 2;
|
||||
GoDiff lhs = 1;
|
||||
GoDiff rhs = 2;
|
||||
}
|
||||
|
||||
message RShift {
|
||||
GoDiff left = 1;
|
||||
GoDiff right = 2;
|
||||
GoDiff lhs = 1;
|
||||
GoDiff rhs = 2;
|
||||
}
|
||||
|
||||
message UnsignedRShift {
|
||||
GoDiff left = 1;
|
||||
GoDiff right = 2;
|
||||
GoDiff lhs = 1;
|
||||
GoDiff rhs = 2;
|
||||
}
|
||||
|
||||
message Complement {
|
||||
|
@ -198,33 +198,33 @@ message FloorDivision {
|
||||
}
|
||||
|
||||
message BOr {
|
||||
GoTerm left = 1;
|
||||
GoTerm right = 2;
|
||||
GoTerm lhs = 1;
|
||||
GoTerm rhs = 2;
|
||||
}
|
||||
|
||||
message BAnd {
|
||||
GoTerm left = 1;
|
||||
GoTerm right = 2;
|
||||
GoTerm lhs = 1;
|
||||
GoTerm rhs = 2;
|
||||
}
|
||||
|
||||
message BXOr {
|
||||
GoTerm left = 1;
|
||||
GoTerm right = 2;
|
||||
GoTerm lhs = 1;
|
||||
GoTerm rhs = 2;
|
||||
}
|
||||
|
||||
message LShift {
|
||||
GoTerm left = 1;
|
||||
GoTerm right = 2;
|
||||
GoTerm lhs = 1;
|
||||
GoTerm rhs = 2;
|
||||
}
|
||||
|
||||
message RShift {
|
||||
GoTerm left = 1;
|
||||
GoTerm right = 2;
|
||||
GoTerm lhs = 1;
|
||||
GoTerm rhs = 2;
|
||||
}
|
||||
|
||||
message UnsignedRShift {
|
||||
GoTerm left = 1;
|
||||
GoTerm right = 2;
|
||||
GoTerm lhs = 1;
|
||||
GoTerm rhs = 2;
|
||||
}
|
||||
|
||||
message Complement {
|
||||
|
@ -256,33 +256,33 @@ message Comparison {
|
||||
}
|
||||
|
||||
message BOr {
|
||||
JavaDiff left = 1;
|
||||
JavaDiff right = 2;
|
||||
JavaDiff lhs = 1;
|
||||
JavaDiff rhs = 2;
|
||||
}
|
||||
|
||||
message BXOr {
|
||||
JavaDiff left = 1;
|
||||
JavaDiff right = 2;
|
||||
JavaDiff lhs = 1;
|
||||
JavaDiff rhs = 2;
|
||||
}
|
||||
|
||||
message BAnd {
|
||||
JavaDiff left = 1;
|
||||
JavaDiff right = 2;
|
||||
JavaDiff lhs = 1;
|
||||
JavaDiff rhs = 2;
|
||||
}
|
||||
|
||||
message LShift {
|
||||
JavaDiff left = 1;
|
||||
JavaDiff right = 2;
|
||||
JavaDiff lhs = 1;
|
||||
JavaDiff rhs = 2;
|
||||
}
|
||||
|
||||
message RShift {
|
||||
JavaDiff left = 1;
|
||||
JavaDiff right = 2;
|
||||
JavaDiff lhs = 1;
|
||||
JavaDiff rhs = 2;
|
||||
}
|
||||
|
||||
message UnsignedRShift {
|
||||
JavaDiff left = 1;
|
||||
JavaDiff right = 2;
|
||||
JavaDiff lhs = 1;
|
||||
JavaDiff rhs = 2;
|
||||
}
|
||||
|
||||
message Complement {
|
||||
|
@ -238,33 +238,33 @@ message Comparison {
|
||||
}
|
||||
|
||||
message BOr {
|
||||
JavaTerm left = 1;
|
||||
JavaTerm right = 2;
|
||||
JavaTerm lhs = 1;
|
||||
JavaTerm rhs = 2;
|
||||
}
|
||||
|
||||
message BXOr {
|
||||
JavaTerm left = 1;
|
||||
JavaTerm right = 2;
|
||||
JavaTerm lhs = 1;
|
||||
JavaTerm rhs = 2;
|
||||
}
|
||||
|
||||
message BAnd {
|
||||
JavaTerm left = 1;
|
||||
JavaTerm right = 2;
|
||||
JavaTerm lhs = 1;
|
||||
JavaTerm rhs = 2;
|
||||
}
|
||||
|
||||
message LShift {
|
||||
JavaTerm left = 1;
|
||||
JavaTerm right = 2;
|
||||
JavaTerm lhs = 1;
|
||||
JavaTerm rhs = 2;
|
||||
}
|
||||
|
||||
message RShift {
|
||||
JavaTerm left = 1;
|
||||
JavaTerm right = 2;
|
||||
JavaTerm lhs = 1;
|
||||
JavaTerm rhs = 2;
|
||||
}
|
||||
|
||||
message UnsignedRShift {
|
||||
JavaTerm left = 1;
|
||||
JavaTerm right = 2;
|
||||
JavaTerm lhs = 1;
|
||||
JavaTerm rhs = 2;
|
||||
}
|
||||
|
||||
message Complement {
|
||||
|
@ -227,28 +227,28 @@ message FloorDivision {
|
||||
}
|
||||
|
||||
message BAnd {
|
||||
PHPDiff left = 1;
|
||||
PHPDiff right = 2;
|
||||
PHPDiff lhs = 1;
|
||||
PHPDiff rhs = 2;
|
||||
}
|
||||
|
||||
message BOr {
|
||||
PHPDiff left = 1;
|
||||
PHPDiff right = 2;
|
||||
PHPDiff lhs = 1;
|
||||
PHPDiff rhs = 2;
|
||||
}
|
||||
|
||||
message BXOr {
|
||||
PHPDiff left = 1;
|
||||
PHPDiff right = 2;
|
||||
PHPDiff lhs = 1;
|
||||
PHPDiff rhs = 2;
|
||||
}
|
||||
|
||||
message LShift {
|
||||
PHPDiff left = 1;
|
||||
PHPDiff right = 2;
|
||||
PHPDiff lhs = 1;
|
||||
PHPDiff rhs = 2;
|
||||
}
|
||||
|
||||
message RShift {
|
||||
PHPDiff left = 1;
|
||||
PHPDiff right = 2;
|
||||
PHPDiff lhs = 1;
|
||||
PHPDiff rhs = 2;
|
||||
}
|
||||
|
||||
message And {
|
||||
|
@ -209,28 +209,28 @@ message FloorDivision {
|
||||
}
|
||||
|
||||
message BAnd {
|
||||
PHPTerm left = 1;
|
||||
PHPTerm right = 2;
|
||||
PHPTerm lhs = 1;
|
||||
PHPTerm rhs = 2;
|
||||
}
|
||||
|
||||
message BOr {
|
||||
PHPTerm left = 1;
|
||||
PHPTerm right = 2;
|
||||
PHPTerm lhs = 1;
|
||||
PHPTerm rhs = 2;
|
||||
}
|
||||
|
||||
message BXOr {
|
||||
PHPTerm left = 1;
|
||||
PHPTerm right = 2;
|
||||
PHPTerm lhs = 1;
|
||||
PHPTerm rhs = 2;
|
||||
}
|
||||
|
||||
message LShift {
|
||||
PHPTerm left = 1;
|
||||
PHPTerm right = 2;
|
||||
PHPTerm lhs = 1;
|
||||
PHPTerm rhs = 2;
|
||||
}
|
||||
|
||||
message RShift {
|
||||
PHPTerm left = 1;
|
||||
PHPTerm right = 2;
|
||||
PHPTerm lhs = 1;
|
||||
PHPTerm rhs = 2;
|
||||
}
|
||||
|
||||
message And {
|
||||
|
@ -198,28 +198,28 @@ message XOr {
|
||||
}
|
||||
|
||||
message BAnd {
|
||||
PythonDiff left = 1;
|
||||
PythonDiff right = 2;
|
||||
PythonDiff lhs = 1;
|
||||
PythonDiff rhs = 2;
|
||||
}
|
||||
|
||||
message BOr {
|
||||
PythonDiff left = 1;
|
||||
PythonDiff right = 2;
|
||||
PythonDiff lhs = 1;
|
||||
PythonDiff rhs = 2;
|
||||
}
|
||||
|
||||
message BXOr {
|
||||
PythonDiff left = 1;
|
||||
PythonDiff right = 2;
|
||||
PythonDiff lhs = 1;
|
||||
PythonDiff rhs = 2;
|
||||
}
|
||||
|
||||
message LShift {
|
||||
PythonDiff left = 1;
|
||||
PythonDiff right = 2;
|
||||
PythonDiff lhs = 1;
|
||||
PythonDiff rhs = 2;
|
||||
}
|
||||
|
||||
message RShift {
|
||||
PythonDiff left = 1;
|
||||
PythonDiff right = 2;
|
||||
PythonDiff lhs = 1;
|
||||
PythonDiff rhs = 2;
|
||||
}
|
||||
|
||||
message Complement {
|
||||
|
@ -180,28 +180,28 @@ message XOr {
|
||||
}
|
||||
|
||||
message BAnd {
|
||||
PythonTerm left = 1;
|
||||
PythonTerm right = 2;
|
||||
PythonTerm lhs = 1;
|
||||
PythonTerm rhs = 2;
|
||||
}
|
||||
|
||||
message BOr {
|
||||
PythonTerm left = 1;
|
||||
PythonTerm right = 2;
|
||||
PythonTerm lhs = 1;
|
||||
PythonTerm rhs = 2;
|
||||
}
|
||||
|
||||
message BXOr {
|
||||
PythonTerm left = 1;
|
||||
PythonTerm right = 2;
|
||||
PythonTerm lhs = 1;
|
||||
PythonTerm rhs = 2;
|
||||
}
|
||||
|
||||
message LShift {
|
||||
PythonTerm left = 1;
|
||||
PythonTerm right = 2;
|
||||
PythonTerm lhs = 1;
|
||||
PythonTerm rhs = 2;
|
||||
}
|
||||
|
||||
message RShift {
|
||||
PythonTerm left = 1;
|
||||
PythonTerm right = 2;
|
||||
PythonTerm lhs = 1;
|
||||
PythonTerm rhs = 2;
|
||||
}
|
||||
|
||||
message Complement {
|
||||
|
@ -117,7 +117,8 @@ message RubySyntax {
|
||||
Module module = 83;
|
||||
Require require = 84;
|
||||
Send send = 85;
|
||||
List list = 86;
|
||||
ZSuper zSuper = 86;
|
||||
List list = 87;
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,28 +185,28 @@ message FloorDivision {
|
||||
}
|
||||
|
||||
message BAnd {
|
||||
RubyDiff left = 1;
|
||||
RubyDiff right = 2;
|
||||
RubyDiff lhs = 1;
|
||||
RubyDiff rhs = 2;
|
||||
}
|
||||
|
||||
message BOr {
|
||||
RubyDiff left = 1;
|
||||
RubyDiff right = 2;
|
||||
RubyDiff lhs = 1;
|
||||
RubyDiff rhs = 2;
|
||||
}
|
||||
|
||||
message BXOr {
|
||||
RubyDiff left = 1;
|
||||
RubyDiff right = 2;
|
||||
RubyDiff lhs = 1;
|
||||
RubyDiff rhs = 2;
|
||||
}
|
||||
|
||||
message LShift {
|
||||
RubyDiff left = 1;
|
||||
RubyDiff right = 2;
|
||||
RubyDiff lhs = 1;
|
||||
RubyDiff rhs = 2;
|
||||
}
|
||||
|
||||
message RShift {
|
||||
RubyDiff left = 1;
|
||||
RubyDiff right = 2;
|
||||
RubyDiff lhs = 1;
|
||||
RubyDiff rhs = 2;
|
||||
}
|
||||
|
||||
message Complement {
|
||||
@ -517,6 +518,8 @@ message Send {
|
||||
repeated RubyDiff sendBlock = 4;
|
||||
}
|
||||
|
||||
message ZSuper { }
|
||||
|
||||
message List {
|
||||
repeated RubyDiff listContent = 1;
|
||||
}
|
||||
|
@ -99,7 +99,8 @@ message RubySyntax {
|
||||
Module module = 83;
|
||||
Require require = 84;
|
||||
Send send = 85;
|
||||
List list = 86;
|
||||
ZSuper zSuper = 86;
|
||||
List list = 87;
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,28 +167,28 @@ message FloorDivision {
|
||||
}
|
||||
|
||||
message BAnd {
|
||||
RubyTerm left = 1;
|
||||
RubyTerm right = 2;
|
||||
RubyTerm lhs = 1;
|
||||
RubyTerm rhs = 2;
|
||||
}
|
||||
|
||||
message BOr {
|
||||
RubyTerm left = 1;
|
||||
RubyTerm right = 2;
|
||||
RubyTerm lhs = 1;
|
||||
RubyTerm rhs = 2;
|
||||
}
|
||||
|
||||
message BXOr {
|
||||
RubyTerm left = 1;
|
||||
RubyTerm right = 2;
|
||||
RubyTerm lhs = 1;
|
||||
RubyTerm rhs = 2;
|
||||
}
|
||||
|
||||
message LShift {
|
||||
RubyTerm left = 1;
|
||||
RubyTerm right = 2;
|
||||
RubyTerm lhs = 1;
|
||||
RubyTerm rhs = 2;
|
||||
}
|
||||
|
||||
message RShift {
|
||||
RubyTerm left = 1;
|
||||
RubyTerm right = 2;
|
||||
RubyTerm lhs = 1;
|
||||
RubyTerm rhs = 2;
|
||||
}
|
||||
|
||||
message Complement {
|
||||
@ -499,6 +500,8 @@ message Send {
|
||||
repeated RubyTerm sendBlock = 4;
|
||||
}
|
||||
|
||||
message ZSuper { }
|
||||
|
||||
message List {
|
||||
repeated RubyTerm listContent = 1;
|
||||
}
|
||||
|
@ -196,6 +196,7 @@ message TypeScriptSyntax {
|
||||
QualifiedExportFrom qualifiedExportFrom = 162;
|
||||
JavaScriptRequire javaScriptRequire = 163;
|
||||
List list = 164;
|
||||
StatementBlock statementBlock = 165;
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,33 +299,33 @@ message FloorDivision {
|
||||
}
|
||||
|
||||
message BAnd {
|
||||
TypeScriptDiff left = 1;
|
||||
TypeScriptDiff right = 2;
|
||||
TypeScriptDiff lhs = 1;
|
||||
TypeScriptDiff rhs = 2;
|
||||
}
|
||||
|
||||
message BOr {
|
||||
TypeScriptDiff left = 1;
|
||||
TypeScriptDiff right = 2;
|
||||
TypeScriptDiff lhs = 1;
|
||||
TypeScriptDiff rhs = 2;
|
||||
}
|
||||
|
||||
message BXOr {
|
||||
TypeScriptDiff left = 1;
|
||||
TypeScriptDiff right = 2;
|
||||
TypeScriptDiff lhs = 1;
|
||||
TypeScriptDiff rhs = 2;
|
||||
}
|
||||
|
||||
message LShift {
|
||||
TypeScriptDiff left = 1;
|
||||
TypeScriptDiff right = 2;
|
||||
TypeScriptDiff lhs = 1;
|
||||
TypeScriptDiff rhs = 2;
|
||||
}
|
||||
|
||||
message RShift {
|
||||
TypeScriptDiff left = 1;
|
||||
TypeScriptDiff right = 2;
|
||||
TypeScriptDiff lhs = 1;
|
||||
TypeScriptDiff rhs = 2;
|
||||
}
|
||||
|
||||
message UnsignedRShift {
|
||||
TypeScriptDiff left = 1;
|
||||
TypeScriptDiff right = 2;
|
||||
TypeScriptDiff lhs = 1;
|
||||
TypeScriptDiff rhs = 2;
|
||||
}
|
||||
|
||||
message Complement {
|
||||
@ -857,6 +858,7 @@ message OptionalParameter {
|
||||
message RequiredParameter {
|
||||
repeated TypeScriptDiff requiredParameterContext = 1;
|
||||
TypeScriptDiff requiredParameterSubject = 2;
|
||||
TypeScriptDiff requiredParameterValue = 3;
|
||||
}
|
||||
|
||||
message RestParameter {
|
||||
@ -965,6 +967,10 @@ message List {
|
||||
repeated TypeScriptDiff listContent = 1;
|
||||
}
|
||||
|
||||
message StatementBlock {
|
||||
repeated TypeScriptDiff statements = 1;
|
||||
}
|
||||
|
||||
message Alias {
|
||||
bytes aliasValue = 1;
|
||||
bytes aliasName = 2;
|
||||
|
@ -178,6 +178,7 @@ message TypeScriptSyntax {
|
||||
QualifiedExportFrom qualifiedExportFrom = 162;
|
||||
JavaScriptRequire javaScriptRequire = 163;
|
||||
List list = 164;
|
||||
StatementBlock statementBlock = 165;
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,33 +281,33 @@ message FloorDivision {
|
||||
}
|
||||
|
||||
message BAnd {
|
||||
TypeScriptTerm left = 1;
|
||||
TypeScriptTerm right = 2;
|
||||
TypeScriptTerm lhs = 1;
|
||||
TypeScriptTerm rhs = 2;
|
||||
}
|
||||
|
||||
message BOr {
|
||||
TypeScriptTerm left = 1;
|
||||
TypeScriptTerm right = 2;
|
||||
TypeScriptTerm lhs = 1;
|
||||
TypeScriptTerm rhs = 2;
|
||||
}
|
||||
|
||||
message BXOr {
|
||||
TypeScriptTerm left = 1;
|
||||
TypeScriptTerm right = 2;
|
||||
TypeScriptTerm lhs = 1;
|
||||
TypeScriptTerm rhs = 2;
|
||||
}
|
||||
|
||||
message LShift {
|
||||
TypeScriptTerm left = 1;
|
||||
TypeScriptTerm right = 2;
|
||||
TypeScriptTerm lhs = 1;
|
||||
TypeScriptTerm rhs = 2;
|
||||
}
|
||||
|
||||
message RShift {
|
||||
TypeScriptTerm left = 1;
|
||||
TypeScriptTerm right = 2;
|
||||
TypeScriptTerm lhs = 1;
|
||||
TypeScriptTerm rhs = 2;
|
||||
}
|
||||
|
||||
message UnsignedRShift {
|
||||
TypeScriptTerm left = 1;
|
||||
TypeScriptTerm right = 2;
|
||||
TypeScriptTerm lhs = 1;
|
||||
TypeScriptTerm rhs = 2;
|
||||
}
|
||||
|
||||
message Complement {
|
||||
@ -839,6 +840,7 @@ message OptionalParameter {
|
||||
message RequiredParameter {
|
||||
repeated TypeScriptTerm requiredParameterContext = 1;
|
||||
TypeScriptTerm requiredParameterSubject = 2;
|
||||
TypeScriptTerm requiredParameterValue = 3;
|
||||
}
|
||||
|
||||
message RestParameter {
|
||||
@ -947,6 +949,10 @@ message List {
|
||||
repeated TypeScriptTerm listContent = 1;
|
||||
}
|
||||
|
||||
message StatementBlock {
|
||||
repeated TypeScriptTerm statements = 1;
|
||||
}
|
||||
|
||||
message Alias {
|
||||
bytes aliasValue = 1;
|
||||
bytes aliasName = 2;
|
||||
|
@ -144,9 +144,9 @@ newtype Cache term address value = Cache { unCache :: Monoidal.Map (Configuratio
|
||||
|
||||
-- | A single point in a program’s execution.
|
||||
data Configuration term address value = Configuration
|
||||
{ configurationTerm :: term -- ^ The “instruction,” i.e. the current term to evaluate.
|
||||
, configurationRoots :: Live address -- ^ The set of rooted addresses.
|
||||
, configurationHeap :: Heap address address value -- ^ The heap of values.
|
||||
{ configurationTerm :: term -- ^ The “instruction,” i.e. the current term to evaluate.
|
||||
, configurationRoots :: Live address -- ^ The set of rooted addresses.
|
||||
, configurationHeap :: Heap address address value -- ^ The heap of values.
|
||||
}
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
|
@ -65,23 +65,24 @@ style = (defaultStyle (T.encodeUtf8Builder . vertexIdentifier))
|
||||
graphingTerms :: ( Member (Reader ModuleInfo) sig
|
||||
, Member (Reader Span) sig
|
||||
, Member (State (Graph ControlFlowVertex)) sig
|
||||
, Member (State (Map (Slot (Hole context (Located address))) ControlFlowVertex)) sig
|
||||
, Member (State (Heap (Hole context (Located address)) (Hole context (Located address)) value)) sig
|
||||
, Member (State (Map (Slot hole) ControlFlowVertex)) sig
|
||||
, Member (State (Heap hole hole value)) sig
|
||||
, Member (State (ScopeGraph (Hole context (Located address)))) sig
|
||||
, Member (Resumable (BaseError (ScopeError (Hole context (Located address))))) sig
|
||||
, Member (Resumable (BaseError (HeapError (Hole context (Located address))))) sig
|
||||
, Member (Reader (CurrentFrame (Hole context (Located address)))) sig
|
||||
, Member (Reader (CurrentScope (Hole context (Located address)))) sig
|
||||
, Member (Resumable (BaseError (ScopeError hole))) sig
|
||||
, Member (Resumable (BaseError (HeapError hole))) sig
|
||||
, Member (Reader (CurrentFrame hole)) sig
|
||||
, Member (Reader (CurrentScope hole)) sig
|
||||
, Member (Reader ControlFlowVertex) sig
|
||||
, VertexDeclaration syntax
|
||||
, Declarations1 syntax
|
||||
, Ord address
|
||||
, Ord context
|
||||
, Foldable syntax
|
||||
, hole ~ Hole context (Located address)
|
||||
, term ~ Term syntax Location
|
||||
, Carrier sig m
|
||||
)
|
||||
=> Open (term -> Evaluator term (Hole context (Located address)) value m a)
|
||||
=> Open (term -> Evaluator term hole value m a)
|
||||
graphingTerms recur term@(Term (In a syntax)) = do
|
||||
definedInModule <- currentModule
|
||||
case toVertex a definedInModule syntax of
|
||||
|
@ -35,7 +35,7 @@ getConfiguration term = Configuration term <$> getHeap
|
||||
|
||||
-- | A single point in a program’s execution.
|
||||
data Configuration term address value = Configuration
|
||||
{ configurationTerm :: term -- ^ The “instruction,” i.e. the current term to evaluate.
|
||||
, configurationHeap :: Heap address address value -- ^ The heap of values.
|
||||
{ configurationTerm :: term -- ^ The “instruction,” i.e. the current term to evaluate.
|
||||
, configurationHeap :: Heap address address value -- ^ The heap of values.
|
||||
}
|
||||
deriving (Eq, Ord, Show)
|
||||
|
@ -80,9 +80,9 @@ sendFunction :: (Member (Function term address value) sig, Carrier sig m) => Fun
|
||||
sendFunction = send
|
||||
|
||||
data Function term address value (m :: * -> *) k
|
||||
= Function Name [Name] term address (value -> k)
|
||||
| BuiltIn address BuiltIn (value -> k)
|
||||
| Call value [value] (value -> k)
|
||||
= Function Name [Name] term address (value -> k) -- ^ A function is parameterized by its name, parameter names, body, parent scope, and returns a ValueRef.
|
||||
| BuiltIn address BuiltIn (value -> k) -- ^ A built-in is parameterized by its parent scope, BuiltIn type, and returns a value.
|
||||
| Call value [value] (value -> k) -- ^ A Call takes a set of values as parameters and returns a ValueRef.
|
||||
deriving (Functor)
|
||||
|
||||
instance HFunctor (Function term address value) where
|
||||
|
@ -147,8 +147,9 @@ instance HasPrelude 'Ruby where
|
||||
defineBuiltIn (Declaration $ X.name "inspect") Show
|
||||
|
||||
instance HasPrelude 'TypeScript where
|
||||
definePrelude _ = defineSelf
|
||||
-- defineNamespace (Declaration (X.name "console")) $ defineBuiltIn (Declaration $ X.name "log") Print
|
||||
definePrelude _ = do
|
||||
defineSelf
|
||||
defineNamespace (Declaration (X.name "console")) $ defineBuiltIn (Declaration $ X.name "log") Print
|
||||
|
||||
instance HasPrelude 'JavaScript where
|
||||
definePrelude _ = do
|
||||
|
@ -41,14 +41,20 @@ import qualified Data.Map.Strict as Map
|
||||
import Prelude hiding (lookup)
|
||||
import Prologue
|
||||
|
||||
-- | A Frame describes the vertices of the Heap. Think of it as an instance of a Scope in the ScopeGraph.
|
||||
data Frame scopeAddress frameAddress value = Frame
|
||||
{ scopeAddress :: scopeAddress
|
||||
-- ^ The scope address of its corresponding Scope
|
||||
, links :: Map EdgeLabel (Map scopeAddress frameAddress)
|
||||
-- ^ A map of edge labels to maps of scope addresses to frame addresses (scope addresses are unique keys in the ScopeGraph
|
||||
-- and frame addresses are unique keys in the Heap). This map describes the frame’s links to other frames.
|
||||
-- A frame’s links are always in one-to-one correspondence with its scope’s edges to parent scopes.
|
||||
, slots :: IntMap (Set value)
|
||||
-- ^ An IntMap of values that are declared in the frame.
|
||||
}
|
||||
deriving (Eq, Ord, Show, Generic, NFData)
|
||||
|
||||
-- | A map of frame addresses onto Frames.
|
||||
-- | A Heap is a Map from frame addresses to frames.
|
||||
newtype Heap scopeAddress frameAddress value = Heap { unHeap :: Map frameAddress (Frame scopeAddress frameAddress value) }
|
||||
deriving stock (Eq, Generic, Ord)
|
||||
deriving newtype (NFData)
|
||||
@ -135,11 +141,13 @@ heapSize = Map.size . unHeap
|
||||
heapRestrict :: Ord address => Heap address address value -> Live address -> Heap address address value
|
||||
heapRestrict (Heap m) roots = Heap (Map.filterWithKey (\ address _ -> address `liveMember` roots) m)
|
||||
|
||||
-- | Checks whether a heap as no slots and links.
|
||||
isHeapEmpty :: (Eq address, Eq value) => Heap scope address value -> Bool
|
||||
isHeapEmpty h@(Heap heap)
|
||||
= heapSize h == 1
|
||||
&& (toEmptyFrame <$> Map.elems heap) == [ Frame () mempty mempty ]
|
||||
where
|
||||
-- Maps a frame's address param to () so we can check that its slots and links are empty.
|
||||
toEmptyFrame Frame{..} = Frame () (Map.mapKeysMonotonic (const ()) <$> links) slots
|
||||
|
||||
|
||||
|
@ -176,34 +176,6 @@ instance (Show address, Show term) => AbstractIntro (Value term address) where
|
||||
|
||||
null = Null
|
||||
|
||||
-- materializeEnvironment :: ( Member (Deref (Value term address)) sig
|
||||
-- , Member (Reader ModuleInfo) sig
|
||||
-- , Member (Reader Span) sig
|
||||
-- , Member (Resumable (BaseError (AddressError address (Value term address)))) sig
|
||||
-- , Member (State (Heap address address (Value term address))) sig
|
||||
-- , Ord address
|
||||
-- , Carrier sig m
|
||||
-- )
|
||||
-- => Value term address
|
||||
-- -> Evaluator term address (Value term address) m (Maybe (Environment address))
|
||||
-- materializeEnvironment val = do
|
||||
-- ancestors <- rec val
|
||||
-- pure (Env.Environment <$> nonEmpty ancestors)
|
||||
-- where
|
||||
-- rec val = do
|
||||
-- supers <- concat <$> traverse (deref >=> rec) (parents val)
|
||||
-- pure . maybe [] (: supers) $ bindsFrom val
|
||||
--
|
||||
-- bindsFrom = \case
|
||||
-- Class _ _ binds -> Just binds
|
||||
-- Namespace _ _ binds -> Just binds
|
||||
-- _ -> Nothing
|
||||
--
|
||||
-- parents = \case
|
||||
-- Class _ supers _ -> supers
|
||||
-- Namespace _ supers _ -> toList supers
|
||||
-- _ -> []
|
||||
|
||||
-- | Construct a 'Value' wrapping the value arguments (if any).
|
||||
instance ( Member (Allocator address) sig
|
||||
, Member (Abstract.Boolean (Value term address)) sig
|
||||
@ -243,6 +215,7 @@ instance ( Member (Allocator address) sig
|
||||
scopedEnvironment v
|
||||
| Object address <- v = pure (Just address)
|
||||
| Class _ _ address <- v = pure (Just address)
|
||||
| Namespace _ address <- v = pure (Just address)
|
||||
| otherwise = pure Nothing
|
||||
|
||||
asString v
|
||||
|
@ -126,6 +126,7 @@ type Syntax = '[
|
||||
, Ruby.Syntax.Module
|
||||
, Ruby.Syntax.Require
|
||||
, Ruby.Syntax.Send
|
||||
, Ruby.Syntax.ZSuper
|
||||
, []
|
||||
]
|
||||
|
||||
@ -214,12 +215,12 @@ withNewScope inner = withExtendedScope $ do
|
||||
identifier :: Assignment Term
|
||||
identifier =
|
||||
vcallOrLocal
|
||||
<|> zsuper
|
||||
<|> mk Constant
|
||||
<|> mk InstanceVariable
|
||||
<|> mk ClassVariable
|
||||
<|> mk GlobalVariable
|
||||
<|> mk Operator
|
||||
<|> mk Super
|
||||
<|> mk Setter
|
||||
<|> mk SplatArgument
|
||||
<|> mk HashSplatArgument
|
||||
@ -227,6 +228,7 @@ identifier =
|
||||
<|> mk Uninterpreted
|
||||
where
|
||||
mk s = makeTerm <$> symbol s <*> (Syntax.Identifier . name <$> source)
|
||||
zsuper = makeTerm <$> symbol Super <*> (Ruby.Syntax.ZSuper <$ source)
|
||||
vcallOrLocal = do
|
||||
(loc, ident, locals) <- identWithLocals
|
||||
case ident of
|
||||
|
@ -374,3 +374,18 @@ instance Evaluatable Assignment where
|
||||
instance Tokenize Assignment where
|
||||
-- Should we be using 'assignmentContext' in here?
|
||||
tokenize Assignment{..} = assignmentTarget *> yield Token.Assign <* assignmentValue
|
||||
|
||||
-- | A call to @super@ without parentheses in Ruby is known as "zsuper", which has
|
||||
-- the semantics of invoking @super()@ but implicitly passing the current function's
|
||||
-- arguments to the @super()@ invocation.
|
||||
data ZSuper a = ZSuper
|
||||
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable, Named1, Message1, NFData1)
|
||||
|
||||
instance Evaluatable ZSuper
|
||||
|
||||
instance Eq1 ZSuper where liftEq = genericLiftEq
|
||||
instance Ord1 ZSuper where liftCompare = genericLiftCompare
|
||||
instance Show1 ZSuper where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
instance Tokenize ZSuper where
|
||||
tokenize _ = yield $ Run "super"
|
||||
|
@ -7,7 +7,6 @@ module Language.TypeScript.Resolution
|
||||
, resolveModule
|
||||
, resolveNonRelativePath
|
||||
, javascriptExtensions
|
||||
-- , evalRequire
|
||||
, typescriptExtensions
|
||||
) where
|
||||
|
||||
@ -19,8 +18,8 @@ import Data.Abstract.Evaluatable
|
||||
import qualified Data.Abstract.Module as M
|
||||
import Data.Abstract.Package
|
||||
import Data.Abstract.Path
|
||||
import Data.ImportPath
|
||||
import qualified Data.Language as Language
|
||||
import Data.ImportPath
|
||||
|
||||
-- Node.js resolution algorithm: https://nodejs.org/api/modules.html#modules_all_together
|
||||
--
|
||||
|
@ -85,7 +85,7 @@ instance Ord1 OptionalParameter where liftCompare = genericLiftCompare
|
||||
instance Show1 OptionalParameter where liftShowsPrec = genericLiftShowsPrec
|
||||
instance Evaluatable OptionalParameter
|
||||
|
||||
data RequiredParameter a = RequiredParameter { requiredParameterContext :: ![a], requiredParameterSubject :: !a, requiredParameterValue :: !a }
|
||||
data RequiredParameter a = RequiredParameter { requiredParameterContext :: [a], requiredParameterSubject :: a, requiredParameterValue :: a }
|
||||
deriving (Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Message1, NFData1, Named1, Ord, Show, ToJSONFields1, Traversable)
|
||||
|
||||
instance Declarations1 RequiredParameter where
|
||||
|
@ -611,6 +611,7 @@ instance Taggable Ruby.Load
|
||||
instance Taggable Ruby.LowPrecedenceAnd
|
||||
instance Taggable Ruby.LowPrecedenceOr
|
||||
instance Taggable Ruby.Assignment
|
||||
instance Taggable Ruby.ZSuper
|
||||
|
||||
instance Taggable TypeScript.JavaScriptRequire
|
||||
instance Taggable TypeScript.Debugger
|
||||
|
@ -44,13 +44,12 @@ spec config = parallel $ do
|
||||
(scopeGraph, (heap, res)) <- evaluate ["main1.ts", "foo.ts", "a.ts"]
|
||||
case ModuleTable.lookup "main1.ts" <$> res of
|
||||
Right (Just (Module _ (scopeAndFrame, _) :| [])) -> do
|
||||
-- Env.names env `shouldBe` [ "b", "z" ]
|
||||
() <$ SpecHelpers.lookupDeclaration "b" scopeAndFrame heap scopeGraph `shouldBe` Just ()
|
||||
() <$ SpecHelpers.lookupDeclaration "z" scopeAndFrame heap scopeGraph `shouldBe` Just ()
|
||||
|
||||
lookupMembers "b" Import scopeAndFrame heap scopeGraph `shouldBe` Just [ "baz", "foo" ]
|
||||
lookupMembers "z" Import scopeAndFrame heap scopeGraph `shouldBe` Just [ "baz", "foo" ]
|
||||
-- (Heap.lookupDeclaration "b" heap >>= deNamespace heap) `shouldBe` Just ("b", [ "baz", "foo" ])
|
||||
-- (Heap.lookupDeclaration "z" heap >>= deNamespace heap) `shouldBe` Just ("z", [ "baz", "foo" ])
|
||||
|
||||
() <$ SpecHelpers.lookupDeclaration "baz" scopeAndFrame heap scopeGraph `shouldBe` Nothing
|
||||
() <$ SpecHelpers.lookupDeclaration "foo" scopeAndFrame heap scopeGraph `shouldBe` Nothing
|
||||
other -> expectationFailure (show other)
|
||||
@ -77,7 +76,7 @@ spec config = parallel $ do
|
||||
Right (Just (Module _ (scopeAndFrame@(currentScope, currentFrame), value) :| [])) -> do
|
||||
() <$ SpecHelpers.lookupDeclaration "baz" scopeAndFrame heap scopeGraph `shouldBe` Nothing
|
||||
value `shouldBe` Unit
|
||||
Heap.heapSize heap `shouldBe` 3
|
||||
Heap.heapSize heap `shouldBe` 4
|
||||
other -> expectationFailure (show other)
|
||||
|
||||
it "fails exporting symbols not defined in the module" $ do
|
||||
|
@ -477,6 +477,9 @@ instance Listable1 Ruby.Syntax.Module where
|
||||
instance Listable1 Ruby.Syntax.Require where
|
||||
liftTiers tiers' = liftCons2 tiers tiers' Ruby.Syntax.Require
|
||||
|
||||
instance Listable1 Ruby.Syntax.ZSuper where
|
||||
liftTiers tiers = cons0 Ruby.Syntax.ZSuper
|
||||
|
||||
instance Listable1 Ruby.Syntax.Send where
|
||||
liftTiers tiers = liftCons4 (liftTiers tiers) (liftTiers tiers) (liftTiers tiers) (liftTiers tiers) Ruby.Syntax.Send
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
(SymbolElement)
|
||||
(Integer)
|
||||
(This)
|
||||
(Identifier)
|
||||
(ZSuper)
|
||||
(Enumeration
|
||||
(Integer)
|
||||
(Integer)
|
||||
|
Loading…
Reference in New Issue
Block a user