コード例 #1
0
            public static MainFunc Find(string str)
            {
                Match match = Is.MatchesAll(str);

                if (match == null)
                {
                    return(null);
                }

                var returnIntOrVoid = new MemberName("int");

                if (match.Groups["MainFunc_returnInt"].ToString() == "")
                {
                    returnIntOrVoid = new MemberName("void");
                }

                var statements = Statements.Find(match.Groups["MainFunc_statements"].ToString());

                if (statements == null)
                {
                    return(null);
                }

                return(new MainFunc
                {
                    returnIntOrVoid = returnIntOrVoid,
                    _statements = statements,
                    argsName = new LocalVaribleName(match.Groups["MainFunc_argsName"].ToString())
                });
            }
コード例 #2
0
 /// <devdoc>
 ///    <para>
 ///       Initializes a new instance of <see cref='System.CodeDom.CodeIterationStatement'/>.
 ///    </para>
 /// </devdoc>
 public CodeIterationStatement(CodeStatement initStatement, CodeExpression testExpression, CodeStatement incrementStatement, params CodeStatement[] statements)
 {
     InitStatement      = initStatement;
     TestExpression     = testExpression;
     IncrementStatement = incrementStatement;
     Statements.AddRange(statements);
 }
コード例 #3
0
ファイル: EditorComponent.cs プロジェクト: fremag/nats-ui
        private void OnItemClicked(string colName, ScriptStatement command)
        {
            int index = ScriptService.Current.Statements.IndexOf(command);

            switch (colName)
            {
            case nameof(ScriptStatement.Insert):
                Logger.Debug($"Insert ! {index}");
                var scriptStatement = new ScriptStatement();
                Statements.Insert(index + 1, scriptStatement);
                ScriptService.Current.Insert(index + 1, scriptStatement);
                break;

            case nameof(ScriptStatement.Up):
                Logger.Debug($"Up ! {index}");
                Statements.Swap(index, index - 1);
                ScriptService.Current.Swap(index, index - 1);
                break;

            case nameof(ScriptStatement.Down):
                Logger.Debug($"Down !  {index}");
                Statements.Swap(index, index + 1);
                ScriptService.Current.Swap(index, index + 1);
                break;

            case nameof(ScriptStatement.Trash):
                Logger.Debug($"Trash !  {index}");
                Statements.Remove(index);
                ScriptService.Current.Remove(index);
                break;
            }
        }
コード例 #4
0
        public IEnumerable <ICodeGeneratable> GetRepositories()
        {
            var isAsync     = IsFunctionAsync();
            var arrowClause = Statements.Count > 1 ? null
                : Statements.First();

            if (arrowClause != null && arrowClause.StartsWith("return "))
            {
                arrowClause = arrowClause.Replace("return ", string.Empty);
            }
            var block   = arrowClause != null ? null : Statements;
            var names   = GetTypeAndMethodNames();
            var methods = new List <Method>
            {
                new Method
                {
                    ArrowClauseExpression = arrowClause,
                    Block     = block,
                    Comment   = Description,
                    Modifiers = isAsync
                        ? "public static async"
                        : "public static",
                    Name           = names.Last(),
                    Parameters     = Parameters,
                    Type           = ReturnType,
                    TypeParameters = TypeParameters
                }
            };

            yield return(new StaticFunction(
                             Name, names.First(), Description, Version, EnvironmentVariables, PackageReferences, SameAccountDependencies, fields: Fields, methods: methods, usingDirectives: UsingDirectives, usingStaticDirectives: UsingStaticDirectives));
        }
コード例 #5
0
ファイル: JSStatementTypes.cs プロジェクト: carcer/JSIL
 public JSForLoop(JSStatement initializer, JSExpression condition, JSStatement increment, params JSStatement[] body)
 {
     _Initializer = initializer;
     _Condition   = condition;
     _Increment   = increment;
     Statements.AddRange(body);
 }
