/// <summary> /// Extract all the <see cref="GBaseBlock"/>s from the given GIMPLE source. /// </summary> /// <param name="gimple">GIMPLE source file content.</param> /// <returns> /// <see cref="List{T}"/> of <see cref="GBaseBlock"/> containing all the Base Blocks. /// </returns> public static List <GBaseBlock> getBaseBlocks(List <string> gimple) { Block block = new Block( ); List <Block> blocks = new List <Block> ( ); bool readingBlock = false; foreach (var line in gimple) { if (GBBStmt.matches(line)) { readingBlock = true; } if (line.Length == 0) { if (readingBlock) { blocks.Add(block); } readingBlock = false; block = new Block( ); } if (readingBlock) { block.Add(line.Trim( )); } } List <GBaseBlock> baseBlocks = new List <GBaseBlock> ( ); foreach (var b in blocks) { baseBlocks.Add(new GBaseBlock(b)); } return(baseBlocks); }
private void getVarsDecl(List <string> gimple) { gVarsDecl.Clear( ); foreach (var line in gimple) { if (line == "" || GBBStmt.matches(line)) { break; } string declPattern = @"\s*(?<type>.*) (?<name>\S*);"; var match = Regex.Match(line, declPattern); var gVar = new GVar { name = match.Groups["name"].Value, type = match.Groups["type"].Value }; gVarsDecl.Add(gVar); } }