Example #1
0
static at *call_method(at *obj, struct hashelem *hx, at *args)
{
   at *fun = hx->function;
   assert(FUNCTIONP(fun));
   
   if (Class(fun) == de_class) {
      // DE
      at *p = eval_arglist(args);
      return with_object(obj, fun, p, hx->sofar);

   } else if (Class(fun) == df_class) {
      // DF
      return with_object(obj, fun, args, hx->sofar);

   } else if (Class(fun) == dm_class) {
      // DM
      at *p = new_cons(new_cons(fun, args), NIL);
      at *q = with_object(obj, at_mexpand, p, hx->sofar);
      return eval(q);
      
   } else {
      // DX, DY, DH
      at *p = new_cons(fun, new_cons(obj, args));
      return Class(fun)->listeval(fun, p);
   }
}
Example #2
0
static void
test_chars_after_function_call_fail(void)
{
	const char *args = "a()a";
	const char *stop_ptr;
	char *result;

	result = eval_arglist(args, &stop_ptr);
	assert_true(result == NULL);
	free(result);
}
Example #3
0
static void
test_broken_comparison_operator(void)
{
	const char *args = "'a' < = 'b'";
	const char *stop_ptr;
	char *result;

	result = eval_arglist(args, &stop_ptr);
	assert_true(result == NULL);
	free(result);
}
Example #4
0
static void
test_empty_parens_fail(void)
{
	const char *args = "()";
	const char *stop_ptr;
	char *result;

	result = eval_arglist(args, &stop_ptr);
	assert_true(result == NULL);
	free(result);
}
Example #5
0
static void
test_wrong_expression_position(void)
{
	const char *args = "'a' , some text";
	const char *stop_ptr;
	char *result;

	result = eval_arglist(args, &stop_ptr);
	assert_true(result == NULL);
	assert_true(args + 4 == stop_ptr);
	free(result);
}
Example #6
0
static void
test_double_single_quote(void)
{
	const char *args = "'a''b'";
	const char *stop_ptr;
	char *result;

	result = eval_arglist(args, &stop_ptr);
	assert_true(result != NULL);
	assert_string_equal("a'b", result);
	free(result);
}
Example #7
0
static void
test_two_dot_separated_args(void)
{
	const char *args = "'a'  .  'b'";
	const char *stop_ptr;
	char *result;

	result = eval_arglist(args, &stop_ptr);
	assert_true(result != NULL);
	assert_string_equal("ab", result);
	free(result);
}
Example #8
0
static void
test_one_arg(void)
{
	const char *args = "'a'";
	const char *stop_ptr;
	char *result;

	result = eval_arglist(args, &stop_ptr);
	assert_true(result != NULL);
	assert_string_equal("a", result);
	free(result);
}
Example #9
0
static void
test_function_call(void)
{
	const char *args = "a('hello')";
	const char *stop_ptr;
	char *result;

	result = eval_arglist(args, &stop_ptr);
	assert_true(result != NULL);
	assert_string_equal("hello", result);
	free(result);
}
Example #10
0
static void
test_statement_and_not_statement(void)
{
	const char *args = "'a'=='a' 'b'";
	const char *stop_ptr;
	char *result;

	result = eval_arglist(args, &stop_ptr);
	assert_true(result != NULL);
	assert_string_equal("1 b", result);
	free(result);
}
Example #11
0
File: storage.c Project: barak/lush
static at *storage_listeval(at *p, at *q)
{
   storage_t *st = Mptr(p);
   
   if (!st->data)
      error(NIL, "unsized storage", p);
   
   q = eval_arglist(Cdr(q));
   ifn (CONSP(q) && Car(q) && NUMBERP(Car(q)))
      error(NIL, "illegal subscript", q);
   
   ssize_t off = Number(Car(q));
   if (off<0 || off>=st->size)
      error(NIL, "subscript out of range", q);
   
   if (Cdr(q)) {
      ifn (CONSP(Cdr(q)) && !Cddr(q))
         error(NIL, "one or two arguments expected",q);
      storage_setat[st->type](st, off, Cadr(q));
      return st->backptr;
   } else
      return storage_getat[st->type](st, off);
}