コード例 #6
0
ファイル: CaseExpression.cs プロジェクト: TerabyteX/main
 public CaseExpression(Expression value, WhenClause/*!*/[] whenClauses, Statements elseStatements, SourceSpan location)
     : base(location)
 {
     _value = value;
     _whenClauses = whenClauses ?? WhenClause.EmptyArray;
     _elseStatements = elseStatements;
 }
コード例 #7
0
ファイル: Player.cs プロジェクト: mileskav/TBGame
        public void UpdateInventoryCategories()
        {
            Consumables.Clear();
            Weapons.Clear();
            KeyItems.Clear();
            Statements.Clear();

            foreach (var gameItemQuantity in _inventory)
            {
                if (gameItemQuantity.GameItem is Consumable)
                {
                    Consumables.Add(gameItemQuantity);
                }
                if (gameItemQuantity.GameItem is Weapon)
                {
                    Weapons.Add(gameItemQuantity);
                }
                if (gameItemQuantity.GameItem is KeyItem)
                {
                    KeyItems.Add(gameItemQuantity);
                }
                if (gameItemQuantity.GameItem is Statement)
                {
                    Statements.Add(gameItemQuantity);
                }
            }
        }
コード例 #8
0
        private Statements ReadIfs(Statements statements)
        {
            // 1. Find first .IF
            var firstIf = statements.FirstOrDefault(statement => statement is Control c && c.Name.ToLower() == "if");

            if (firstIf == null)
            {
                return(statements);
            }

            var firstIfIndex = statements.IndexOf(firstIf);
            var result       = (Statements)statements.Clone();

            // 2. Find matching .ENDIF
            var matchedEndIfIndex = FindFirstMatched(result, firstIfIndex + 1, "endif");

            if (matchedEndIfIndex == statements.Count)
            {
                Validation.Reading.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Error, "Cannot find matched .endif"));
                return(result);
            }

            // 3. Compute result of .if
            var ifResultStatements = ComputeIfResult(result, firstIfIndex, matchedEndIfIndex);

            // 4.Replace .if statements with its result
            result.Replace(firstIfIndex, matchedEndIfIndex, ifResultStatements);

            // 5. Do it again.
            result = ReadIfs(result);

            return(result);
        }
コード例 #9
0
        /// <summary>
        /// Preprocess .ST and .STEP.
        /// </summary>
        /// <param name="statements">Statements</param>
        public Statements Process(Statements statements)
        {
            if (statements == null)
            {
                throw new ArgumentNullException(nameof(statements));
            }

            foreach (var statement in statements.ToArray())
            {
                if (statement is Control c)
                {
                    if (c.Name.ToLower() == "st")
                    {
                        var cloned = (Control)c.Clone();
                        cloned.Name = "ST_R";
                        statements.Add(cloned);
                    }

                    if (c.Name.ToLower() == "step")
                    {
                        var cloned = (Control)c.Clone();
                        cloned.Name = "STEP_R";
                        statements.Add(cloned);
                    }
                }
            }

            return(statements);
        }
コード例 #10
0
        protected override void GenerateInner(CodeGenerator generator, CodeStatementEmitOptions emitOptions)
        {
            generator.Indent--;
            generator.Write(TokenType.Keyword, "default");
            generator.WriteLine(TokenType.Punctuation, ':');
            generator.Indent++;

            if (!Fallthrough)
            {
                generator.EnterLocalScope();
                Statements.ReserveLocals(generator, default(CodeStatementEmitOptions));
            }

            Statements.Generate(generator, default(CodeStatementEmitOptions));

            if (!Fallthrough)
            {
                bool needsBreak = true;
                if (Statements.Count > 0)
                {
                    var lastStatement = Statements[Statements.Count - 1];
                    needsBreak = !lastStatement.IsTerminator;
                }

                if (needsBreak)
                {
                    generator.Write(TokenType.Keyword, "break");
                    generator.WriteLine(TokenType.Punctuation, ';');
                }
                generator.ExitLocalScope();
            }
        }
        protected override void GenerateInner(CodeGenerator generator, CodeCompositeTypeDeclaration enclosingType)
        {
            generator.Write(TokenType.Keyword, "static");
            generator.Write(TokenType.Space, ' ');
            generator.Write(TokenType.Identifier, enclosingType.Name);
            generator.Write(TokenType.Punctuation, "()");

            if (Statements.Count > 0)
            {
                generator.WriteOpeningBrace();
                generator.Indent++;
                generator.EnterLocalScope();
                foreach (var parameter in Parameters)
                {
                    generator.ReserveLocal(parameter.Name);
                }
                Statements.Generate(generator, default(CodeStatementEmitOptions));
                generator.ExitLocalScope();
                generator.Indent--;
                generator.WriteClosingBrace();
            }
            else
            {
                generator.WriteEmptyBlock();
            }
        }
