-static void Assignment (struct expent* lval)
-/* Parse an assignment */
-{
- int k;
- struct expent lval2;
- unsigned flags;
- type* ltype = lval->e_tptr;
-
- /* cc65 does not have full support for handling structs by value. Since
- * assigning structs is one of the more useful operations from this
- * familiy, allow it here.
- */
- if (IsStruct (ltype)) {
-
- /* Bring the address of the lhs into the primary and push it */
- exprhs (0, 0, lval);
- g_push (CF_PTR | CF_UNSIGNED, 0);
-
- /* Get the expression on the right of the '=' into the primary */
- k = hie1 (&lval2);
- if (k) {
- /* Get the address */
- exprhs (0, 0, &lval2);
- } else {
- /* We need an lvalue */
- Error (ERR_LVALUE_EXPECTED);
- }
-
- /* Push the address (or whatever is in ax in case of errors) */
- g_push (CF_PTR | CF_UNSIGNED, 0);
-
- /* Check for equality of the structs */
- if (!EqualTypes (ltype, lval2.e_tptr)) {
- Error (ERR_INCOMPATIBLE_TYPES);
- }
-
- /* Load the size of the struct into the primary */
- g_getimmed (CF_INT | CF_UNSIGNED | CF_CONST, SizeOf (ltype), 0);
-
- /* Call the memcpy function */
- g_call (CF_FIXARGC, "memcpy", 4);
-
- } else {
-
- /* Get the address on stack if needed */
- PushAddr (lval);
-
- /* No struct, setup flags for the load */
- flags = SizeOf (ltype) == 1? CF_FORCECHAR : CF_NONE;
-
- /* Get the expression on the right of the '=' into the primary */
- if (evalexpr (flags, hie1, &lval2) == 0) {
- /* Constant expression. Adjust the types */
- assignadjust (ltype, &lval2);
- /* Put the value into the primary register */
- lconst (flags, &lval2);
- } else {
- /* Expression is not constant and already in the primary */
- assignadjust (ltype, &lval2);
- }
-
- /* Generate a store instruction */
- store (lval);
-
- }
-
- /* Value is still in primary */
- lval->e_flags = E_MEXPR;
-}
-
-
-
-int hie1 (struct expent* lval)