Skip to content

Commit cacae5d

Browse files
committed
use Args array instead of splitting with delimiter
1 parent 0a9a81d commit cacae5d

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

kscr-compiler/KScr/Compiler/Code/ExpressionVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override StatementComponent VisitDeclaration(KScrParser.DeclarationContex
4040
{
4141
Type = StatementComponentType.Declaration,
4242
CodeType = context.expr() != null ? BytecodeType.Assignment : BytecodeType.Declaration,
43-
Arg = VisitTypeInfo(context.type()).FullDetailedName + ';' + context.idPart().GetText(),
43+
Args = { VisitTypeInfo(context.type()).FullDetailedName, context.idPart().GetText() },
4444
SubComponent = context.expr() is { } expr ? VisitExpression(expr) : null,
4545
SourcefilePosition = ToSrcPos(context)
4646
};

kscr-core/Bytecode/Statement.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ public virtual Stack Evaluate(RuntimeBase vm, Stack stack)
248248
break;
249249
case (StatementComponentType.Declaration, _):
250250
// variable declaration
251-
var split = Arg.Split(';');
252-
stack[Default] = vm[stack, VariableContext, split[1]] = new ObjectRef(vm.FindType(split[0])!);
251+
stack[Default] = vm[stack, VariableContext, Args[1]] = new ObjectRef(vm.FindType(Args[0])!);
253252
if (CodeType == BytecodeType.Assignment)
254253
{
255254
SubComponent!.Evaluate(vm, stack.Output()).Copy(Alp, Bet);

0 commit comments

Comments
 (0)