コード例 #12
0
 public bool CheckSemantics(QLContext context, List <Message> messages)
 {
     return(Statements.TrueForAll((statement) =>
     {
         return statement.CheckSemantics(context, messages);
     }));
 }
コード例 #13
0
        internal BlockExpression(Statements/*!*/ statements, SourceSpan location)
            : base(location) {
            Assert.NotNull(statements);
            Debug.Assert(statements.Count > 1);

            _statements = statements;
        }
コード例 #14
0
        public override void Visit(DataModificationStatement node)
        {
            switch (TypeFilter)
            {
            case ObjectTypeFilter.PermanentOnly:
                if (!IsTempNode(node))
                {
                    Statements.Add(node);
                }

                break;

            case ObjectTypeFilter.TempOnly:
                if (IsTempNode(node))
                {
                    Statements.Add(node);
                }

                break;

            default:
                Statements.Add(node);
                break;
            }
        }
コード例 #15
0
 void WalkMethodStatements(Statements statements)
 {
     foreach (Expression expression in statements)
     {
         WalkExpression(expression);
     }
 }
コード例 #16
0
        private static int FindFirstMatched(Statements result, int startIndex, string controlToFind)
        {
            int ifCount = 0;

            while (startIndex < result.Count)
            {
                if (result[startIndex] is Control c && c.Name.ToLower() == controlToFind && ifCount == 0)
                {
                    break;
                }

                if (result[startIndex] is Control c2 && c2.Name.ToLower() == "endif")
                {
                    ifCount--;
                }

                if (result[startIndex] is Control c3 && c3.Name.ToLower() == "if")
                {
                    ifCount++;
                }

                startIndex++;
            }

            return(startIndex);
        }
コード例 #17
0
        private static void Week3Examples()
        {
            Console.WriteLine("----------------------------------------------");
            Console.WriteLine("Week3 in-class discussion and testing...      ");
            Console.WriteLine("----------------------------------------------");

            AdditonalExamples ae = new AdditonalExamples();

            //ae.CoalescingExample();
            //bool first, second, third, fourth;
            //first = ae.UseUmbrella(true, false, true);
            //second = ae.UseUmbrella(true, true, true);
            //third = ae.UseUmbrella(false, false, false);
            //fourth = ae.UseUmbrella(false, true, false);

            Console.WriteLine(ae.UseUmbrella(true, false, true));
            Console.WriteLine(ae.UseUmbrella(true, true, true));
            Console.WriteLine(ae.UseUmbrella(false, false, false));
            Console.WriteLine(ae.UseUmbrella(false, true, false));

            Statements myStatements = new Statements();

            myStatements.IfStatementBasicExample(10, 12);
            myStatements.IfStatementChainExample("Turkey");
            myStatements.SwitchStatemntExample("Friday");
            myStatements.ForEachLoopExample();
        }
コード例 #18
0
 public override void Visit(TSqlFragment node)
 {
     if (_types.Contains(node.GetType()))
     {
         Statements.Add(node);
     }
 }
コード例 #19
0
            static void Main(string[] args)
            {
                if (args.Length != 2)
                {
                    Console.WriteLine("MusicAnalyzer <SampleMusicPlaylist> <error_file_path>");
                    Environment.Exit(1);
                }

                string csvDataFilePath = args[0];
                string errorFilePath   = args[1];

                List <Setup> setupList = null;

                try
                {
                    setupList = Configure.Load(csvDataFilePath);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Environment.Exit(2);
                }

                var report = Statements.GenerateText(setupList);

                try
                {
                    System.IO.File.WriteAllText(setupFilePath, report);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Environment.Exit(3);
                }
            }
