#define STR(s) #s
-/* With most of the ops we need to do the same stuff so this save some
- typing. */
+/* With most of the ops we need to do the same stuff so this macros are meant
+ to save some typing. */
+
+/* Generate appropriate case and emit convential calls to function. */
#define CASE_CALL_NARGS(name, nargs) \
case B##name: \
PUSH (gcc_jit_lvalue_as_rvalue (res)); \
break
+/* Emit calls to functions with prototype (ptrdiff_t nargs, Lisp_Object *args)
+ This is done aggregating args into the scratch_call_area. */
+
+#define EMIT_SCRATCH_CALL_N(name, nargs) \
+ pop (nargs, &stack, args); \
+ res = jit_emit_callN (name, nargs, args); \
+ PUSH (gcc_jit_lvalue_as_rvalue (res))
+
/* The compiler context */
typedef struct {
CASE_CALL_NARGS (substring, 3);
case Bconcat2:
- printf("Bconcat2\n");
+ EMIT_SCRATCH_CALL_N ("Fconcat", 2);
break;
case Bconcat3:
- printf("Bconcat3\n");
+ EMIT_SCRATCH_CALL_N ("Fconcat", 3);
break;
case Bconcat4:
- printf("Bconcat4\n");
+ EMIT_SCRATCH_CALL_N ("Fconcat", 4);
break;
+ case BconcatN:
+ op = FETCH;
+ EMIT_SCRATCH_CALL_N ("Fconcat", op);
+ break;
+
case Bsub1:
printf("Bsub1\n");
break;
case BRgotoifnonnilelsepop:
printf("BRgotoifnonnilelsepop\n");
break;
- case BconcatN:
- printf("BconcatN\n");
- break;
case BinsertN:
printf("BinsertN\n");
break;
(should (= (comp-tests-symbol-value-f) 3)))
+(ert-deftest comp-tests-concat ()
+ "Testing concatX opcodes."
+ (defun comp-tests-concat-f (x)
+ (concat "a" "b" "c" "d"
+ (concat "a" "b" "c" (concat "a" "b" (concat "foo" x)))))
+ (byte-compile #'comp-tests-concat-f)
+ (native-compile #'comp-tests-concat-f)
+
+ (should (string= (comp-tests-concat-f "bar") "abcdabcabfoobar")))
(ert-deftest comp-tests-ffuncall ()
"Testing varset."