Ejemplo n.º 1
0
 public void AddArgument(LuaExpressionSyntax argument)
 {
     ArgumentList.AddArgument(argument);
 }
 public LuaLocalVariableDeclaratorSyntax(LuaIdentifierNameSyntax identifier, LuaExpressionSyntax expression = null)
 {
     Declarator = new LuaVariableDeclaratorSyntax(identifier, expression);
 }
Ejemplo n.º 3
0
 public LuaInvocationExpressionSyntax(LuaExpressionSyntax expression, LuaExpressionSyntax argument) : this(expression) {
     AddArgument(argument);
 }
Ejemplo n.º 4
0
 internal void Add(LuaIdentifierNameSyntax key, LuaExpressionSyntax value)
 {
     Items.Add(new LuaKeyValueTableItemSyntax(key, value));
 }
Ejemplo n.º 5
0
 public LuaSingleTableItemSyntax(LuaExpressionSyntax expression)
 {
     Expression = expression ?? throw new ArgumentNullException(nameof(expression));
 }
Ejemplo n.º 6
0
 public void Update(LuaExpressionSyntax expression, bool isObjectColon)
 {
     Contract.Assert(Expression == null);
     Expression    = expression;
     OperatorToken = isObjectColon ? Tokens.ObjectColon : Tokens.Dot;
 }
Ejemplo n.º 7
0
 public LuaKeyValueTableItemSyntax(LuaIdentifierNameSyntax key, LuaExpressionSyntax value) : this(new LuaTableLiteralKeySyntax(key), value)
 {
 }
Ejemplo n.º 8
0
 private void AddInitFiled(LuaIdentifierNameSyntax name, LuaExpressionSyntax value)
 {
     initStatements_.Add(LuaIdentifierNameSyntax.This.MemberAccess(name).Assignment(value));
 }
Ejemplo n.º 9
0
 public void AddField(LuaIdentifierNameSyntax name, LuaExpressionSyntax value, bool isImmutable, bool isStatic, bool isPrivate, bool isReadOnly, List <LuaStatementSyntax> statements)
 {
     if (isStatic)
     {
         if (isPrivate)
         {
             local_.Variables.Add(name);
             if (value != null)
             {
                 var assignment = name.Assignment(value);
                 if (isImmutable)
                 {
                     methodList_.Statements.Add(assignment);
                 }
                 else
                 {
                     if (statements != null)
                     {
                         staticInitStatements_.AddRange(statements);
                     }
                     staticInitStatements_.Add(assignment);
                 }
             }
         }
         else
         {
             if (isReadOnly)
             {
                 local_.Variables.Add(name);
                 if (value != null)
                 {
                     var assignment = name.Assignment(value);
                     if (isImmutable)
                     {
                         methodList_.Statements.Add(assignment);
                         AddResultTable(name);
                     }
                     else
                     {
                         if (statements != null)
                         {
                             staticInitStatements_.AddRange(statements);
                         }
                         staticInitStatements_.Add(assignment);
                         staticInitStatements_.Add(LuaIdentifierNameSyntax.This.MemberAccess(name).Assignment(name));
                     }
                 }
             }
             else
             {
                 if (value != null)
                 {
                     if (isImmutable)
                     {
                         AddResultTable(name, value);
                     }
                     else
                     {
                         if (statements != null)
                         {
                             staticInitStatements_.AddRange(statements);
                         }
                         staticInitStatements_.Add(LuaIdentifierNameSyntax.This.MemberAccess(name).Assignment(value));
                     }
                 }
             }
         }
     }
     else
     {
         if (value != null)
         {
             if (isImmutable)
             {
                 AddResultTable(name, value);
             }
             else
             {
                 if (statements != null)
                 {
                     initStatements_.AddRange(statements);
                 }
                 AddInitFiled(name, value);
             }
         }
     }
 }
Ejemplo n.º 10
0
 public LuaElseIfStatementSyntax(LuaExpressionSyntax condition)
 {
     Condition = condition ?? throw new ArgumentNullException(nameof(condition));;
 }