コード例 #20
0
ファイル: Finalizer.cs プロジェクト: jxnmaomao/ironruby
        public Finalizer(LexicalScope/*!*/ definedScope, Statements statements, SourceSpan location)
            : base(location) {
            Assert.NotNull(definedScope);

            _definedScope = definedScope;
            _statements = statements;
        }
コード例 #21
0
 protected override void GenerateInner(CodeGenerator generator, CodeStatementEmitOptions emitOptions)
 {
     generator.WriteBlankLineBeforeEnteringBlock();
     generator.EnterLocalScope();
     generator.Write(TokenType.Keyword, "foreach");
     generator.Write(TokenType.Space, ' ');
     generator.Write(TokenType.Punctuation, '(');
     Declaration.Type.Generate(generator);
     generator.Write(TokenType.Space, ' ');
     generator.OutputIdentifier(TokenType.Identifier, Declaration.Name);
     generator.Write(TokenType.Space, ' ');
     generator.Write(TokenType.Keyword, "in");
     generator.Write(TokenType.Space, ' ');
     Expression.Generate(generator);
     generator.Write(TokenType.Punctuation, ')');
     if (Statements.Count > 0)
     {
         generator.WriteOpeningBrace();
         generator.Indent++;
         generator.EnterLocalScope();
         Statements.ReserveLocals(generator, default(CodeStatementEmitOptions));
         Statements.Generate(generator, default(CodeStatementEmitOptions));
         generator.ExitLocalScope();
         generator.Indent--;
         generator.WriteClosingBrace();
     }
     else
     {
         generator.WriteEmptyBlock();
     }
     generator.ExitLocalScope();
 }
コード例 #22
0
ファイル: ElseIfClause.cs プロジェクト: TerabyteX/main
 public ElseIfClause(Expression condition, Statements/*!*/ statements, SourceSpan location)
     : base(location)
 {
     Assert.NotNull(statements);
     _statements = statements;
     _condition = condition;
 }
コード例 #23
0
 public CodeForeachStatement(CodeVariableDeclarationStatement declaration, CodeExpression expression, IEnumerable <CodeStatement> statements)
 {
     Debug.Assert(declaration.InitExpression == null, "foreach variable declaration cannot have initializer");
     Declaration = declaration;
     Expression  = expression;
     Statements.AddRange(statements);
 }
コード例 #24
0
 public void Add(Statement instruction)
 {
     if (instruction != null)
     {
         Statements.Add(instruction);
     }
 }
コード例 #25
0
 public void Insert(Statement instruction)
 {
     if (instruction != null)
     {
         Statements.Insert(0, instruction);
     }
 }
コード例 #26
0
 /// <summary>
 /// Creates a new for loop statement. Usage:
 /// for 'identifier' in 'firstExpression' .. 'secondExpression' do 'statements' end for;
 /// </summary>
 /// <param name="identifier">Iterator's identifier</param>
 /// <param name="firstExpression">Starting value</param>
 /// <param name="secondExpression">Ending value</param>
 /// <param name="statements">Statements to execute</param>
 public StatementFor(string identifier, Expression firstExpression, Expression secondExpression, Statements statements)
 {
     Identifier = identifier;
     FirstExpression = firstExpression;
     SecondExpression = secondExpression;
     Statements = statements;
 }
 protected override void GenerateInner(CodeGenerator generator, CodeStatementEmitOptions emitOptions)
 {
     generator.WriteBlankLineBeforeEnteringBlock();
     generator.Write(TokenType.Keyword, "switch");
     generator.Write(TokenType.Space, ' ');
     generator.Write(TokenType.Punctuation, '(');
     Value.Generate(generator);
     generator.Write(TokenType.Punctuation, ')');
     if (Statements.Count > 0)
     {
         generator.WriteOpeningBrace();
         generator.Indent++;
         generator.Indent++;
         generator.EnterLocalScope();
         Statements.ReserveLocals(generator, default(CodeStatementEmitOptions));
         Statements.Generate(generator, default(CodeStatementEmitOptions));
         generator.ExitLocalScope();
         generator.Indent--;
         generator.Indent--;
         generator.WriteClosingBrace();
     }
     else
     {
         generator.WriteEmptyBlock();
     }
 }
