@@ -25,7 +25,8 @@ class Context {
2525 }
2626
2727 newChildContext ( props ) {
28- return new Context ( { ...this , ...props , parent : this , locals : new Map ( ) } ) ;
28+
29+ return new Context ( { ...this , ...props , parent : this , locals : this . locals } ) ;
2930 }
3031}
3132
@@ -86,9 +87,9 @@ export default function analyze(match) {
8687
8788 FuncDef (
8889 id ,
89- open ,
90+ _open ,
9091 param ,
91- close ,
92+ _close ,
9293 _eq ,
9394 _newLine ,
9495 body ,
@@ -99,16 +100,17 @@ export default function analyze(match) {
99100 // Temporary check inside the function.
100101 const originalContext = context ;
101102 context = context . newChildContext ( ) ;
103+ context . add ( id . sourceString , {
104+ kind : "Function" ,
105+ type : core . functionType ,
106+ name : id . sourceString ,
107+ } ) ;
102108 context . add ( param . sourceString , {
103109 kind : "MutableRange" ,
104110 type : core . numberType ,
105111 name : param . sourceString ,
106112 } ) ;
107- const functionId =
108- id . sourceString +
109- open . sourceString +
110- param . sourceString +
111- close . sourceString ;
113+ const functionId = `${ id . sourceString } (${ param . sourceString } )` ;
112114 context . add ( functionId , {
113115 kind : "Function" ,
114116 type : core . functionType ,
@@ -117,7 +119,7 @@ export default function analyze(match) {
117119 const analyzedBody = body ?. rep ( ) ;
118120 // Checks outside of the function definition.
119121 context = originalContext ;
120- context . add ( functionId , {
122+ context . add ( id . sourceString , {
121123 kind : "Function" ,
122124 type : core . functionType ,
123125 name : functionId ,
@@ -136,20 +138,15 @@ export default function analyze(match) {
136138 return func ;
137139 } ,
138140
139- FuncCall ( id , open , arg , close ) {
140- const functionId =
141- id . sourceString +
142- open . sourceString +
143- arg . sourceString +
144- close . sourceString ;
145- const func = context . lookup ( functionId ) ;
141+ FuncCall ( id , _open , arg , _close ) {
142+ const func = context . lookup ( id . sourceString ) ;
146143 mustHaveBeenFound ( func , id . sourceString , { at : id } ) ;
147- return core . funcCall ( id . sourceString , arg . sourceString ) ;
144+ return core . funcCall ( id . sourceString , arg . rep ( ) ) ;
148145 } ,
149146
150- FunctionGroup ( _open , expr , _close ) {
151- return core . functionGroup ( expr . rep ( ) ) ;
152- } ,
147+ // FunctionGroup(_open, expr, _close) {
148+ // return core.functionGroup(expr.rep());
149+ // },
153150
154151 Expr ( condExpr , _sep , _newLine , rest ) {
155152 return core . expr (
@@ -239,7 +236,7 @@ export default function analyze(match) {
239236
240237 MulExpr_mul ( left , right ) {
241238 const l = left . rep ( ) ;
242- const r = right . sourceString ;
239+ const r = right . rep ( ) ;
243240 return core . mulExpr ( l , "*" , r ) ;
244241 } ,
245242
@@ -283,10 +280,10 @@ export default function analyze(match) {
283280 return core . printStmt ( expr . rep ( ) ) ;
284281 } ,
285282
286- StepCall ( expr , _dot , _step , _open , stepValue , _close ) {
283+ StepCall ( id , _open , arg , _close , _dot , _step , _open1 , stepValue , _close1 ) {
287284 // Syntax Sugar: Default step count is 1.
288285 return core . stepCall (
289- expr . rep ( ) ,
286+ { name : id . sourceString , arg : arg . sourceString } ,
290287 stepValue . rep ( ) . length ? stepValue . rep ( ) [ 0 ] . value : 1
291288 ) ;
292289 } ,
@@ -325,8 +322,8 @@ export default function analyze(match) {
325322 num ( sign , value , _period , decimal ) {
326323 const number = Number (
327324 sign . sourceString +
328- value . sourceString +
329- decimal . sourceString
325+ value . sourceString +
326+ decimal . sourceString
330327 ) ;
331328 return core . num ( number ) ;
332329 } ,
@@ -343,7 +340,7 @@ export default function analyze(match) {
343340 const idName = firstChar . sourceString + name ?. sourceString ;
344341 const entity = context . lookup ( idName ) ;
345342 mustHaveBeenFound ( entity , idName , { at : name } ) ;
346- return core . id ( firstChar . sourceString + name ?. sourceString ) ;
343+ return core . id ( idName ) ;
347344 } ,
348345
349346 _terminal ( ...children ) {
0 commit comments