...
This commit is contained in:
@@ -494,12 +494,12 @@ public static class QBEGenerator
|
||||
case StatementExpressionNode statementExpression:
|
||||
GenerateExpression(statementExpression.Expression);
|
||||
break;
|
||||
case VariableAssignmentNode variableAssignment:
|
||||
GenerateVariableAssignment(variableAssignment);
|
||||
break;
|
||||
case VariableDeclarationNode variableDeclaration:
|
||||
GenerateVariableDeclaration(variableDeclaration);
|
||||
break;
|
||||
case VariableAssignmentNode variableAssignment:
|
||||
GenerateVariableAssignment(variableAssignment);
|
||||
break;
|
||||
case WhileNode whileStatement:
|
||||
GenerateWhile(whileStatement);
|
||||
break;
|
||||
@@ -762,26 +762,26 @@ public static class QBEGenerator
|
||||
|
||||
private static void GenerateArrayBoundsCheck(string array, string index)
|
||||
{
|
||||
// var countName = VarName();
|
||||
// _builder.AppendLine($" {countName} =l loadl {array}");
|
||||
//
|
||||
// var isNegativeName = VarName();
|
||||
// _builder.AppendLine($" {isNegativeName} =w csltl {index}, 0");
|
||||
//
|
||||
// var isOobName = VarName();
|
||||
// _builder.AppendLine($" {isOobName} =w csgel {index}, {countName}");
|
||||
//
|
||||
// var anyOobName = VarName();
|
||||
// _builder.AppendLine($" {anyOobName} =w or {isNegativeName}, {isOobName}");
|
||||
//
|
||||
// var oobLabel = LabelName();
|
||||
// var notOobLabel = LabelName();
|
||||
// _builder.AppendLine($" jnz {anyOobName}, {oobLabel}, {notOobLabel}");
|
||||
//
|
||||
// _builder.AppendLine(oobLabel);
|
||||
// _builder.AppendLine($" call $nub_panic_array_oob()");
|
||||
//
|
||||
// _builder.AppendLine(notOobLabel);
|
||||
var countName = VarName();
|
||||
_builder.AppendLine($" {countName} =l loadl {array}");
|
||||
|
||||
var isNegativeName = VarName();
|
||||
_builder.AppendLine($" {isNegativeName} =w csltl {index}, 0");
|
||||
|
||||
var isOobName = VarName();
|
||||
_builder.AppendLine($" {isOobName} =w csgel {index}, {countName}");
|
||||
|
||||
var anyOobName = VarName();
|
||||
_builder.AppendLine($" {anyOobName} =w or {isNegativeName}, {isOobName}");
|
||||
|
||||
var oobLabel = LabelName();
|
||||
var notOobLabel = LabelName();
|
||||
_builder.AppendLine($" jnz {anyOobName}, {oobLabel}, {notOobLabel}");
|
||||
|
||||
_builder.AppendLine(oobLabel);
|
||||
_builder.AppendLine($" call $nub_panic_array_oob()");
|
||||
|
||||
_builder.AppendLine(notOobLabel);
|
||||
}
|
||||
|
||||
private static string GenerateArrayInitializer(ArrayInitializerNode arrayInitializer)
|
||||
@@ -1199,19 +1199,12 @@ public static class QBEGenerator
|
||||
var item = GenerateExpression(memberAccess.Expression);
|
||||
switch (memberAccess.Expression.Type)
|
||||
{
|
||||
case NubArrayType arrayType:
|
||||
case NubArrayType:
|
||||
{
|
||||
if (memberAccess.Member == "count")
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
if (arrayType.ElementType is NubPrimitiveType { Kind: PrimitiveTypeKind.U8 } && memberAccess.Member == "cstring")
|
||||
{
|
||||
var result = VarName();
|
||||
_builder.AppendLine($" {result} =l call $nub_string_to_cstring(l {item})");
|
||||
return result;
|
||||
}
|
||||
|
||||
throw new UnreachableException(nameof(memberAccess.Member));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user