コード例 #28
0
        public async Task CreateStatementsTest()
        {
            Statements statements = new Statements();
            var        response   = await instance.CreateStatementsAsync(accessToken, xeroTenantId, statements);

            Assert.IsType <Statements>(response);
        }
コード例 #29
0
ファイル: ForLoopExpression.cs プロジェクト: jschementi/iron
        public ForLoopExpression(LexicalScope/*!*/ definedScope, Parameters/*!*/ variables, Expression/*!*/ list, Statements body, SourceSpan location)
            : base(location) {
            Assert.NotNull(definedScope, variables, list);

            _block = new BlockDefinition(definedScope, variables, body, location);
            _list = list;
        }
コード例 #30
0
 public ForLoopExpression(CompoundLeftValue/*!*/ variables, Expression/*!*/ list, Statements body, SourceSpan location)
     : base(location) {
     Assert.NotNull(variables, list);
     
     _block = new BlockDefinition(null, variables, body, location);
     _list = list;
 }
コード例 #31
0
ファイル: RescueClause.cs プロジェクト: aceptra/ironruby
 public RescueClause(CompoundRightValue type, LeftValue target, Statements statements, SourceSpan location)
     : base(location) {
     _types = type.RightValues;
     _splatType = type.SplattedValue;
     _target = target;
     _statements = statements;
 }
コード例 #32
0
ファイル: RescueClause.cs プロジェクト: aceptra/ironruby
 public RescueClause(Expression/*!*/ type, LeftValue target, Statements statements, SourceSpan location)
     : base(location) {
     Assert.NotNull(type);
     _types = new Expression[] { type };
     _target = target;
     _statements = statements;
 }
コード例 #33
0
        /// <summary>
        /// Reads .include statements.
        /// </summary>
        /// <param name="statements">Statements.</param>
        /// <param name="currentDirectoryPath">Current directory path.</param>
        protected Statements Process(Statements statements, string currentDirectoryPath)
        {
            var subCircuits = statements.OfType <SubCircuit>().ToList();

            if (subCircuits.Any())
            {
                foreach (SubCircuit subCircuit in subCircuits)
                {
                    var subCircuitIncludes = subCircuit.Statements.OfType <Control>()
                                             .Where(statement => statement.Name == "include" || statement.Name.ToLower() == "inc").ToList();

                    foreach (Control include in subCircuitIncludes)
                    {
                        ReadSingleInclude(subCircuit.Statements, currentDirectoryPath, include);
                    }
                }
            }

            var includes = statements.OfType <Control>().Where(statement =>
                                                               statement.Name.ToLower() == "include" || statement.Name.ToLower() == "inc").ToList();

            if (includes.Any())
            {
                foreach (Control include in includes)
                {
                    ReadSingleInclude(statements, currentDirectoryPath, include);
                }
            }

            return(statements);
        }