Ejemplo n.º 11
0
 private void AddResultTable(LuaIdentifierNameSyntax name, LuaExpressionSyntax value)
 {
     AddResultTable(new LuaKeyValueTableItemSyntax(name, value));
 }
 public void Update(string newName)
 {
     NameExpression = newName;
 }
 public LuaSymbolNameSyntax(LuaExpressionSyntax identifierName) : base("")
 {
     NameExpression = identifierName;
 }
Ejemplo n.º 14
0
 private void AddImport(LuaIdentifierNameSyntax name, LuaExpressionSyntax value)
 {
     importAreaStatements.Statements.Add(new LuaLocalVariableDeclaratorSyntax(name, value));
 }
Ejemplo n.º 15
0
 public LuaBinaryExpressionSyntax(LuaExpressionSyntax left, string operatorToken, LuaExpressionSyntax right)
 {
     Left          = left ?? throw new ArgumentNullException(nameof(left));
     OperatorToken = operatorToken;
     Right         = right ?? throw new ArgumentNullException(nameof(right));
 }
Ejemplo n.º 16
0
        private (LuaPropertyOrEventIdentifierNameSyntax, LuaPropertyOrEventIdentifierNameSyntax) AddPropertyOrEvent(bool isProperty, LuaIdentifierNameSyntax name, LuaIdentifierNameSyntax innerName, LuaExpressionSyntax value, bool isImmutable, bool isStatic, bool isPrivate, LuaExpressionSyntax typeExpression, List <LuaStatementSyntax> statements)
        {
            LuaPropertyOrEventIdentifierNameSyntax get, set;

            if (isProperty)
            {
                get = new LuaPropertyOrEventIdentifierNameSyntax(true, true, name);
                set = new LuaPropertyOrEventIdentifierNameSyntax(true, false, name);
            }
            else
            {
                get = new LuaPropertyOrEventIdentifierNameSyntax(false, true, name);
                set = new LuaPropertyOrEventIdentifierNameSyntax(false, false, name);
            }

            local_.Variables.Add(get);
            local_.Variables.Add(set);
            if (!isStatic)
            {
                var initMethodIdentifier = isProperty ? LuaIdentifierNameSyntax.Property : LuaIdentifierNameSyntax.Event;
                var assignment           = new LuaMultipleAssignmentExpressionSyntax();
                assignment.Lefts.Add(get);
                assignment.Lefts.Add(set);
                var invocation = new LuaInvocationExpressionSyntax(initMethodIdentifier);
                invocation.AddArgument(new LuaStringLiteralExpressionSyntax(innerName));
                assignment.Rights.Add(invocation);
                methodList_.Statements.Add(assignment);
            }
            else
            {
                var memberAccess = typeExpression.MemberAccess(innerName);
                var getFunction  = new LuaFunctionExpressionSyntax();
                var setFunction  = new LuaFunctionExpressionSyntax();
                if (isProperty)
                {
                    getFunction.AddStatement(new LuaReturnStatementSyntax(memberAccess));
                    setFunction.AddParameter(LuaIdentifierNameSyntax.Value);
                    setFunction.AddStatement(memberAccess.Assignment(LuaIdentifierNameSyntax.Value));
                }
                else
                {
                    getFunction.AddParameter(LuaIdentifierNameSyntax.Value);
                    var getAssignment = memberAccess.Assignment(memberAccess.Binary(Tokens.Plus, LuaIdentifierNameSyntax.Value));
                    getFunction.AddStatement(getAssignment);
                    setFunction.AddParameter(LuaIdentifierNameSyntax.Value);
                    var setAssignment = memberAccess.Assignment(memberAccess.Binary(Tokens.Sub, LuaIdentifierNameSyntax.Value));
                    setFunction.AddStatement(setAssignment);
                }
                methodList_.Statements.Add(get.Assignment(getFunction));
                methodList_.Statements.Add(set.Assignment(setFunction));
            }

            if (value != null)
            {
                if (isStatic)
                {
                    if (isImmutable)
                    {
                        AddResultTable(innerName, value);
                    }
                    else
                    {
                        if (statements != null)
                        {
                            staticInitStatements_.AddRange(statements);
                        }
                        staticInitStatements_.Add(LuaIdentifierNameSyntax.This.MemberAccess(innerName).Assignment(value));
                    }
                }
                else
                {
                    if (isImmutable)
                    {
                        AddResultTable(innerName, value);
                    }
                    else
                    {
                        if (statements != null)
                        {
                            initStatements_.AddRange(statements);
                        }
                        AddInitFiled(innerName, value);
                    }
                }
            }

            if (!isPrivate)
            {
                AddResultTable(get);
                AddResultTable(set);
            }

            return(get, set);
        }
