public override ParseResult VisitArrayLiteral(MelonParser.ArrayLiteralContext context) { parseContext.instructions.Add((int)OpCode.LDARR); instructionline++; var value = _engine.CreateArray(); for (int i = 0; i < context.array().expressionGroup().expression()?.Length; i++) { parseContext.instructions.Add((int)OpCode.DUP); instructionline++; var expressionResult = Visit(context.array().expressionGroup().expression(i)); value.SetValue(i, expressionResult.value); EmitLDINT(i); parseContext.instructions.Add((int)OpCode.STELEM); instructionline++; } return(new ParseResult { value = value, typeReference = new TypeReference(_engine, _engine.arrayType) }); }
private void LDARR(Context context) { context.Push(_engine.CreateArray(new MelonObject[0])); }