Add some more language link code
This commit is contained in:
@@ -28,12 +28,12 @@ GtCarpCoderModel >> bindAndExecute: sourceString [
|
||||
| carpSource trimmedSource ast varNames lastStatement application commandFactory |
|
||||
|
||||
trimmedSource := SmaCCString on: sourceString trimRight.
|
||||
ast := JSParser parse: trimmedSource.
|
||||
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 items last.
|
||||
lastStatement := ast expressions last.
|
||||
trimmedSource
|
||||
insert: '(defdynamic snippetResult '
|
||||
at: lastStatement startPosition.
|
||||
@@ -108,6 +108,19 @@ GtCarpCoderModel >> pharoBindings: anObject [
|
||||
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
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
GtCarpCoderModel >> sourceFrom: trimmedSourceString returnedVarNames: varNames [
|
||||
"Answer the modified source to return the declared variables"
|
||||
|
Reference in New Issue
Block a user