From 199a11e980251b9ad9ad369f3c810ccb04c5feb5 Mon Sep 17 00:00:00 2001 From: Randy Hollines Date: Fri, 7 Feb 2025 13:19:21 -0700 Subject: [PATCH] working on issue #510 --- core/compiler/context.cpp | 1 + core/compiler/emit.cpp | 4 ---- core/compiler/intermediate.cpp | 3 +-- programs/tests/prgm333.obs | 5 +++-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/core/compiler/context.cpp b/core/compiler/context.cpp index a0b3e7921..2526ab6ef 100644 --- a/core/compiler/context.cpp +++ b/core/compiler/context.cpp @@ -2643,6 +2643,7 @@ void ContextAnalyzer::AnalyzeNewArrayCall(MethodCall* method_call, const int dep if(expressions.size() == 0) { ProcessError(static_cast(method_call), L"Empty array index"); } + // TODO: check for dimension size of 1, looking at type else if(expressions.size() == 1 && expressions[0]->GetExpressionType() == VAR_EXPR && expressions[0]->GetEvalType() && expressions[0]->GetEvalType()->GetDimension() ) { diff --git a/core/compiler/emit.cpp b/core/compiler/emit.cpp index 2bae4bfb5..8423ae6a8 100644 --- a/core/compiler/emit.cpp +++ b/core/compiler/emit.cpp @@ -164,8 +164,6 @@ void IntermediateProgram::Write(bool emit_lib, bool is_debug, OutputStream& out_ } } - - // write byte strings WriteInt((int)byte_strings.size(), out_stream); for(size_t i = 0; i < byte_strings.size(); ++i) { @@ -176,8 +174,6 @@ void IntermediateProgram::Write(bool emit_lib, bool is_debug, OutputStream& out_ } } - - // write int strings WriteInt((int)int_strings.size(), out_stream); for(size_t i = 0; i < int_strings.size(); ++i) { diff --git a/core/compiler/intermediate.cpp b/core/compiler/intermediate.cpp index 51f1c6a2e..61645b91d 100644 --- a/core/compiler/intermediate.cpp +++ b/core/compiler/intermediate.cpp @@ -249,8 +249,7 @@ void IntermediateEmitter::Translate() Class* start_class = parsed_program->GetStartClass(); Method* start_method = parsed_program->GetStartMethod(); - imm_program->SetStartIds((start_class ? start_class->GetId() : -1), - (start_method ? start_method->GetId() : -1)); + imm_program->SetStartIds((start_class ? start_class->GetId() : -1), (start_method ? start_method->GetId() : -1)); #ifdef _DEBUG assert(break_labels.empty()); diff --git a/programs/tests/prgm333.obs b/programs/tests/prgm333.obs index 2aed5452c..adb410576 100644 --- a/programs/tests/prgm333.obs +++ b/programs/tests/prgm333.obs @@ -1,11 +1,12 @@ class Test { function : Main(args : String[]) ~ Nil { - a := [1, 2, 3]->As(Byte[]); + a := [1, 2, 3]->As(Int[]); # a := [1.1, 2.2, 3.3]; # b := a->Copy(); - b : Byte[] := a->Copy(); +# b : Byte[] := a->Copy(); + b := Int->New[a]; b[2]->PrintLine(); b->Size()->PrintLine();