]> git.saurik.com Git - cycript.git/blobdiff - Replace.cpp
Require strings used as characters to be one byte.
[cycript.git] / Replace.cpp
index f84d7e301365a2f888a79ed2c643615bd04cc8e9..68beb4f47b3ad1127ba94aabb0338c714434b159 100644 (file)
@@ -394,7 +394,10 @@ CYStatement *CYExternalDefinition::Replace(CYContext &context) {
 }
 
 CYTarget *CYExternalExpression::Replace(CYContext &context) {
-    return $C1(type_->Replace(context), $C2($V("dlsym"), $V("RTLD_DEFAULT"), name_->PropertyName(context)));
+    CYExpression *expression(name_->Number(context));
+    if (expression == NULL)
+        expression = $C2($V("dlsym"), $V("RTLD_DEFAULT"), name_->PropertyName(context));
+    return $C1(type_->Replace(context), expression);
 }
 
 CYNumber *CYFalse::Number(CYContext &context) {
@@ -967,7 +970,10 @@ CYIdentifierFlags *CYScope::Declare(CYContext &context, CYIdentifier *identifier
     else if (existing->kind_ == CYIdentifierGlobal || existing->kind_ == CYIdentifierMagic)
         existing->kind_ = kind;
     else if (existing->kind_ == CYIdentifierLexical || kind == CYIdentifierLexical)
-        _assert(false); // XXX: throw new SyntaxError()
+        _assert(false);
+    else if (transparent_ && existing->kind_ == CYIdentifierArgument && kind == CYIdentifierVariable)
+        _assert(false);
+    // XXX: throw new SyntaxError() instead of these asserts
 
     return existing;
 }
@@ -1005,10 +1011,6 @@ void CYScope::Close(CYContext &context) {
     CYForEach (i, internal_) {
         _assert(i->identifier_->next_ == i->identifier_);
     switch (i->kind_) {
-        case CYIdentifierArgument: {
-            _assert(!transparent_);
-        } break;
-
         case CYIdentifierLexical: {
             if (!damaged_) {
                 CYIdentifier *replace(context.Unique());
@@ -1171,6 +1173,13 @@ CYTarget *CYTemplate::Replace(CYContext &context) {
     return $C2($M($M($M($V("String"), $S("prototype")), $S("concat")), $S("apply")), $S(""), $ CYArray($ CYElementValue(string_, spans_->Replace(context))));
 }
 
+CYString *CYTemplate::String(CYContext &context) {
+    // XXX: implement this over local concat
+    if (spans_ != NULL)
+        return NULL;
+    return string_;
+}
+
 CYTarget *CYThis::Replace(CYContext &context) {
     if (context.this_ != NULL)
         return $V(context.this_->Identifier(context));
@@ -1260,6 +1269,15 @@ CYTarget *CYTypeExpression::Replace(CYContext &context) {
     return typed_->Replace(context);
 }
 
+CYTarget *CYTypeFloating::Replace(CYContext &context) {
+    switch (length_) {
+        case 0: return $V("float");
+        case 1: return $V("double");
+        case 2: return $V("longdouble");
+        default: _assert(false);
+    }
+}
+
 CYTarget *CYTypeInt128::Replace(CYContext &context) {
     return $V(signing_ == CYTypeUnsigned ? "uint128" : "int128");
 }