コード例 #34
0
        private IEnumerable <Statement> ComputeIfResult(Statements result, int ifIndex, int endIfIndex)
        {
            var ifControl   = (Control)result[ifIndex];
            var ifCondition = (Models.Netlist.Spice.Objects.Parameters.ExpressionParameter)ifControl.Parameters[0];

            Control elseControl   = null;
            Control elseIfControl = null;

            var elseControlIndex = FindFirstMatched(result, ifIndex + 1, "else");

            if (elseControlIndex != result.Count)
            {
                elseControl = result[elseControlIndex] as Control;
            }

            var elseIfControlIndex = FindFirstMatched(result, ifIndex + 1, "elseif");

            if (elseIfControlIndex != result.Count)
            {
                elseIfControl = result[elseIfControlIndex] as Control;
            }

            if (EvaluationContext.Evaluate(ifCondition.Image) >= 1.0)
            {
                if (elseIfControl != null)
                {
                    return(result.Skip(ifIndex + 1).Take(elseIfControlIndex - ifIndex - 1).ToList());
                }
                else
                {
                    if (elseControl == null)
                    {
                        return(result.Skip(ifIndex + 1).Take(endIfIndex - ifIndex - 1).ToList());
                    }
                    else
                    {
                        return(result.Skip(ifIndex + 1).Take(elseControlIndex - ifIndex - 1).ToList());
                    }
                }
            }
            else
            {
                if (elseIfControl != null)
                {
                    return(ComputeIfResult(result, elseIfControlIndex, endIfIndex));
                }
                else
                {
                    if (elseControl == null)
                    {
                        return(new List <Statement>());
                    }
                    else
                    {
                        return(result.Skip(elseControlIndex + 1).Take(endIfIndex - elseControlIndex - 1).ToList());
                    }
                }
            }
        }
コード例 #35
0
        protected override void GenerateInner(CodeGenerator generator, CodeCompositeTypeDeclaration enclosingType)
        {
            generator.GenerateAttributes(ReturnTypeCustomAttributes, "return");

            if (ExplicitImplementationType == null)
            {
                Modifiers.Generate(generator);
            }

            ReturnType.Generate(generator);
            generator.Write(TokenType.Space, ' ');
            if (ExplicitImplementationType != null)
            {
                ExplicitImplementationType.Generate(generator);
                generator.Write(TokenType.Punctuation, '.');
            }
            generator.OutputIdentifier(TokenType.Identifier, Name);

            generator.OutputTypeParameters(TypeParameters);

            generator.Write(TokenType.Punctuation, '(');
            Parameters.GenerateCommaSeparated(generator);
            generator.Write(TokenType.Punctuation, ')');

            foreach (var typeParameter in TypeParameters)
            {
                typeParameter.GenerateConstraints(generator);
            }

            if (enclosingType.IsInterface ||
                (Modifiers & CodeMemberModifiers.ScopeMask) == CodeMemberModifiers.Abstract)
            {
                generator.WriteLine(TokenType.Punctuation, ';');
            }
            else
            {
                if (Statements.Count > 0)
                {
                    generator.WriteOpeningBrace();
                    generator.Indent++;

                    generator.EnterLocalScope();
                    foreach (var parameter in Parameters)
                    {
                        generator.ReserveLocal(parameter.Name);
                    }

                    Statements.Generate(generator, default(CodeStatementEmitOptions));
                    generator.ExitLocalScope();

                    generator.Indent--;
                    generator.WriteClosingBrace();
                }
                else
                {
                    generator.WriteEmptyBlock();
                }
            }
        }
コード例 #36
0
ファイル: CaseExpression.cs プロジェクト: joshholmes/ironruby
        public CaseExpression(Expression value, List<WhenClause>/*!*/ whenClauses, Statements elseStatements, SourceSpan location)
            : base(location) {
            ContractUtils.RequiresNotNull(whenClauses, "whenClauses");

            _value = value;
            _whenClauses = whenClauses;
            _elseStatements = elseStatements;
        }
コード例 #37
0
ファイル: SchemaBuilderBase.cs プロジェクト: vdandrade/Plato
 public ISchemaBuilderBase AddStatement(string statement)
 {
     if (!string.IsNullOrEmpty(statement))
     {
         Statements.Add(statement);
     }
     return(this);
 }
コード例 #38
0
ファイル: BlockDefinition.cs プロジェクト: nieve/ironruby
        public BlockDefinition(LexicalScope/*!*/ definedScope, CompoundLeftValue/*!*/ parameters, Statements/*!*/ body, SourceSpan location)
            : base(location) {
            Assert.NotNull(definedScope, parameters, body);

            _definedScope = definedScope;
            _body = body;
            _parameters = parameters;
        }
