Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wixoaGit committed Nov 15, 2024
1 parent 3b59466 commit 3bee946
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions DMCompiler/DM/Builders/DMExpressionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private DMExpression BuildExpression(DMASTExpression expression, DreamPath? infe

switch (expression) {
case DMASTInvalidExpression:
// No Compiler.Emit() here because the parser should have emitted an error when making this
// No error emission here because the parser should have emitted an error when making this
return new BadExpression(expression.Location);

case DMASTExpressionConstant constant: result = BuildConstant(constant); break;
Expand Down Expand Up @@ -640,7 +640,7 @@ private DMExpression BuildScopeIdentifier(DMASTScopeIdentifier scopeIdentifier,

DMExpression? expression;

// "type" and "parent_type" cannot resolve in a context, but it's still valid with scope identifiers
// "type" and "parent_type" cannot resolve in a static context, but it's still valid with scope identifiers
if (scopeIdentifier.Expression is DMASTIdentifier { Identifier: "type" or "parent_type" } identifier) {
// This is the same behaviour as in BYOND, but BYOND simply raises an undefined var error.
// We want to give end users an explanation at least.
Expand Down Expand Up @@ -691,7 +691,7 @@ private DMExpression BuildScopeIdentifier(DMASTScopeIdentifier scopeIdentifier,
} else { // A::B
var globalVarId = owner.GetGlobalVariableId(bIdentifier);
if (globalVarId != null) {
// B is a var.
// B is a static var.
// This is the only case a ScopeIdentifier can be an LValue.
var globalVar = ObjectTree.Globals [globalVarId.Value];
return new GlobalField(location, globalVar.Type, globalVarId.Value, globalVar.ValType);
Expand Down Expand Up @@ -944,7 +944,7 @@ private DMExpression BuildDereference(DMASTDereference deref, DreamPath? inferre

property = fromObject.GetVariable(field);
if (!fieldOperation.Safe && fromObject.IsSubtypeOf(DreamPath.Client)) {
Compiler.Emit(WarningCode.UnsafeClientAccess, deref.Location,
Compiler.Emit(WarningCode.UnsafeClientAccess, deref.Location,
"Unsafe \"client\" access. Use the \"?.\" operator instead");
}

Expand Down Expand Up @@ -1121,7 +1121,7 @@ private DMExpression BuildAddText(DMASTAddText addText, DreamPath? inferredPath)
for (int i = 0; i < expArr.Length; i++) {
DMASTCallParameter parameter = addText.Parameters[i];
if(parameter.Key != null)
Compiler.Emit(WarningCode.InvalidArgumentKey, parameter.Location, "addtext() does not take named arguments");
Compiler.Emit(WarningCode.InvalidArgumentKey, parameter.Location, "addtext() does not take named arguments");

expArr[i] = BuildExpression(parameter.Value, inferredPath);
}
Expand Down Expand Up @@ -1152,7 +1152,7 @@ private DMExpression BuildInput(DMASTInput input) {
// Default filter is "as anything" when there's a list
input.Types ??= DMValueType.Anything;
if (input.Types != DMValueType.Anything && (input.Types & objectTypes) == 0x0) {
Compiler.Emit(WarningCode.BadArgument, input.Location,
Compiler.Emit(WarningCode.BadArgument, input.Location,
$"Invalid input() filter \"{input.Types}\". Filter must be \"{DMValueType.Anything}\" or at least one of \"{objectTypes}\"");
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion DMCompiler/DM/DMExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ internal sealed class ArgumentList(Location location, (string? Name, DMExpressio
}

private void VerifyArgType(DMCompiler compiler, DMProc targetProc, int index, string? name, DMExpression expr) {
// TODO: See if the typechecking can be improved
// TODO: See if the static typechecking can be improved
// Also right now we don't care if the arg is Anything
// TODO: Make a separate "UnsetStaticType" pragma for whether we should care if it's Anything
// TODO: We currently silently avoid typechecking "call()()" and "new" args (NewPath is handled)
Expand Down
10 changes: 5 additions & 5 deletions DMCompiler/DM/Expressions/Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override void EmitPushValue(ExpressionContext ctx) {

public override bool IsTruthy() => false;

public override bool TryAsJsonRepresentation(DMCompiler compiler1, out object? json) {
public override bool TryAsJsonRepresentation(DMCompiler compiler, out object? json) {
json = null;
return true;
}
Expand Down Expand Up @@ -80,7 +80,7 @@ public override void EmitPushValue(ExpressionContext ctx) {

public override bool IsTruthy() => Value.Length != 0;

public override bool TryAsJsonRepresentation(DMCompiler compiler1, out object? json) {
public override bool TryAsJsonRepresentation(DMCompiler compiler, out object? json) {
json = Value;
return true;
}
Expand Down Expand Up @@ -240,7 +240,7 @@ public override void EmitPushValue(ExpressionContext ctx) {

public override bool IsTruthy() => true;

public override bool TryAsJsonRepresentation(DMCompiler compiler1, out object? json) {
public override bool TryAsJsonRepresentation(DMCompiler compiler, out object? json) {
json = new Dictionary<string, object> {
{ "type", JsonVariableType.Type },
{ "value", Value.Id }
Expand All @@ -267,7 +267,7 @@ public override void EmitPushValue(ExpressionContext ctx) {

public override bool IsTruthy() => true;

public override bool TryAsJsonRepresentation(DMCompiler compiler1, out object? json) {
public override bool TryAsJsonRepresentation(DMCompiler compiler, out object? json) {
json = new Dictionary<string, object> {
{ "type", JsonVariableType.Proc },
{ "value", Value.Id }
Expand All @@ -294,7 +294,7 @@ public override void EmitPushValue(ExpressionContext ctx) {

public override bool IsTruthy() => true;

public override bool TryAsJsonRepresentation(DMCompiler compiler1, out object? json) {
public override bool TryAsJsonRepresentation(DMCompiler compiler, out object? json) {
json = _str;
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion DMCompiler/DMCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public bool Compile(DMCompilerSettings settings) {
ForcedWarning("Unimplemented proc & var warnings are currently suppressed");
}

DMPreprocessor preprocessor = Preprocess( this, settings.Files, settings.MacroDefines);
DMPreprocessor preprocessor = Preprocess(this, settings.Files, settings.MacroDefines);

Check warning

Code scanning / InspectCode

Converting null literal or possible null value to non-nullable type. Warning

Converting null literal or possible null value into non-nullable type

Check warning

Code scanning / InspectCode

Possible null reference argument for a parameter. Warning

Possible null reference argument for parameter 'files' in 'DMCompiler.DMCompiler.Preprocess'
bool successfulCompile = preprocessor is not null && Compile(preprocessor);

if (successfulCompile) {
Expand Down

0 comments on commit 3bee946

Please sign in to comment.