diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-07-16 14:51:15 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-07-16 14:51:15 +0200 |
commit | 4e6b3a206fa4ad8bb0b664f7674c9a70376d6e26 (patch) | |
tree | 7bb9ad7e31c24d1cf1707e03e6f1a80f6d033951 /Source/JavaScriptCore/offlineasm/parser.rb | |
parent | 3977e3d2f72f7fe2c887c1ec0e0c342e1d169f42 (diff) | |
download | qtwebkit-4e6b3a206fa4ad8bb0b664f7674c9a70376d6e26.tar.gz |
Imported WebKit commit 953baa67aa07087b6ecd4199351ec554c724e27d (http://svn.webkit.org/repository/webkit/trunk@122676)
Diffstat (limited to 'Source/JavaScriptCore/offlineasm/parser.rb')
-rw-r--r-- | Source/JavaScriptCore/offlineasm/parser.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/Source/JavaScriptCore/offlineasm/parser.rb b/Source/JavaScriptCore/offlineasm/parser.rb index 11863c724..8696a61a9 100644 --- a/Source/JavaScriptCore/offlineasm/parser.rb +++ b/Source/JavaScriptCore/offlineasm/parser.rb @@ -21,6 +21,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF # THE POSSIBILITY OF SUCH DAMAGE. +require "config" require "ast" require "instructions" require "pathname" @@ -81,11 +82,20 @@ def lex(str, fileName) fileName = Pathname.new(fileName) result = [] lineNumber = 1 + annotation = nil while not str.empty? case str when /\A\#([^\n]*)/ # comment, ignore + when /\A\/\/([^\n]*)/ + # annotation + annotation = $1 when /\A\n/ + # We've found a '\n'. Emit the last comment recorded if appropriate: + if $enableInstrAnnotations and annotation + result << Token.new(CodeOrigin.new(fileName, lineNumber), "@" + annotation) + annotation = nil + end result << Token.new(CodeOrigin.new(fileName, lineNumber), $&) lineNumber += 1 when /\A[a-zA-Z]([a-zA-Z0-9_]*)/ @@ -136,6 +146,10 @@ def isIdentifier(token) token =~ /\A[a-zA-Z]([a-zA-Z0-9_]*)\Z/ and not isKeyword(token) end +def isAnnotation(token) + token =~ /\A\@([^\n]*)/ +end + def isLabel(token) token =~ /\A_([a-zA-Z0-9_]*)\Z/ end @@ -535,6 +549,10 @@ class Parser # Zero operand instruction, and it's the last one. list << Instruction.new(codeOrigin, name, []) break + elsif isAnnotation @tokens[@idx] + annotation = @tokens[@idx].string + list << Instruction.new(codeOrigin, name, [], annotation) + @idx += 2 # Consume the newline as well. elsif @tokens[@idx] == "\n" # Zero operand instruction. list << Instruction.new(codeOrigin, name, []) @@ -543,6 +561,7 @@ class Parser # It's definitely an instruction, and it has at least one operand. operands = [] endOfSequence = false + annotation = nil loop { operands << parseOperand("while inside of instruction #{name}") if (not final and @idx == @tokens.size) or (final and @tokens[@idx] =~ final) @@ -552,6 +571,10 @@ class Parser elsif @tokens[@idx] == "," # Has another operand. @idx += 1 + elsif isAnnotation @tokens[@idx] + annotation = @tokens[@idx].string + @idx += 2 # Consume the newline as well. + break elsif @tokens[@idx] == "\n" # The end of the instruction. @idx += 1 @@ -560,7 +583,7 @@ class Parser parseError("Expected a comma, newline, or #{final} after #{operands.last.dump}") end } - list << Instruction.new(codeOrigin, name, operands) + list << Instruction.new(codeOrigin, name, operands, annotation) if endOfSequence break end |