Skip to content

Commit

Permalink
Initial implementation of default parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
lofcz committed Apr 7, 2022
1 parent 8f8c336 commit 0daf420
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class IndexExpression : Expression, IVariable
Expression m_BaseExp;
Expression m_IndexExp;
string m_Name;
private Token nameToken;
private bool inc;
private bool dec;
private bool nilCheck;
Expand Down Expand Up @@ -125,7 +124,7 @@ public void CompileAssignment(ByteCode bc, Operator op, int stackofs, int tuplei
{
if (isLength)
{
throw new SyntaxErrorException(nameToken, "Cannot assign to readonly property .length");
throw new SyntaxErrorException(null, "Cannot assign to readonly property .length");
}
if (op != Operator.NotAnOperator)
{
Expand Down
5 changes: 1 addition & 4 deletions src/MoonSharp.Interpreter/Tree/Lexer/Lexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -851,9 +851,7 @@ private Token ReadHashBang(int fromLine, int fromCol)
private Token ReadCMultilineComment(int fromLine, int fromCol)
{
StringBuilder text = new StringBuilder(32);

bool extraneousFound = false;


for (char c = CursorChar(); ; c = CursorCharNext())
{
if (c == '\r') continue;
Expand Down Expand Up @@ -894,7 +892,6 @@ private Token ReadComment(int fromLine, int fromCol)
}
else if (c == '\n')
{
extraneousFound = true;
CursorCharNext();
return CreateToken(TokenType.Comment, fromLine, fromCol, text.ToString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class FunctionDefinitionStatement : Statement
internal class FunctionParamRef
{
public string Name { get; set; }
public Expression? DefaultValue { get; set; }
public Expression DefaultValue { get; set; }

public FunctionParamRef(string name)
{
Name = name;
}

public FunctionParamRef(string name, Expression? defaultValue)
public FunctionParamRef(string name, Expression defaultValue)
{
Name = name;
DefaultValue = defaultValue;
Expand Down

0 comments on commit 0daf420

Please sign in to comment.