コード例 #39
0
ファイル: Block.cs プロジェクト: kkestell/rhea
        public VariableDeclaration FindDeclaration(string name)
        {
            var declaration = Statements
                              .OfType <VariableDeclaration>()
                              .FirstOrDefault(d => d.Name == name);

            return(declaration ?? ParentScope.FindDeclaration(name));
        }
コード例 #40
0
 /// <summary>
 /// Gets the models with given type and with different name than source model.
 /// </summary>
 /// <param name="statements">The statements.</param>
 /// <param name="sourceModelName">The name of source model.</param>
 /// <param name="modelType">The type of model to search.</param>
 /// <returns>
 /// Enumerable of models.
 /// </returns>
 private IEnumerable <Model> GetModelsOfType(Statements statements, string sourceModelName, string modelType)
 {
     return(statements
            .Where(s =>
                   s is Model m &&
                   GetTypeOfModel(m).ToLower() == modelType.ToLower() &&
                   m.Name != sourceModelName).Cast <Model>());
 }
コード例 #41
0
ファイル: RescueClause.cs プロジェクト: TerabyteX/main
        private readonly Expression[] _types; // might be empty, might include SplattedArgument expressions

        #endregion Fields

        #region Constructors

        public RescueClause(Expression/*!*/[]/*!*/ types, LeftValue target, Statements statements, SourceSpan location)
            : base(location)
        {
            Assert.NotNullItems(types);
            _types = types;
            _target = target;
            _statements = statements;
        }
コード例 #42
0
ファイル: SqlMap.cs プロジェクト: zhenman-li/SmartSql
 public Statement GetStatement(string fullSqlId)
 {
     if (!Statements.TryGetValue(fullSqlId, out var statement))
     {
         throw new SmartSqlException($"Can not find Statement.FullSqlId:{fullSqlId}");
     }
     return(statement);
 }
コード例 #43
0
ファイル: BlockDefinition.cs プロジェクト: jschementi/iron
        public BlockDefinition(LexicalScope/*!*/ definedScope, Parameters parameters, Statements/*!*/ body, SourceSpan location)
            : base(location) {
            Assert.NotNull(definedScope, body);

            _definedScope = definedScope;
            _body = body;
            _parameters = parameters ?? Parameters.Empty; 
        }
コード例 #44
0
        public UnlessExpression(Expression/*!*/ condition, Statements/*!*/ statements, ElseIfClause elseClause, SourceSpan location)
            : base(location) {
            ContractUtils.RequiresNotNull(condition, "condition");
            ContractUtils.RequiresNotNull(statements, "statements");
            ContractUtils.Requires(elseClause == null || elseClause.Condition == null, "elseClause", "No condition allowed.");

            _statements = statements;
            _condition = condition;
            _elseClause = elseClause;
        }
コード例 #45
0
        public WhileLoopExpression(Expression/*!*/ condition, bool isWhileLoop, bool isPostTest, Statements/*!*/ statements, SourceSpan location)
            : base(location) {

            ContractUtils.RequiresNotNull(condition, "condition");
            ContractUtils.RequiresNotNull(statements, "statements");

            _condition = condition;
            _isWhileLoop = isWhileLoop;
            _isPostTest = isPostTest;
            _statements = statements;
        }
コード例 #46
0
ファイル: Body.cs プロジェクト: jcteague/ironruby
        public Body(Statements/*!*/ statements, List<RescueClause> rescueClauses, Statements elseStatements,
            Statements ensureStatements, SourceSpan location)
            : base(location) {

            Assert.NotNull(statements);

            _statements = statements;
            _rescueClauses = rescueClauses;
            _elseStatements = elseStatements;
            _ensureStatements = ensureStatements;
        }