Ejemplo n.º 17
0
 public LuaPropertyAdapterExpressionSyntax(LuaExpressionSyntax expression, LuaPropertyOrEventIdentifierNameSyntax name, bool isObjectColon)
 {
     Update(expression, isObjectColon);
     Name = name;
 }
Ejemplo n.º 18
0
 public (LuaPropertyOrEventIdentifierNameSyntax, LuaPropertyOrEventIdentifierNameSyntax) AddEvent(LuaIdentifierNameSyntax name, LuaIdentifierNameSyntax innerName, LuaExpressionSyntax value, bool isImmutable, bool isStatic, bool isPrivate, LuaExpressionSyntax typeExpression, List <LuaStatementSyntax> statements)
 {
     return(AddPropertyOrEvent(false, name, innerName, value, isImmutable, isStatic, isPrivate, typeExpression, statements));
 }
Ejemplo n.º 19
0
 public LuaKeyValueTableItemSyntax(LuaTableKeySyntax key, LuaExpressionSyntax value)
 {
     Key   = key;
     Value = value;
 }
Ejemplo n.º 20
0
 public LuaPrefixUnaryExpressionSyntax(LuaExpressionSyntax operand, string operatorToken)
 {
     Operand       = operand ?? throw new ArgumentNullException(nameof(operand));
     OperatorToken = operatorToken;
 }
Ejemplo n.º 21
0
 public LuaTableIndexAccessExpressionSyntax(LuaExpressionSyntax expression, LuaExpressionSyntax index)
 {
     Expression = expression ?? throw new ArgumentNullException(nameof(expression));
     Index      = index ?? throw new ArgumentNullException(nameof(index));
 }
Ejemplo n.º 22
0
 public LuaParenthesizedExpressionSyntax(LuaExpressionSyntax expression)
 {
     Expression = expression ?? throw new ArgumentNullException(nameof(expression));
 }
Ejemplo n.º 23
0
 internal void Add(LuaExpressionSyntax value)
 {
     Items.Add(new LuaSingleTableItemSyntax(value));
 }
Ejemplo n.º 24
0
 public LuaArrayTypeAdapterExpressionSyntax(LuaExpressionSyntax typeExpression, LuaArrayRankSpecifierSyntax rankSpecifier)
 {
     TypeExpression = typeExpression ?? throw new ArgumentNullException(nameof(typeExpression));
     RankSpecifier  = rankSpecifier ?? throw new ArgumentNullException(nameof(rankSpecifier));
 }
Ejemplo n.º 25
0
 public LuaTableExpressionKeySyntax(LuaExpressionSyntax expression)
 {
     Expression = expression ?? throw new ArgumentNullException(nameof(expression));
 }
Ejemplo n.º 26
0
 public LuaInternalMethodExpressionSyntax(LuaExpressionSyntax expression)
 {
     Expression = expression ?? throw new ArgumentNullException(nameof(expression));
 }
 public LuaEqualsValueClauseSyntax(LuaExpressionSyntax value)
 {
     Value = value ?? throw new ArgumentNullException(nameof(value));
 }
Ejemplo n.º 28
0
 public LuaAssignmentExpressionSyntax(LuaExpressionSyntax left, LuaExpressionSyntax right)
 {
     Left  = left ?? throw new ArgumentNullException(nameof(left));
     Right = right ?? throw new ArgumentNullException(nameof(right));
 }
Ejemplo n.º 29
0
 public LuaInvocationExpressionSyntax(LuaExpressionSyntax expression, LuaExpressionSyntax argument1, LuaExpressionSyntax argument2, LuaExpressionSyntax argument3) : this(expression) {
     AddArgument(argument1);
     AddArgument(argument2);
     AddArgument(argument3);
 }
Ejemplo n.º 30
0
 public LuaInvocationExpressionSyntax(LuaExpressionSyntax expression, params LuaExpressionSyntax[] arguments) : this(expression) {
     AddArguments(arguments);
 }