예제 #1
0
/*! Copies the given argument
    @param arg     the argument to copy
    @return         the new, duplicate argument
*/
inline argument* copyArgument (argument* arg) {
    if (arg == NULL) {
        return NULL;
    } else {
        return newArgument(copyString(arg->name), copyTypelistDeep(arg->types), copyExpression(arg->initial));
    }
}
예제 #2
0
파일: lc.c 프로젝트: Henry/Leda
struct list* buildArgumentList
(
    struct list* id,
    enum forms af,
    struct typeRecord* typ,
    struct list* soFar
)
{
    // Base case, got to the end
    if (id == 0)
    {
        return soFar;
    }
    // else recurse first
    soFar = buildArgumentList(id->next, af, typ, soFar);
    // then build current symbol
    soFar = newList((char*) newArgument(id->value, typ, af), soFar);

    return soFar;
}
예제 #3
0
	END_IT
END_DESCRIBE

DESCRIBE(newExpressionArr, "expression* newExpressionArr (array*)")
	IT("Creates a new array expression")
		expression* expr = newExpressionArr(newArray(5));
		SHOULD_EQUAL(expr->type, TYPE_ARR)
		SHOULD_EQUAL(expr->ev.arrval->size, 5)
		freeExpr(expr);
	END_IT
END_DESCRIBE

DESCRIBE(newExpressionFun, "expression* newExpressionFun (tap_fun* value)")
	IT("Creates a new type expression")
		argument* fun_args[1];
		fun_args[0] = newArgument(newString(strDup("arg")), newTypelist(TYPE_STR), NULL);
		expression* expr1 = newExpressionStr(newString(strDup("*")));
		expr1->flag = EFLAG_VAR;
		expression* expr2 = newExpressionStr(newString(strDup("arg")));
		expr1->next = expr2;
		expr2->next = newExpressionStr(newString(strDup("arg")));
		tap_fun* fun = newTapFunction(fun_args, 1, 1, newExpressionLaz(expr1));
		expr1 = newExpressionFun(fun);
		SHOULD_EQUAL(expr1->type, TYPE_FUN)
		SHOULD_EQUAL(expr1->ev.funval, fun)
		freeExpr(expr1);
	END_IT
END_DESCRIBE

DESCRIBE(newExpressionTyp, "expression* newExpressionTyp (datatype value)")
	IT("Creates a new type expression")