This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final var _header: _VectorHeader { | |
unsafeAddress { | |
return Buffer(unsafeBufferObject: self).withUnsafeMutablePointerToValue { UnsafePointer($0) } | |
} | |
unsafeMutableAddress { | |
return Buffer(unsafeBufferObject: self).withUnsafeMutablePointerToValue { $0 } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct MatrixIndex: Comparable, CustomStringConvertible { | |
let row: Int | |
let col: Int | |
var description: String { | |
return "(\(row), \(col))" | |
} | |
} | |
func ==(lhs: MatrixIndex, rhs: MatrixIndex) -> Bool { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
encodeMessage (Request idx begin length) = runPut $ do | |
putWord32be (13 :: Word32) | |
putWord8 (6 :: Word8) | |
putWord32be (fromIntegral idx) | |
putWord32be (fromIntegral begin) | |
putWord32be (fromIntegral length) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void lex(Token &Result) { | |
Result = NextToken; | |
if (Result.isNot(tok::eof)) | |
lexImpl(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Restart: | |
// Remember the start of the token so we can form the text range. | |
const char *TokStart = CurPtr; | |
switch ((signed char)*CurPtr++) { | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class tok { | |
unknown = 0, | |
eof, | |
identifier, | |
oper_binary_unspaced, // "x+y" | |
oper_binary_spaced, // "x + y" | |
oper_postfix, | |
oper_prefix, | |
... | |
NUM_TOKENS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Lexer::formToken(tok Kind, const char *TokStart) { | |
assert(CurPtr >= BufferStart && | |
CurPtr <= BufferEnd && | |
"Current pointer out of range!"); | |
NextToken.setToken(Kind, StringRef(TokStart, CurPtr-TokStart)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case '\n': | |
case '\r': | |
NextToken.setAtStartOfLine(true); | |
goto Restart; // Skip whitespace. | |
case ' ': | |
case '\t': | |
case '\f': | |
case '\v': | |
goto Restart; // Skip whitespace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case 0: | |
// If this is a random nul character in the middle | |
// of a buffer, skip it as whitespace. | |
if (CurPtr-1 != BufferEnd) { | |
diagnoseEmbeddedNul(Diags, CurPtr-1); | |
goto Restart; | |
} | |
// Otherwise, this is the real end of the buffer. | |
// Put CurPtr back into buffer bounds. | |
CurPtr--; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case '@': return formToken(tok::at_sign, TokStart); | |
case '{': return formToken(tok::l_brace, TokStart); | |
case '[': return formToken(tok::l_square, TokStart); | |
case '(': return formToken(tok::l_paren, TokStart); | |
case '}': return formToken(tok::r_brace, TokStart); | |
case ']': return formToken(tok::r_square, TokStart); | |
case ')': return formToken(tok::r_paren, TokStart); | |
case ',': return formToken(tok::comma, TokStart); | |
case ';': return formToken(tok::semi, TokStart); | |
case ':': return formToken(tok::colon, TokStart); |
OlderNewer