コード例 #47
0
        public static void CopyFile(FileInfo source, FileInfo destination,
            Statements.FileCopyOptions options, CopyFileHandler callback, object state)
        {
            if (source == null) throw new ArgumentNullException("source");
            if (destination == null) throw new ArgumentNullException("destination");

            new FileIOPermission(FileIOPermissionAccess.Read, source.FullName).Demand();
            new FileIOPermission(FileIOPermissionAccess.Write, destination.FullName).Demand();

            CopyProgressRoutine cpr = (callback == null) ? null : new CopyProgressRoutine(
                new CopyProgressData(source, destination, callback, state).CallbackHandler);

            bool cancel = false;
            if (!NativeMethod.CopyFileEx(source.FullName, destination.FullName, cpr, IntPtr.Zero, ref cancel, (int)options))
                throw new IOException(new Win32Exception().Message);
        }
コード例 #48
0
ファイル: IfExpression.cs プロジェクト: ExpertsInside/IronSP
        public IfExpression(Expression/*!*/ condition, Statements/*!*/ body, List<ElseIfClause>/*!*/ elseIfClauses, SourceSpan location)
            : base(location) {
            ContractUtils.RequiresNotNull(body, "body");
            ContractUtils.RequiresNotNull(condition, "condition");
            ContractUtils.RequiresNotNull(elseIfClauses, "elseIfClauses");

            // all but the last clause should have non-null conditions:
            for (int i = 0; i < elseIfClauses.Count - 1; i++) {
                if (elseIfClauses[i].Condition == null) {
                    throw ExceptionUtils.MakeArgumentItemNullException(i, "elseIfClauses");
                }
            }

            _condition = condition;
            _body = body;
            _elseIfClauses = elseIfClauses;
        }
コード例 #49
0
 public bool Resume(Bookmark bookmark, FileInfo source, FileInfo destination, Statements.FileCopyOptions options, int stepIncrement)
 {
     var context = new CopyFileContext(stepIncrement)
     {
         Instance = this,
         Bookmark = bookmark,
         Action = CopyFileAction.Continue
     };
     if (contexts.TryAdd(bookmark.Name, context))
     {
         var action = new Action(() => ExecuteCopyFile(context, source, destination, options));
         action.BeginInvoke((a) =>
         {
             try { action.EndInvoke(a); }
             catch (Exception ex) { ((CopyFileContext)a.AsyncState).Exception = ex; }
             finally { ((CopyFileContext)a.AsyncState).NotifyCompletion(); }
         }, context);
         return true;
     }
     return false;
 }
コード例 #50
0
		public virtual void Visit(Statements.ScopeGuardStatement s)
		{
			VisitChildren(s);
		}
コード例 #51
0
		public virtual void Visit(Statements.TemplateMixin s)
		{
			VisitAbstractStmt(s);

			if (s.Qualifier != null)
				s.Qualifier.Accept(this);
		}
コード例 #52
0
		public virtual void Visit(Statements.AsmStatement s)
		{
			VisitAbstractStmt(s);
		}
コード例 #53
0
 private BlockExpression() 
     : base(SourceSpan.None) {
     _statements = EmptyStatements;            
 }
コード例 #54
0
		public virtual void Visit(Statements.AssertStatement s)
		{
			VisitAbstractStmt(s);

			if (s.AssertedExpression != null)
				s.AssertedExpression.Accept(this);
		}
コード例 #55
0
		public virtual void Visit(Statements.PragmaStatement s)
		{
			VisitChildren(s);

			s.Pragma.Accept(this);
		}
コード例 #56
0
		public virtual void Visit(Statements.VolatileStatement s)
		{
			VisitChildren(s);
		}
コード例 #57
0
		public virtual void Visit(Statements.DebugSpecification s)
		{
			VisitAbstractStmt(s);
		}
コード例 #58
0
		public virtual void Visit(Statements.TryStatement.FinallyStatement s)
		{
			VisitChildren(s);
		}
コード例 #59
0
		public virtual void Visit(Statements.DeclarationStatement s)
		{
			VisitAbstractStmt(s);

			if (s.Declarations != null)
				foreach (var decl in s.Declarations)
					decl.Accept(this);
		}
コード例 #60
0
		public virtual void Visit(Statements.ExpressionStatement s)
		{
			VisitAbstractStmt(s);

			s.Expression.Accept(this);
		}