Skip to content

Commit 00e417d

Browse files
committed
#200 - rename
1 parent dd5e013 commit 00e417d

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/Application/HydraScript.Application.CodeGeneration/IValueFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public interface IValueFactory
88
{
99
public IValue Create(ValueDto dto);
1010

11-
public Name CreateName(IdentifierReference id);
11+
public Name Create(IdentifierReference id);
1212

13-
public Name CreateName(string id);
13+
public Name Create(string id);
1414
}

src/Application/HydraScript.Application.CodeGeneration/Impl/ValueFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public IValue Create(ValueDto dto) =>
2121
_ => throw new ArgumentOutOfRangeException(nameof(dto))
2222
};
2323

24-
public Name CreateName(IdentifierReference id)
24+
public Name Create(IdentifierReference id)
2525
{
2626
var dto = id.ToValueDto();
2727
return dto switch
@@ -34,7 +34,7 @@ public Name CreateName(IdentifierReference id)
3434
};
3535
}
3636

37-
public Name CreateName(string id) => new(id, CurrentFrame);
37+
public Name Create(string id) => new(id, CurrentFrame);
3838

3939
private CurrentFrame CurrentFrame { get; } = new(frameContext);
4040

src/Application/HydraScript.Application.CodeGeneration/Visitors/ExpressionInstructionProvider.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public AddressedInstructions Visit(ArrayLiteral visitable)
4747
{
4848
var arraySize = visitable.Expressions.Count;
4949

50-
var arrayName = _valueFactory.CreateName(visitable.Id);
50+
var arrayName = _valueFactory.Create(visitable.Id);
5151
var createArray = new CreateArray(arrayName, arraySize);
5252

5353
var result = new AddressedInstructions { createArray };
@@ -75,7 +75,7 @@ public AddressedInstructions Visit(ArrayLiteral visitable)
7575

7676
public AddressedInstructions Visit(ObjectLiteral visitable)
7777
{
78-
var objectId = _valueFactory.CreateName(visitable.Id);
78+
var objectId = _valueFactory.Create(visitable.Id);
7979
var createObject = new CreateObject(objectId);
8080

8181
var result = new AddressedInstructions { createObject };
@@ -90,7 +90,7 @@ public AddressedInstructions Visit(ObjectLiteral visitable)
9090

9191
public AddressedInstructions Visit(Property visitable)
9292
{
93-
var objectId = _valueFactory.CreateName(visitable.Object.Id);
93+
var objectId = _valueFactory.Create(visitable.Object.Id);
9494

9595
var (id, expression) = visitable;
9696
var propertyId = new Constant(id);
@@ -123,7 +123,7 @@ public AddressedInstructions Visit(UnaryExpression visitable)
123123
public AddressedInstructions Visit(BinaryExpression visitable)
124124
{
125125
if (visitable is { Left: IdentifierReference arr, Right: PrimaryExpression primary, Operator: "::" })
126-
return [new RemoveFromArray(_valueFactory.CreateName(arr), index: _valueFactory.Create(primary.ToValueDto()))];
126+
return [new RemoveFromArray(_valueFactory.Create(arr), index: _valueFactory.Create(primary.ToValueDto()))];
127127

128128
var result = new AddressedInstructions();
129129
IValue left, right;
@@ -172,7 +172,7 @@ public AddressedInstructions Visit(CastAsExpression visitable)
172172

173173
public AddressedInstructions Visit(WithExpression visitable)
174174
{
175-
var objectId = _valueFactory.CreateName(visitable.ObjectLiteral.Id);
175+
var objectId = _valueFactory.Create(visitable.ObjectLiteral.Id);
176176
var createObject = new CreateObject(objectId);
177177

178178
var result = new AddressedInstructions { createObject };
@@ -197,15 +197,15 @@ public AddressedInstructions Visit(WithExpression visitable)
197197
result.AddRange(visitable.Expression is PrimaryExpression ? [] : visitable.Expression.Accept(This));
198198

199199
var copyFrom = visitable.Expression is IdentifierReference objectIdent
200-
? _valueFactory.CreateName(objectIdent)
200+
? _valueFactory.Create(objectIdent)
201201
: result.OfType<Simple>().Last().Left!;
202202

203203
for (var i = 0; i < visitable.ComputedCopiedProperties.Count; i++)
204204
{
205205
var property = new Constant(visitable.ComputedCopiedProperties[i]);
206206
result.Add(new DotRead(copyFrom, property));
207207
var read = result[result.End].Address.Name;
208-
result.Add(new DotAssignment(objectId, property, _valueFactory.CreateName(read)));
208+
result.Add(new DotAssignment(objectId, property, _valueFactory.Create(read)));
209209
}
210210

211211
return result;
@@ -255,7 +255,7 @@ public AddressedInstructions Visit(AssignmentExpression visitable)
255255
}
256256

257257
if (visitable.Destination.Empty())
258-
result.OfType<Simple>().Last().Left = _valueFactory.CreateName(visitable.Destination.Id);
258+
result.OfType<Simple>().Last().Left = _valueFactory.Create(visitable.Destination.Id);
259259
else
260260
{
261261
var last = result.OfType<Simple>().Last().Left!;
@@ -277,7 +277,7 @@ public AddressedInstructions Visit(DotAccess visitable)
277277
var right = new Constant(visitable.Property.Name);
278278

279279
if (!visitable.HasPrev() && visitable.Parent is LeftHandSideExpression lhs)
280-
return [new DotRead(_valueFactory.CreateName(lhs.Id), right)];
280+
return [new DotRead(_valueFactory.Create(lhs.Id), right)];
281281

282282
var result = visitable.Prev?.Accept(This) ?? [];
283283
var left = result.OfType<Simple>().Last().Left!;
@@ -301,7 +301,7 @@ public AddressedInstructions Visit(IndexAccess visitable)
301301
}
302302

303303
if (!visitable.HasPrev() && visitable.Parent is LeftHandSideExpression lhs)
304-
result.Add(new IndexRead(_valueFactory.CreateName(lhs.Id), right));
304+
result.Add(new IndexRead(_valueFactory.Create(lhs.Id), right));
305305
else
306306
{
307307
result.AddRange(visitable.Prev?.Accept(This) ?? []);
@@ -332,7 +332,7 @@ public AddressedInstructions Visit(CallExpression visitable)
332332
{
333333
var caller = result.Count > 0
334334
? result.OfType<Simple>().Last().Left!
335-
: _valueFactory.CreateName(visitable.Id);
335+
: _valueFactory.Create(visitable.Id);
336336
result.Add(new PushParameter(caller));
337337
}
338338

src/Application/HydraScript.Application.CodeGeneration/Visitors/InstructionProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public AddressedInstructions Visit(FunctionDeclaration visitable)
133133
for (var i = 0; i < visitable.Arguments.Count; i++)
134134
{
135135
var arg = visitable.Arguments[i];
136-
result.Add(new PopParameter(_valueFactory.CreateName(arg.Name), arg.Info.Value));
136+
result.Add(new PopParameter(_valueFactory.Create(arg.Name), arg.Info.Value));
137137
}
138138

139139
result.AddRange(visitable.Statements.Accept(This));
@@ -238,11 +238,11 @@ public AddressedInstructions Visit(OutputStatement visitable)
238238
var valueDto = prim.ToValueDto();
239239
var printedValue = _valueFactory.Create(valueDto);
240240
IExecutableInstruction instruction = valueDto is { Type: ValueDtoType.Env } or { Type: ValueDtoType.Constant, Value: string }
241-
? new Print(printedValue)
241+
? new Output(printedValue)
242242
: new AsString(printedValue);
243243
AddressedInstructions shortResult = [instruction];
244244
if (instruction is AsString asString)
245-
shortResult.Add(new Print(asString.Left!));
245+
shortResult.Add(new Output(asString.Left!));
246246
return shortResult;
247247
}
248248

@@ -252,7 +252,7 @@ public AddressedInstructions Visit(OutputStatement visitable)
252252
var name = result.OfType<Simple>().Last().Left!;
253253
var nameAsString = new AsString(name);
254254
result.Add(nameAsString);
255-
result.Add(new Print(nameAsString.Left!));
255+
result.Add(new Output(nameAsString.Left!));
256256

257257
return result;
258258
}

0 commit comments

Comments
 (0)