case CXType_LongLong: typed->specifier_ = $ CYTypeIntegral(CYTypeSigned, 3); break;
case CXType_ULongLong: typed->specifier_ = $ CYTypeIntegral(CYTypeUnsigned, 3); break;
+ case CXType_Int128: typed->specifier_ = $ CYTypeInt128(CYTypeSigned); break;
+ case CXType_UInt128: typed->specifier_ = $ CYTypeInt128(CYTypeUnsigned); break;
+
case CXType_BlockPointer: {
CXType pointee(clang_getPointeeType(type));
_assert(!clang_isFunctionTypeVariadic(pointee));
return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeSigned, 1));
}
+#ifdef __SIZEOF_INT128__
+template <>
+CYTypedIdentifier *Primitive<signed __int128>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeInt128(CYTypeSigned));
+}
+#endif
+
template <>
CYTypedIdentifier *Primitive<signed long int>::Decode(CYPool &pool) const {
return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeSigned, 2));
return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeUnsigned, 1));
}
+#ifdef __SIZEOF_INT128__
+template <>
+CYTypedIdentifier *Primitive<unsigned __int128>::Decode(CYPool &pool) const {
+ return $ CYTypedIdentifier($ CYTypeInt128(CYTypeUnsigned));
+}
+#endif
+
template <>
CYTypedIdentifier *Primitive<unsigned long int>::Decode(CYPool &pool) const {
return $ CYTypedIdentifier($ CYTypeIntegral(CYTypeUnsigned, 2));
CYCastJSValue_(signed long long int)
CYCastJSValue_(unsigned long long int)
+#ifdef __SIZEOF_INT128__
+CYCastJSValue_(signed __int128)
+CYCastJSValue_(unsigned __int128)
+#endif
+
JSValueRef CYJSUndefined(JSContextRef context) {
return JSValueMakeUndefined(context);
}
CYPoolFFI_(unsigned long long int)
CYPoolFFI_(unsigned short int)
+#ifdef __SIZEOF_INT128__
+CYPoolFFI_(signed __int128)
+CYPoolFFI_(unsigned __int128)
+#endif
+
void Void::PoolFFI(CYPool *pool, JSContextRef context, ffi_type *ffi, void *data, JSValueRef value) const {
_assert(false);
}
CYFromFFI_(unsigned long long int)
CYFromFFI_(unsigned short int)
+#ifdef __SIZEOF_INT128__
+CYFromFFI_(signed __int128)
+CYFromFFI_(unsigned __int128)
+#endif
+
JSValueRef Void::FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const {
return CYJSUndefined(context);
}
CYSetProperty(context, cache, CYJSString("ulong"), CYMakeType(context, sig::Primitive<unsigned long>()), kJSPropertyAttributeDontEnum);
CYSetProperty(context, cache, CYJSString("ulonglong"), CYMakeType(context, sig::Primitive<unsigned long long>()), kJSPropertyAttributeDontEnum);
+#ifdef __SIZEOF_INT128__
+ CYSetProperty(context, cache, CYJSString("int128"), CYMakeType(context, sig::Primitive<__int128>()), kJSPropertyAttributeDontEnum);
+ CYSetProperty(context, cache, CYJSString("uint128"), CYMakeType(context, sig::Primitive<unsigned __int128>()), kJSPropertyAttributeDontEnum);
+#endif
+
CYSetProperty(context, cache, CYJSString("float"), CYMakeType(context, sig::Primitive<float>()), kJSPropertyAttributeDontEnum);
CYSetProperty(context, cache, CYJSString("double"), CYMakeType(context, sig::Primitive<double>()), kJSPropertyAttributeDontEnum);
out << "@error";
}
+void CYTypeInt128::Output(CYOutput &out) const {
+ switch (signing_) {
+ case CYTypeNeutral: break;
+ case CYTypeSigned: out << "signed" << ' '; break;
+ case CYTypeUnsigned: out << "unsigned" << ' '; break;
+ }
+
+ out << "__int128";
+}
+
void CYTypeIntegral::Output(CYOutput &out) const {
if (signing_ == CYTypeUnsigned)
out << "unsigned" << ' ';
%union { CYParenthetical *parenthetical_; }
%union { CYProperty *property_; }
%union { CYPropertyName *propertyName_; }
+%union { CYTypeSigning signing_; }
%union { CYSpan *span_; }
%union { CYStatement *statement_; }
%union { CYString *string_; }
%token _goto_ "goto"
%token _implements_ "implements"
%token _int_ "int"
+%token ___int128_ "__int128"
%token _interface_ "interface"
%token _let_ "let"
%token _let__ "!let"
%type <typedIdentifier_> TypeSignifier
%type <typedIdentifier_> TypeSignifierNone
%type <typedIdentifier_> TypeSignifierOpt
+%type <signing_> TypeSigning
%type <modifier_> ParameterTail
%type <modifier_> TypeQualifierLeft
%type <modifier_> TypeQualifierLeftOpt
: IdentifierTypeNoOf
| "char" { $$ = CYNew CYIdentifier("char"); }
| "int" { $$ = CYNew CYIdentifier("int"); }
+ | "__int128" { $$ = CYNew CYIdentifier("__int128"); }
| "long" { $$ = CYNew CYIdentifier("long"); }
| "__restrict" { $$ = CYNew CYIdentifier("__restrict"); }
| "restrict" { $$ = CYNew CYIdentifier("restrict"); }
| { $$ = NULL; }
;
+TypeSigning
+ : { $$ = CYTypeNeutral; }
+ | "signed" { $$ = CYTypeSigned; }
+ | "unsigned" { $$ = CYTypeUnsigned; }
+ ;
+
PrimitiveType
: IdentifierType[name] { $$ = CYNew CYTypeVariable($name); }
| IntegerType[pass] { $$ = $pass; }
- | "char" { $$ = CYNew CYTypeCharacter(CYTypeNeutral); }
- | "signed" "char" { $$ = CYNew CYTypeCharacter(CYTypeSigned); }
- | "unsigned" "char" { $$ = CYNew CYTypeCharacter(CYTypeUnsigned); }
+ | TypeSigning[signing] "char" { $$ = CYNew CYTypeCharacter($signing); }
+ | TypeSigning[signing] "__int128" { $$ = CYNew CYTypeInt128($signing); }
| "struct" IdentifierType[name] { $$ = CYNew CYTypeReference($name); }
;
return typed_->Replace(context);
}
+CYTarget *CYTypeInt128::Replace(CYContext &context) {
+ return $V(signing_ == CYTypeUnsigned ? "uint128" : "int128");
+}
+
CYTarget *CYTypeIntegral::Replace(CYContext &context) {
bool u(signing_ == CYTypeUnsigned);
switch (length_) {
"Infinity" L /*III*/ F(tk::_Infinity_, hi::Constant);
"instanceof" L /*KKK*/ F(tk::_instanceof_, hi::Operator);
"int" L /*FII*/ F(tk::_int_, hi::Type);
+"__int128" L /*III*/ F(tk::___int128_, hi::Type);
"interface" L /*FSS*/ F(tk::_interface_, hi::Meta);
"let" L /*IS?*/ F(tk::_let_, hi::Meta);
"long" L /*FII*/ F(tk::_long_, hi::Type);
virtual void Output(CYOutput &out) const;
};
+struct CYTypeInt128 :
+ CYTypeSpecifier
+{
+ CYTypeSigning signing_;
+
+ CYTypeInt128(CYTypeSigning signing) :
+ signing_(signing)
+ {
+ }
+
+ virtual CYTarget *Replace(CYContext &context);
+ virtual void Output(CYOutput &out) const;
+};
+
struct CYTypeIntegral :
CYTypeSpecifier
{
#include "sig/ffi_type.hpp"
#include "sig/types.hpp"
+#if FFI_LONG_LONG_MAX == 9223372036854775807LL
#define ffi_type_slonglong ffi_type_sint64
#define ffi_type_ulonglong ffi_type_uint64
+#else
+#error need to configure for long long
+#endif
namespace sig {
return &ffi_type_sint;
}
+#ifdef __SIZEOF_INT128__
+template <>
+ffi_type *Primitive<signed __int128>::GetFFI(CYPool &pool) const {
+ _assert(false);
+}
+#endif
+
template <>
ffi_type *Primitive<signed long int>::GetFFI(CYPool &pool) const {
return &ffi_type_slong;
return &ffi_type_uint;
}
+#ifdef __SIZEOF_INT128__
+template <>
+ffi_type *Primitive<unsigned __int128>::GetFFI(CYPool &pool) const {
+ _assert(false);
+}
+#endif
+
template <>
ffi_type *Primitive<unsigned long int>::GetFFI(CYPool &pool) const {
return &ffi_type_ulong;
case 's': type = new(pool) Primitive<short>(); break;
case 'v': type = new(pool) Void(); break;
+#ifdef __SIZEOF_INT128__
+ case 't': type = new(pool) Primitive<signed __int128>(); break;
+ case 'T': type = new(pool) Primitive<unsigned __int128>(); break;
+#endif
+
case '{':
type = new(pool) Aggregate(false);
next = '}';
return "i";
}
+#ifdef __SIZEOF_INT128__
+template <>
+const char *Primitive<signed __int128>::Encode(CYPool &pool) const {
+ return "t";
+}
+#endif
+
template <>
const char *Primitive<signed long int>::Encode(CYPool &pool) const {
return "l";
return "I";
}
+#ifdef __SIZEOF_INT128__
+template <>
+const char *Primitive<unsigned __int128>::Encode(CYPool &pool) const {
+ return "T";
+}
+#endif
+
template <>
const char *Primitive<unsigned long int>::Encode(CYPool &pool) const {
return "L";