2015-04-15 21:25:31 +03:00
|
|
|
//===----------------- lib/Jit/utility.cpp ----------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// LLILC
|
|
|
|
//
|
|
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
// Licensed under the MIT license.
|
|
|
|
// See LICENSE file in the project root for full license information.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// \brief Definitions of utility classes.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
2015-02-26 01:56:44 +03:00
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
#include "jitpch.h"
|
|
|
|
#include "utility.h"
|
|
|
|
#include "llvm/Support/ConvertUTF.h"
|
|
|
|
|
|
|
|
// Checks given parsed representation to see if method is in the set.
|
|
|
|
|
|
|
|
bool MethodSet::contains(const char *Name, const char *ClassName,
|
|
|
|
PCCOR_SIGNATURE sig) {
|
2015-04-15 21:25:31 +03:00
|
|
|
assert(isInitialized());
|
2015-02-26 01:56:44 +03:00
|
|
|
|
|
|
|
std::list<MethodName>::const_iterator iterator;
|
|
|
|
|
2015-04-15 21:25:31 +03:00
|
|
|
for (iterator = MethodList->begin(); iterator != MethodList->end();
|
|
|
|
++iterator) {
|
2015-02-26 01:56:44 +03:00
|
|
|
if (iterator->Name->compare("*") == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Just matching method name. This is way too loose but have not yet
|
|
|
|
// plumbed through the class name and wildcard logic.
|
|
|
|
|
|
|
|
if (iterator->Name->compare(Name) == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-04-16 02:11:20 +03:00
|
|
|
std::unique_ptr<std::string> Convert::utf16ToUtf8(const char16_t *WideStr) {
|
|
|
|
// Get the length of the input
|
|
|
|
size_t SrcLen = 0;
|
|
|
|
for (; WideStr[SrcLen] != (char16_t)0; SrcLen++)
|
|
|
|
;
|
|
|
|
|
|
|
|
ArrayRef<char> SrcBytes((const char *)WideStr, 2 * SrcLen);
|
2015-02-26 01:56:44 +03:00
|
|
|
std::unique_ptr<std::string> OutString(new std::string);
|
|
|
|
llvm::convertUTF16ToUTF8String(SrcBytes, *OutString);
|
|
|
|
|
|
|
|
return OutString;
|
|
|
|
}
|