Evaluation works!

This commit is contained in:
2022-06-13 15:10:12 +02:00
parent 004db89c60
commit 81a483d540
28 changed files with 307 additions and 198 deletions

View File

@@ -13,6 +13,11 @@ CarpCharacterNode >> acceptVisitor: anExpressionVisitor [
^ anExpressionVisitor visitCharacter: self
]
{ #category : #accessing }
CarpCharacterNode >> toPharo [
^ value source asCharacter
]
{ #category : #generated }
CarpCharacterNode >> tokenVariables [

View File

@@ -25,3 +25,8 @@ CarpExpressionNode >> isQuoted [
CarpExpressionNode >> listDepth [
^ parent ifNil: [ 0 ] ifNotNil: [ parent listDepth + 1 ]
]
{ #category : #accessing }
CarpExpressionNode >> toPharo [
^ self subclassResponsibility
]

View File

@@ -13,6 +13,11 @@ CarpNumberNode >> acceptVisitor: anExpressionVisitor [
^ anExpressionVisitor visitNumber: self
]
{ #category : #accessing }
CarpNumberNode >> toPharo [
^ value source asInteger
]
{ #category : #generated }
CarpNumberNode >> tokenVariables [

View File

@@ -34,6 +34,11 @@ CarpPairNode >> nodeVariables [
^ #( #key #value )
]
{ #category : #accessing }
CarpPairNode >> toPharo [
^ Association key: key toPharo value: value toPharo
]
{ #category : #generated }
CarpPairNode >> value [

View File

@@ -29,6 +29,11 @@ CarpQuoteNode >> nodeVariables [
^ #( #value )
]
{ #category : #accessing }
CarpQuoteNode >> toPharo [
^ {#quote . value toPharo }
]
{ #category : #generated }
CarpQuoteNode >> value [

View File

@@ -38,3 +38,8 @@ CarpStartNode >> initialize [
super initialize.
expressions := OrderedCollection new: 2.
]
{ #category : #accessing }
CarpStartNode >> toPharo [
^ expressions collect: #toPharo
]

View File

@@ -13,6 +13,11 @@ CarpStringNode >> acceptVisitor: anExpressionVisitor [
^ anExpressionVisitor visitString: self
]
{ #category : #accessing }
CarpStringNode >> toPharo [
^ value source
]
{ #category : #generated }
CarpStringNode >> tokenVariables [

View File

@@ -13,6 +13,11 @@ CarpVariableNode >> acceptVisitor: anExpressionVisitor [
^ anExpressionVisitor visitVariable: self
]
{ #category : #accessing }
CarpVariableNode >> toPharo [
^ value source asSymbol
]
{ #category : #generated }
CarpVariableNode >> tokenVariables [

View File

@@ -65,6 +65,11 @@ CarpArrayNode >> rightBracket: aSmaCCToken [
rightBracket := aSmaCCToken
]
{ #category : #accessing }
CarpArrayNode >> toPharo [
^ expressions collect: #toPharo
]
{ #category : #generated }
CarpArrayNode >> tokenVariables [

View File

@@ -32,6 +32,11 @@ CarpDerefNode >> nodeVariables [
^ #( #value )
]
{ #category : #accessing }
CarpDerefNode >> toPharo [
^ {#deref . value toPharo}
]
{ #category : #generated }
CarpDerefNode >> tokenVariables [

View File

@@ -65,6 +65,11 @@ CarpListNode >> rightParen: aSmaCCToken [
rightParen := aSmaCCToken
]
{ #category : #accessing }
CarpListNode >> toPharo [
^ expressions collect: #toPharo
]
{ #category : #generated }
CarpListNode >> tokenVariables [

View File

@@ -65,6 +65,11 @@ CarpMapNode >> rightBrace: aSmaCCToken [
rightBrace := aSmaCCToken
]
{ #category : #accessing }
CarpMapNode >> toPharo [
^ (pairs collect: #toPharo) asDictionary
]
{ #category : #generated }
CarpMapNode >> tokenVariables [

View File

@@ -32,6 +32,11 @@ CarpModuleOrTypeNode >> nodeVariables [
^ #( #value )
]
{ #category : #accessing }
CarpModuleOrTypeNode >> toPharo [
^ value source asSymbol
]
{ #category : #generated }
CarpModuleOrTypeNode >> tokenVariables [

View File

@@ -6,7 +6,7 @@ Class {
{ #category : #'generated-accessing' }
CarpParser class >> cacheId [
^'2022-04-17T17:01:25.369965+02:00'
^'2022-06-13T14:48:36.40126+02:00'
]
{ #category : #generated }
@@ -16,6 +16,26 @@ CarpParser class >> definitionComment [
%root Expression;
%prefix Carp;
%suffix Node;
%hierarchy Expression (
Array
Deref
List
Map
ModuleOrType
Pattern
RefCall
Ref
Unquote
Character
Number
Pair
Quote
Start
String
Variable
);
<escape>
: \\ (. | u[0-9A-F]{4,4} | o[0-7]{3,3} | newline | return | space | tab | space | backspace | formfeed) # other character types
;
@@ -155,44 +175,44 @@ String
{ #category : #generated }
CarpParser class >> reduceTable [
^#(
#(24 0 #reduceActionForExpressions1: 1289217 false)
#(23 1 #reduceActionForStart1: 1258497 false)
#(32 0 #reduceActionForExpressions1: 1803265 false)
#(43 1 #reduceActionForString1: 2446337 false)
#(40 1 #reduceActionForVariable1: 2233345 false)
#(41 1 #reduceActionForModuleOrType2: 2273282 false)
#(36 1 #reduceActionForNumber1: 2013185 false)
#(35 1 #reduceActionForCharacter1: 1971201 false)
#(24 2 #reduceActionForExpressions2: 1289218 false)
#(25 1 #liftFirstValue: 1347588 false)
#(25 1 #liftFirstValue: 1347589 false)
#(25 1 #liftFirstValue: 1347587 false)
#(25 1 #liftFirstValue: 1347586 false)
#(25 1 #liftFirstValue: 1347585 false)
#(30 1 #liftFirstValue: 1652745 false)
#(30 1 #liftFirstValue: 1652744 false)
#(30 1 #liftFirstValue: 1652743 false)
#(30 1 #liftFirstValue: 1652742 false)
#(30 1 #liftFirstValue: 1652739 false)
#(30 1 #liftFirstValue: 1652741 false)
#(30 1 #liftFirstValue: 1652740 false)
#(39 1 #liftFirstValue: 2195458 false)
#(39 1 #liftFirstValue: 2195457 false)
#(30 1 #liftFirstValue: 1652738 false)
#(30 1 #liftFirstValue: 1652737 false)
#(34 2 #reduceActionForPattern1: 1906689 false)
#(27 2 #reduceActionForUnquote1: 1466369 false)
#(27 2 #reduceActionForUnquote1: 1466370 false)
#(28 2 #reduceActionForRef1: 1548289 false)
#(29 2 #reduceActionForDeref1: 1598465 false)
#(26 2 #reduceActionForRefCall1: 1412097 false)
#(38 2 #reduceActionForQuote1: 2150401 false)
#(31 3 #reduceActionForMap1: 1744897 false)
#(32 2 #reduceActionForExpressions2: 1803266 false)
#(42 3 #reduceActionForList1: 2364417 false)
#(41 3 #reduceActionForModuleOrType1: 2273281 false)
#(37 3 #reduceActionForArray1: 2059265 false)
#(33 2 #reduceActionForMapPair1: 1846273 false)
#(24 0 #reduceActionForExpressions1: 1449985 false)
#(23 1 #reduceActionForStart1: 1419265 false)
#(32 0 #reduceActionForExpressions1: 1964033 false)
#(43 1 #reduceActionForString1: 2607105 false)
#(40 1 #reduceActionForVariable1: 2394113 false)
#(41 1 #reduceActionForModuleOrType2: 2434050 false)
#(36 1 #reduceActionForNumber1: 2173953 false)
#(35 1 #reduceActionForCharacter1: 2131969 false)
#(24 2 #reduceActionForExpressions2: 1449986 false)
#(25 1 #liftFirstValue: 1508356 false)
#(25 1 #liftFirstValue: 1508357 false)
#(25 1 #liftFirstValue: 1508355 false)
#(25 1 #liftFirstValue: 1508354 false)
#(25 1 #liftFirstValue: 1508353 false)
#(30 1 #liftFirstValue: 1813513 false)
#(30 1 #liftFirstValue: 1813512 false)
#(30 1 #liftFirstValue: 1813511 false)
#(30 1 #liftFirstValue: 1813510 false)
#(30 1 #liftFirstValue: 1813507 false)
#(30 1 #liftFirstValue: 1813509 false)
#(30 1 #liftFirstValue: 1813508 false)
#(39 1 #liftFirstValue: 2356226 false)
#(39 1 #liftFirstValue: 2356225 false)
#(30 1 #liftFirstValue: 1813506 false)
#(30 1 #liftFirstValue: 1813505 false)
#(34 2 #reduceActionForPattern1: 2067457 false)
#(27 2 #reduceActionForUnquote1: 1627137 false)
#(27 2 #reduceActionForUnquote1: 1627138 false)
#(28 2 #reduceActionForRef1: 1709057 false)
#(29 2 #reduceActionForDeref1: 1759233 false)
#(26 2 #reduceActionForRefCall1: 1572865 false)
#(38 2 #reduceActionForQuote1: 2311169 false)
#(31 3 #reduceActionForMap1: 1905665 false)
#(32 2 #reduceActionForExpressions2: 1964034 false)
#(42 3 #reduceActionForList1: 2525185 false)
#(41 3 #reduceActionForModuleOrType1: 2434049 false)
#(37 3 #reduceActionForArray1: 2220033 false)
#(33 2 #reduceActionForMapPair1: 2007041 false)
).
]

View File

@@ -26,6 +26,11 @@ CarpPatternNode >> patternGlyph: aSmaCCToken [
patternGlyph := aSmaCCToken
]
{ #category : #accessing }
CarpPatternNode >> toPharo [
^ value source
]
{ #category : #generated }
CarpPatternNode >> tokenVariables [

View File

@@ -32,6 +32,11 @@ CarpRefCallNode >> refGlyph: aSmaCCToken [
refGlyph := aSmaCCToken
]
{ #category : #accessing }
CarpRefCallNode >> toPharo [
^ {#'ref-call' . value toPharo}
]
{ #category : #generated }
CarpRefCallNode >> tokenVariables [

View File

@@ -32,6 +32,11 @@ CarpRefNode >> refGlyph: aSmaCCToken [
refGlyph := aSmaCCToken
]
{ #category : #accessing }
CarpRefNode >> toPharo [
^ {#ref . value toPharo}
]
{ #category : #generated }
CarpRefNode >> tokenVariables [

View File

@@ -30,80 +30,72 @@ CarpScanner >> scan1 [
{ #category : #generated }
CarpScanner >> scan2 [
self recordMatch: #(13).
self step.
currentCharacter isDigit ifTrue: [ ^ self scan3 ].
(currentCharacter isLowercase or: [
currentCharacter isUppercase or: [
('!$' includes: currentCharacter) or: [
(currentCharacter between: $* and: $+) or: [
('-/:' includes: currentCharacter) or: [
(currentCharacter between: $< and: $?) or: [
currentCharacter == $_ ] ] ] ] ] ]) ifTrue: [
[
self recordMatch: #( 13 ).
(currentCharacter isLowercase
or: [ currentCharacter isUppercase
or: [ ('!$' includes: currentCharacter)
or: [ (currentCharacter between: $* and: $+)
or: [ currentCharacter == $-
or: [ (currentCharacter between: $/ and: $:)
or: [ (currentCharacter between: $< and: $?) or: [ currentCharacter == $_ ] ] ] ] ] ] ])
ifTrue: [ [ self recordMatch: #(13).
self step.
currentCharacter isLowercase or: [
currentCharacter isUppercase or: [
currentCharacter isDigit or: [
('!$' includes: currentCharacter) or: [
(currentCharacter between: $* and: $+) or: [
('-/:' includes: currentCharacter) or: [
(currentCharacter between: $< and: $?) or: [
currentCharacter == $_ ] ] ] ] ] ] ] ] whileTrue ].
currentCharacter isLowercase
or: [ currentCharacter isUppercase
or: [ currentCharacter isDigit
or: [ ('!$' includes: currentCharacter)
or: [ (currentCharacter between: $* and: $+)
or: [ ('-/:' includes: currentCharacter)
or: [ (currentCharacter between: $< and: $?) or: [ currentCharacter == $_ ] ] ] ] ] ] ] ]
whileTrue ].
^ self reportLastMatch
]
{ #category : #generated }
CarpScanner >> scan3 [
[
self recordMatch: #( 13 18 ).
[ self recordMatch: #(13 18).
self step.
currentCharacter == $. ifTrue: [ ^ self scan4 ].
currentCharacter isDigit ] whileTrue.
('bfl' includes: currentCharacter) ifTrue: [
self recordMatch: #( 13 18 ).
('bfl' includes: currentCharacter)
ifTrue: [ self recordMatch: #(13 18).
self step.
(currentCharacter isLowercase or: [
currentCharacter isUppercase or: [
currentCharacter isDigit or: [
('!$' includes: currentCharacter) or: [
(currentCharacter between: $* and: $+) or: [
('-/:' includes: currentCharacter) or: [
(currentCharacter between: $< and: $?) or: [
currentCharacter == $_ ] ] ] ] ] ] ]) ifTrue: [
[
self recordMatch: #( 13 ).
(currentCharacter isLowercase
or: [ currentCharacter isUppercase
or: [ currentCharacter isDigit
or: [ ('!$' includes: currentCharacter)
or: [ (currentCharacter between: $* and: $+)
or: [ ('-/:' includes: currentCharacter)
or: [ (currentCharacter between: $< and: $?) or: [ currentCharacter == $_ ] ] ] ] ] ] ])
ifTrue: [ [ self recordMatch: #(13).
self step.
currentCharacter isLowercase or: [
currentCharacter isUppercase or: [
currentCharacter isDigit or: [
('!$' includes: currentCharacter) or: [
(currentCharacter between: $* and: $+) or: [
('-/:' includes: currentCharacter) or: [
(currentCharacter between: $< and: $?) or: [
currentCharacter == $_ ] ] ] ] ] ] ] ] whileTrue ].
currentCharacter isLowercase
or: [ currentCharacter isUppercase
or: [ currentCharacter isDigit
or: [ ('!$' includes: currentCharacter)
or: [ (currentCharacter between: $* and: $+)
or: [ ('-/:' includes: currentCharacter)
or: [ (currentCharacter between: $< and: $?) or: [ currentCharacter == $_ ] ] ] ] ] ] ] ]
whileTrue ].
^ self reportLastMatch ].
(currentCharacter isUppercase or: [
currentCharacter isLowercase or: [
('!$' includes: currentCharacter) or: [
(currentCharacter between: $* and: $+) or: [
('-/:' includes: currentCharacter) or: [
(currentCharacter between: $< and: $?) or: [
currentCharacter == $_ ] ] ] ] ] ]) ifTrue: [
[
self recordMatch: #( 13 ).
(currentCharacter isUppercase
or: [ currentCharacter isLowercase
or: [ ('!$' includes: currentCharacter)
or: [ (currentCharacter between: $* and: $+)
or: [ (currentCharacter between: $- and: $:)
or: [ (currentCharacter between: $< and: $?) or: [ currentCharacter == $_ ] ] ] ] ] ])
ifTrue: [ [ self recordMatch: #(13).
self step.
currentCharacter isLowercase or: [
currentCharacter isUppercase or: [
currentCharacter isDigit or: [
('!$' includes: currentCharacter) or: [
(currentCharacter between: $* and: $+) or: [
('-/:' includes: currentCharacter) or: [
(currentCharacter between: $< and: $?) or: [
currentCharacter == $_ ] ] ] ] ] ] ] ] whileTrue ].
currentCharacter isLowercase
or: [ currentCharacter isUppercase
or: [ currentCharacter isDigit
or: [ ('!$' includes: currentCharacter)
or: [ (currentCharacter between: $* and: $+)
or: [ ('-/:' includes: currentCharacter)
or: [ (currentCharacter between: $< and: $?) or: [ currentCharacter == $_ ] ] ] ] ] ] ] ]
whileTrue ].
^ self reportLastMatch
]
@@ -152,12 +144,9 @@ CarpScanner >> scan7 [
{ #category : #generated }
CarpScanner >> scanForToken [
self step.
currentCharacter == $" ifTrue: [ ^ self scan1 ].
currentCharacter == $# ifTrue: [ ^ self recordAndReportMatch: #(1) ].
currentCharacter == $% ifTrue: [ ^ self scanForTokenX7 ].
currentCharacter == $& ifTrue: [ ^ self recordAndReportMatch: #( 4 ) ].
^ self scanForTokenX9
]
@@ -330,47 +319,36 @@ CarpScanner >> scanForTokenX7 [
{ #category : #generated }
CarpScanner >> scanForTokenX8 [
currentCharacter == $] ifTrue: [ ^ self recordAndReportMatch: #(17) ].
currentCharacter == ${ ifTrue: [ ^ self recordAndReportMatch: #(6) ].
currentCharacter == $} ifTrue: [ ^ self recordAndReportMatch: #(7) ].
currentCharacter == $~ ifTrue: [ ^ self recordAndReportMatch: #(8) ].
currentCharacter isDigit ifTrue: [ ^ self scan5 ].
('''`' includes: currentCharacter) ifTrue: [
^ self recordAndReportMatch: #( 12 ) ].
(currentCharacter isSeparator or: [
currentCharacter == Character pageUp ]) ifTrue: [
^ self scanForTokenX6 ].
('''`' includes: currentCharacter)
ifTrue: [ ^ self recordAndReportMatch: #(12) ].
(currentCharacter isSeparator or: [ currentCharacter == Character pageUp ])
ifTrue: [ ^ self scanForTokenX6 ].
currentCharacter isUppercase ifTrue: [ ^ self scanForTokenX3 ].
(currentCharacter isLowercase or: [
('!$' includes: currentCharacter) or: [
(currentCharacter between: $* and: $+) or: [
('/:' includes: currentCharacter) or: [
(currentCharacter between: $< and: $?) or: [
currentCharacter == $_ ] ] ] ] ]) ifTrue: [
self scanForTokenX4 ].
(currentCharacter isLowercase
or: [ (currentCharacter between: $! and: $?) or: [ currentCharacter == $_ ] ])
ifTrue: [ self scanForTokenX4 ].
^ self reportLastMatch
]
{ #category : #generated }
CarpScanner >> scanForTokenX9 [
currentCharacter == $( ifTrue: [
^ self recordAndReportMatch: #( 10 ) ].
currentCharacter == $) ifTrue: [
^ self recordAndReportMatch: #( 11 ) ].
currentCharacter == $, ifTrue: [
^ self recordAndReportMatch: #( 19 ) ].
currentCharacter == $% ifTrue: [ ^ self scanForTokenX7 ].
currentCharacter == $& ifTrue: [ ^ self recordAndReportMatch: #(4) ].
currentCharacter == $( ifTrue: [ ^ self recordAndReportMatch: #(10) ].
currentCharacter == $) ifTrue: [ ^ self recordAndReportMatch: #(11) ].
currentCharacter == $, ifTrue: [ ^ self recordAndReportMatch: #(19) ].
currentCharacter == $- ifTrue: [ ^ self scan2 ].
currentCharacter == $. ifTrue: [
^ self recordAndReportMatch: #( 15 ) ].
currentCharacter == $. ifTrue: [ ^ self recordAndReportMatch: #(15) ].
currentCharacter == $0 ifTrue: [ ^ self scanForTokenX2 ].
currentCharacter == $; ifTrue: [ ^ self scanForTokenX5 ].
currentCharacter == $@ ifTrue: [ ^ self recordAndReportMatch: #(5) ].
currentCharacter == $[ ifTrue: [
^ self recordAndReportMatch: #( 16 ) ].
currentCharacter == $[ ifTrue: [ ^ self recordAndReportMatch: #(16) ].
currentCharacter == $\ ifTrue: [ ^ self scanForTokenX1 ].
currentCharacter == $] ifTrue: [
^ self recordAndReportMatch: #( 17 ) ].
currentCharacter == ${ ifTrue: [ ^ self recordAndReportMatch: #( 6 ) ].
^ self scanForTokenX8
]

View File

@@ -25,6 +25,11 @@ CarpUnquoteNode >> nodeVariables [
^ #( #value )
]
{ #category : #accessing }
CarpUnquoteNode >> toPharo [
^ {#unquote . value toPharo}
]
{ #category : #generated }
CarpUnquoteNode >> tokenVariables [

View File

@@ -22,7 +22,7 @@ CarpApplication >> baseApplication [
CarpApplication >> debuggerClientFor: anException [
"Answer the debugger client to be used by the Gt Post Mortem debugger"
^ GtPythonPostMortemDebugger new exception: anException
^ CarpPostMortemDebugger new exception: anException
]
{ #category : #accessing }

View File

@@ -0,0 +1,10 @@
Class {
#name : #CarpCommand,
#superclass : #LanguageLinkCommand,
#category : #'Carp-LanguageLink'
}
{ #category : #accessing }
CarpCommand >> codeForRemote [
^ (Character space join: self instructions) copyReplaceAll: Character cr asString with: Character lf asString
]

View File

@@ -3,3 +3,13 @@ Class {
#superclass : #LanguageLinkCommandFactory,
#category : #'Carp-Execution'
}
{ #category : #accessing }
CarpCommandFactory >> command [
^ command
]
{ #category : #accessing }
CarpCommandFactory >> instructionsWithNotifyAtEnd [
^ instructions
]

View File

@@ -4,19 +4,19 @@ Class {
#category : #'Carp-Serialization'
}
{ #category : #'instance creation' }
CarpDeserializer class >> deserialize: anObject [
^ self new
deserialize: anObject
]
{ #category : #accessing }
CarpDeserializer >> buildProxyFor: rawObject [
| proxy |
proxy := CarpProxyObject
carpType: (rawObject at: #carptype)
var: (rawObject at: #carpvar) asJSGI
var: (rawObject at: #carpvar)
application: self application.
self executionHandler registerObject: proxy.
^ proxy
]
{ #category : #accessing }
CarpDeserializer >> deserialize: anObject [
^ self new
deserialize: anObject
]

View File

@@ -23,7 +23,7 @@ CarpPostMortemDebugger >> exception: anException [
CarpPostMortemDebugger >> initialize [
super initialize.
frameRegex := '\s+at.+\(([^:]+)\:(\d+)\:(\d+)\)' asRegexIgnoringCase.
frameRegex := '(.*)\s+at.+([^:]+)\:(\d+)\:(\d+)\.' asRegexIgnoringCase.
]
{ #category : #accessing }
@@ -37,16 +37,19 @@ CarpPostMortemDebugger >> sourceStyler [
CarpPostMortemDebugger >> stackFrameFromLine: aString ordinal: ordinal [
"Answer a frame if the supplied string contains a valid file and line number, or nil"
<return: #GtPythonPostMortemStackFrame or: nil>
| file line column |
| file line column source |
^ (frameRegex search: aString) ifTrue:
[ file := frameRegex subexpression: 2.
line := frameRegex subexpression: 3.
column := frameRegex subexpression: 4.
file := frameRegex subexpression: 3.
line := frameRegex subexpression: 4.
column := frameRegex subexpression: 5.
self halt.
CarpPostMortemStackFrame new
ordinal: ordinal;
displayString: aString;
exception: exception;
source: source;
file: file asFileReference;
line: line asNumber;
column: column asNumber ]

View File

@@ -1,5 +1,18 @@
Class {
#name : #CarpPostMortemStackFrame,
#superclass : #GtJavaScriptPostMortemStackFrame,
#instVars : [
'source'
],
#category : #'Carp-Debugger'
}
{ #category : #accessing }
CarpPostMortemStackFrame >> source: aString [
source := aString
]
{ #category : #accessing }
CarpPostMortemStackFrame >> sourceText [
^ source
]

View File

@@ -3,7 +3,8 @@ Class {
#superclass : #GtSourceCoder,
#instVars : [
'pharoBindings',
'carpLinkApplicationStrategy'
'carpLinkApplicationStrategy',
'exception'
],
#category : #'Carp-Coder'
}
@@ -24,35 +25,37 @@ GtCarpCoderModel >> asCoderViewModel [
{ #category : #accessing }
GtCarpCoderModel >> bindAndExecute: sourceString [
"Answer the source code with all declared variables returned in an immediate dictionary"
<gtIgnoreConstraint: #GtRBAcceptVisitorCalledFromNonVisitingMethods>
| carpSource trimmedSource ast varNames lastStatement application commandFactory |
<remoteDebuggerSignal>
| carpSource trimmedSource ast varNames lastStatement application commandFactory res |
trimmedSource := SmaCCString on: sourceString trimRight.
ast := CarpParser parse: trimmedSource.
"The variables to be returned are names that are in pharoBindings"
varNames := pharoBindings bindingNames asSet.
"Assign the final statement to snippetResult"
ast := CarpParser parse: trimmedSource. "The variables to be returned are names that are in pharoBindings"
varNames := pharoBindings bindingNames asSet. "Assign the final statement to snippetResult"
lastStatement := ast expressions last.
trimmedSource
insert: '(defdynamic snippetResult '
at: lastStatement startPosition.
trimmedSource
insert: ')'
at: lastStatement stopPosition.
varNames add: 'snippetResult'.
"Get the final source to execute"
carpSource := self sourceFrom: trimmedSource asString returnedVarNames: varNames.
trimmedSource insert: ')' at: lastStatement stopPosition.
varNames add: 'snippetResult'. "Get the final source to execute"
carpSource := self
sourceFrom: trimmedSource asString
returnedVarNames: varNames.
application := carpLinkApplicationStrategy applicationServer.
application isRunning ifFalse: [ application start ].
commandFactory := application newCommandFactory.
^ commandFactory
res := commandFactory
<< carpSource;
sendAndWait.
(res at: #result) = 'success' ifTrue: [ ^ res at: #value ].
exception := (PharoLinkRemoteError new
application: application;
command: commandFactory command;
trace: (res at: #value)).
exception signal
]
{ #category : #accessing }
@@ -66,6 +69,11 @@ GtCarpCoderModel >> computeAst: theSourceString [
parseWithErrors: theSourceString
]
{ #category : #accessing }
GtCarpCoderModel >> exception [
^ exception
]
{ #category : #accessing }
GtCarpCoderModel >> initializeAddOns: addOns [
super initializeAddOns: addOns.
@@ -113,36 +121,17 @@ GtCarpCoderModel >> pharoBindings: anObject [
{ #category : #accessing }
GtCarpCoderModel >> primitiveEvaluate: aSourceString inContext: aGtSourceCoderEvaluationContext onFailDo: anEvaluationFailBlock [
| result |
result := self bindAndExecute: aSourceString.
result associationsDo: [ :binding |
(pharoBindings bindingOf: binding key asSymbol) value: binding value ].
^ result
at: 'snippetResult'
ifAbsent: anEvaluationFailBlock
^ (CarpParser parse: (self bindAndExecute: aSourceString)) expressions first toPharo
]
{ #category : #accessing }
GtCarpCoderModel >> sourceFrom: trimmedSourceString returnedVarNames: varNames [
"Answer the modified source to return the declared variables"
^ String streamContents: [ :stream |
^ String
streamContents: [ :stream |
stream << trimmedSourceString.
stream
cr
<< '{ '.
varNames do: [ :varName |
stream
<< '(quote ';
<< varName;
<< ') ';
<< varName;
<< ' ' ].
"Answer the variable dictionary as an immediate object"
stream
<< '(quote carpLinkImmediate) true }' ]
stream lf << 'snippetResult' ]
]
{ #category : #accessing }

View File

@@ -12,7 +12,7 @@ LanguageLinkSettings class >> carpDefaultSettings [
serverProcessClass: CarpPythonProcess;
platform: CarpPlatform new;
commandFactoryClass: CarpCommandFactory;
commandClass: LanguageLinkCommand;
commandClass: CarpCommand;
serializerClass: LanguageLinkSerializer;
deserializerClass: CarpDeserializer;
parserClass: CarpParser;

View File

@@ -41,15 +41,16 @@ LeCarpApplicationStrategy >> newCarpApplicationFor: aLeDatabase [
{ #category : #accessing }
LeCarpApplicationStrategy >> updatedSettings: applicationCarpSettings [
"Update the supplied settings with the lepiter configuration"
| lepiterCarpSettings lepiterDatabase carpDir |
| lepiterCarpSettings lepiterDatabase carpDir |
lepiterDatabase := content database.
(lepiterDatabase isKindOf: LeNullDatabase)
ifTrue: [ ^ applicationCarpSettings ].
lepiterCarpSettings := lepiterDatabase properties carpLinkSettings.
lepiterCarpSettings directory ifNotNil:
[ :relativeDir |
lepiterCarpSettings directory
ifNotNil: [ :relativeDir |
carpDir := lepiterDatabase localStoreRootDirectory resolve: relativeDir.
applicationCarpSettings workingDirectory: carpDir ].
"lepiterCarpSettings carpPath ifNotNil:
applicationCarpSettings workingDirectory: carpDir ]. "lepiterCarpSettings carpPath ifNotNil:
[ :carpPath | applicationCarpSettings serverExecutable: carpPath ]."
applicationCarpSettings serverDebugMode: lepiterCarpSettings serverDebugMode.