1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-25 13:29:41 +00:00

Removed ExprLoad to LoadExpr.

Moved LoadExpr + support functions into a separate module.
Removed obsolete files.
Some cleanup and makefile adjustments.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3113 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2004-06-09 14:12:57 +00:00
parent e3f63219a1
commit 8752f0b2c1
15 changed files with 70 additions and 1228 deletions

View File

@ -39,6 +39,7 @@
#include "datatype.h"
#include "error.h"
#include "expr.h"
#include "loadexpr.h"
#include "scanner.h"
#include "stdnames.h"
#include "typecmp.h"
@ -55,7 +56,7 @@
void Assignment (ExprDesc* Expr)
/* Parse an assignment */
{
ExprDesc lval2;
ExprDesc Expr2;
type* ltype = Expr->Type;
@ -96,27 +97,27 @@ void Assignment (ExprDesc* Expr)
if (UseReg) {
PushAddr (Expr);
} else {
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
g_push (CF_PTR | CF_UNSIGNED, 0);
}
/* Get the expression on the right of the '=' into the primary */
hie1 (&lval2);
hie1 (&Expr2);
/* Check for equality of the structs */
if (TypeCmp (ltype, lval2.Type) < TC_STRICT_COMPATIBLE) {
if (TypeCmp (ltype, Expr2.Type) < TC_STRICT_COMPATIBLE) {
Error ("Incompatible types");
}
/* Check if the right hand side is an lvalue */
if (ED_IsLVal (&lval2)) {
if (ED_IsLVal (&Expr2)) {
/* We have an lvalue. Do we copy using the primary? */
if (UseReg) {
/* Just use the replacement type */
lval2.Type = stype;
Expr2.Type = stype;
/* Load the value into the primary */
ExprLoad (CF_FORCECHAR, &lval2);
LoadExpr (CF_FORCECHAR, &Expr2);
/* Store it into the new location */
Store (Expr, stype);
@ -124,8 +125,8 @@ void Assignment (ExprDesc* Expr)
} else {
/* We will use memcpy. Push the address of the rhs */
ED_MakeRVal (&lval2);
ExprLoad (CF_NONE, &lval2);
ED_MakeRVal (&Expr2);
LoadExpr (CF_NONE, &Expr2);
/* Push the address (or whatever is in ax in case of errors) */
g_push (CF_PTR | CF_UNSIGNED, 0);
@ -162,13 +163,13 @@ void Assignment (ExprDesc* Expr)
PushAddr (Expr);
/* Read the expression on the right side of the '=' */
hie1 (&lval2);
hie1 (&Expr2);
/* Do type conversion if necessary */
TypeConversion (&lval2, ltype);
TypeConversion (&Expr2, ltype);
/* If necessary, load the value into the primary register */
ExprLoad (CF_NONE, &lval2);
LoadExpr (CF_NONE, &Expr2);
/* Generate a store instruction */
Store (Expr, 0);

View File

@ -25,6 +25,7 @@
#include "function.h"
#include "global.h"
#include "litpool.h"
#include "loadexpr.h"
#include "macrotab.h"
#include "preproc.h"
#include "scanner.h"
@ -226,47 +227,6 @@ void DefineData (ExprDesc* Expr)
static void LoadConstant (unsigned Flags, ExprDesc* Expr)
/* Load the primary register with some constant value. */
{
switch (ED_GetLoc (Expr)) {
case E_LOC_ABS:
/* Number constant */
g_getimmed (Flags | TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0);
break;
case E_LOC_GLOBAL:
/* Global symbol, load address */
g_getimmed ((Flags | CF_EXTERNAL) & ~CF_CONST, Expr->Name, Expr->IVal);
break;
case E_LOC_STATIC:
case E_LOC_LITERAL:
/* Static symbol or literal, load address */
g_getimmed ((Flags | CF_STATIC) & ~CF_CONST, Expr->Name, Expr->IVal);
break;
case E_LOC_REGISTER:
/* Register variable. Taking the address is usually not
* allowed.
*/
if (IS_Get (&AllowRegVarAddr) == 0) {
Error ("Cannot take the address of a register variable");
}
g_getimmed ((Flags | CF_REGVAR) & ~CF_CONST, Expr->Name, Expr->IVal);
case E_LOC_STACK:
g_leasp (Expr->IVal);
break;
default:
Internal ("Unknown constant type: %04X", Expr->Flags);
}
}
static int kcalc (token_t tok, long val1, long val2)
/* Calculate an operation with left and right operand constant. */
{
@ -375,93 +335,6 @@ void PushAddr (const ExprDesc* Expr)
void ExprLoad (unsigned Flags, ExprDesc* Expr)
/* Place the result of an expression into the primary register if it is not
* already there.
*/
{
if (ED_IsLVal (Expr)) {
/* Dereferenced lvalue */
Flags |= TypeOf (Expr->Type);
if (ED_NeedsTest (Expr)) {
Flags |= CF_TEST;
}
switch (ED_GetLoc (Expr)) {
case E_LOC_ABS:
/* Absolute: numeric address or const */
g_getstatic (Flags | CF_ABSOLUTE, Expr->IVal, 0);
break;
case E_LOC_GLOBAL:
/* Global variable */
g_getstatic (Flags | CF_EXTERNAL, Expr->Name, Expr->IVal);
break;
case E_LOC_STATIC:
case E_LOC_LITERAL:
/* Static variable or literal in the literal pool */
g_getstatic (Flags | CF_STATIC, Expr->Name, Expr->IVal);
break;
case E_LOC_REGISTER:
/* Register variable */
g_getstatic (Flags | CF_REGVAR, Expr->Name, Expr->IVal);
break;
case E_LOC_STACK:
/* Value on the stack */
g_getlocal (Flags, Expr->IVal);
break;
case E_LOC_PRIMARY:
/* The primary register - just test if necessary */
if (Flags & CF_TEST) {
g_test (Flags);
}
break;
case E_LOC_EXPR:
/* Reference to address in primary with offset in Expr */
g_getind (Flags, Expr->IVal);
break;
default:
Internal ("Invalid location in ExprLoad: 0x%04X", ED_GetLoc (Expr));
}
/* Expression was tested */
ED_TestDone (Expr);
} else {
/* An rvalue */
if (ED_IsLocExpr (Expr)) {
if (Expr->IVal != 0) {
/* We have an expression in the primary plus a constant
* offset. Adjust the value in the primary accordingly.
*/
Flags |= TypeOf (Expr->Type);
g_inc (Flags | CF_CONST, Expr->IVal);
}
} else {
/* Constant of some sort, load it into the primary */
LoadConstant (Flags, Expr);
}
/* Are we testing this value? */
if (ED_NeedsTest (Expr)) {
/* Yes, force a test */
Flags |= TypeOf (Expr->Type);
g_test (Flags);
ED_TestDone (Expr);
}
}
}
static unsigned FunctionParamList (FuncDesc* Func)
/* Parse a function parameter list and pass the parameters to the called
* function. Depending on several criteria this may be done by just pushing
@ -571,7 +444,7 @@ static unsigned FunctionParamList (FuncDesc* Func)
}
/* Load the value into the primary if it is not already there */
ExprLoad (Flags, &Expr);
LoadExpr (Flags, &Expr);
/* Use the type of the argument for the push */
Flags |= TypeOf (Expr.Type);
@ -667,7 +540,7 @@ static void FunctionCall (ExprDesc* Expr)
/* Not a global or local variable, or a fastcall function. Load
* the pointer into the primary and mark it as an expression.
*/
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
ED_MakeRValExpr (Expr);
/* Remember the code position */
@ -717,7 +590,7 @@ static void FunctionCall (ExprDesc* Expr)
}
} else {
/* Load from original location */
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
}
/* Call the function */
@ -995,7 +868,7 @@ static void ArrayRef (ExprDesc* Expr)
Mark2 = 0; /* Silence gcc */
if (!ConstBaseAddr) {
/* Get a pointer to the array into the primary */
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
/* Get the array pointer on stack. Do not push more than 16
* bit, even if this value is greater, since we cannot handle
@ -1053,7 +926,7 @@ static void ArrayRef (ExprDesc* Expr)
pop (CF_PTR);
} else {
/* Get an array pointer into the primary */
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
}
if (IsClassPtr (Expr->Type)) {
@ -1081,7 +954,7 @@ static void ArrayRef (ExprDesc* Expr)
* first (if it's not already there).
*/
if (ConstBaseAddr) {
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
ED_MakeRValExpr (Expr);
}
@ -1096,7 +969,7 @@ static void ArrayRef (ExprDesc* Expr)
/* Add the subscript. Since arrays are indexed by integers,
* we will ignore the true type of the subscript here and
* use always an int. #### Use offset but beware of ExprLoad!
* use always an int. #### Use offset but beware of LoadExpr!
*/
g_inc (CF_INT | CF_CONST, SubScript.IVal);
@ -1106,7 +979,7 @@ static void ArrayRef (ExprDesc* Expr)
/* Array subscript is not constant. Load it into the primary */
Mark2 = GetCodePos ();
ExprLoad (CF_NONE, &SubScript);
LoadExpr (CF_NONE, &SubScript);
/* Do scaling */
if (IsClassPtr (Expr->Type)) {
@ -1127,7 +1000,7 @@ static void ArrayRef (ExprDesc* Expr)
*/
if (ConstBaseAddr) {
g_push (CF_INT, 0);
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
ConstBaseAddr = 0;
} else {
g_swap (CF_INT);
@ -1175,7 +1048,7 @@ static void ArrayRef (ExprDesc* Expr)
RemoveCode (Mark2);
/* Get a pointer to the array into the primary. */
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
/* Add the variable */
if (ED_IsLocStack (&SubScript)) {
@ -1264,7 +1137,7 @@ static void StructRef (ExprDesc* Expr)
if (ED_IsLVal (Expr) && IsTypePtr (Expr->Type)) {
/* Load into the primary */
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
/* Make it an lvalue expression */
ED_MakeLValExpr (Expr);
@ -1577,7 +1450,7 @@ static void PostIncDec (ExprDesc* Expr, void (*inc) (unsigned, unsigned long))
PushAddr (Expr);
/* Fetch the value and save it (since it's the result of the expression) */
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
g_save (Flags | CF_FORCECHAR);
/* If we have a pointer expression, increment by the size of the type */
@ -1628,7 +1501,7 @@ static void UnaryOp (ExprDesc* Expr)
}
} else {
/* Value is not constant */
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
/* Get the type of the expression */
Flags = TypeOf (Expr->Type);
@ -1688,7 +1561,7 @@ void hie10 (ExprDesc* Expr)
/* Not a const, load it into the primary and make it a
* calculated value.
*/
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
ED_MakeRValExpr (Expr);
}
/* If the expression is already a pointer to function, the
@ -1809,7 +1682,7 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */
g_push (ltype | CF_CONST, Expr->IVal);
} else {
/* Value not constant */
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
Mark2 = GetCodePos ();
g_push (ltype, 0);
}
@ -1905,7 +1778,7 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */
g_push (ltype | CF_CONST, Expr->IVal);
} else {
/* Value not constant */
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
Mark2 = GetCodePos ();
g_push (ltype, 0);
}
@ -2066,7 +1939,7 @@ static void parseadd (ExprDesc* Expr)
/* lhs is a constant and rhs is not constant. Load rhs into
* the primary.
*/
ExprLoad (CF_NONE, &Expr2);
LoadExpr (CF_NONE, &Expr2);
/* Beware: The check above (for lhs) lets not only pass numeric
* constants, but also constant addresses (labels), maybe even
@ -2150,7 +2023,7 @@ static void parseadd (ExprDesc* Expr)
} else {
/* Left hand side is not constant. Get the value onto the stack. */
ExprLoad (CF_NONE, Expr); /* --> primary register */
LoadExpr (CF_NONE, Expr); /* --> primary register */
Mark = GetCodePos ();
g_push (TypeOf (Expr->Type), 0); /* --> stack */
@ -2263,7 +2136,7 @@ static void parsesub (ExprDesc* Expr)
/* Remember the output queue position, then bring the value onto the stack */
Mark1 = GetCodePos ();
ExprLoad (CF_NONE, Expr); /* --> primary register */
LoadExpr (CF_NONE, Expr); /* --> primary register */
Mark2 = GetCodePos ();
g_push (TypeOf (lhst), 0); /* --> stack */
@ -2571,7 +2444,7 @@ static void hieAnd (ExprDesc* Expr, unsigned TrueLab, int* BoolOp)
}
/* Load the value */
ExprLoad (CF_FORCECHAR, Expr);
LoadExpr (CF_FORCECHAR, Expr);
/* Generate the jump */
g_falsejump (CF_NONE, lab);
@ -2587,7 +2460,7 @@ static void hieAnd (ExprDesc* Expr, unsigned TrueLab, int* BoolOp)
if (!ED_IsTested (&Expr2)) {
ED_MarkForTest (&Expr2);
}
ExprLoad (CF_FORCECHAR, &Expr2);
LoadExpr (CF_FORCECHAR, &Expr2);
/* Do short circuit evaluation */
if (CurTok.Tok == TOK_BOOL_AND) {
@ -2633,7 +2506,7 @@ static void hieOr (ExprDesc *Expr)
}
/* Get first expr */
ExprLoad (CF_FORCECHAR, Expr);
LoadExpr (CF_FORCECHAR, Expr);
/* For each expression jump to TrueLab if true. Beware: If we
* had && operators, the jump is already in place!
@ -2657,7 +2530,7 @@ static void hieOr (ExprDesc *Expr)
if (!ED_IsTested (&Expr2)) {
ED_MarkForTest (&Expr2);
}
ExprLoad (CF_FORCECHAR, &Expr2);
LoadExpr (CF_FORCECHAR, &Expr2);
/* If there is more to come, add shortcut boolean eval. */
g_truejump (CF_NONE, TrueLab);
@ -2708,7 +2581,7 @@ static void hieQuest (ExprDesc* Expr)
/* Condition codes not set, request a test */
ED_MarkForTest (Expr);
}
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
labf = GetLocalLabel ();
g_falsejump (CF_NONE, labf);
@ -2719,7 +2592,7 @@ static void hieQuest (ExprDesc* Expr)
Expr2IsNULL = ED_IsNullPtr (&Expr2);
if (!IsTypeVoid (Expr2.Type)) {
/* Load it into the primary */
ExprLoad (CF_NONE, &Expr2);
LoadExpr (CF_NONE, &Expr2);
ED_MakeRValExpr (&Expr2);
}
labt = GetLocalLabel ();
@ -2736,7 +2609,7 @@ static void hieQuest (ExprDesc* Expr)
Expr3IsNULL = ED_IsNullPtr (&Expr3);
if (!IsTypeVoid (Expr3.Type)) {
/* Load it into the primary */
ExprLoad (CF_NONE, &Expr3);
LoadExpr (CF_NONE, &Expr3);
ED_MakeRValExpr (&Expr3);
}
@ -2844,7 +2717,7 @@ static void opeq (const GenDesc* Gen, ExprDesc* Expr)
PushAddr (Expr);
/* Fetch the lhs into the primary register if needed */
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
/* Bring the lhs on stack */
Mark = GetCodePos ();
@ -2953,7 +2826,7 @@ static void addsubeq (const GenDesc* Gen, ExprDesc *Expr)
lflags |= CF_CONST;
} else {
/* Not constant, load into the primary */
ExprLoad (CF_NONE, &Expr2);
LoadExpr (CF_NONE, &Expr2);
if (MustScale) {
/* lhs is a pointer, scale rhs */
g_scale (TypeOf (Expr2.Type), CheckedSizeOf (Indirect (Expr->Type)));
@ -3102,7 +2975,7 @@ void hie0 (ExprDesc *Expr)
int evalexpr (unsigned Flags, void (*Func) (ExprDesc*), ExprDesc* Expr)
/* Will evaluate an expression via the given function. If the result is a
* constant, 0 is returned and the value is put in the Expr struct. If the
* result is not constant, ExprLoad is called to bring the value into the
* result is not constant, LoadExpr is called to bring the value into the
* primary register and 1 is returned.
*/
{
@ -3115,7 +2988,7 @@ int evalexpr (unsigned Flags, void (*Func) (ExprDesc*), ExprDesc* Expr)
return 0;
} else {
/* Not constant, load into the primary */
ExprLoad (Flags, Expr);
LoadExpr (Flags, Expr);
return 1;
}
}
@ -3126,7 +2999,7 @@ void Expression0 (ExprDesc* Expr)
/* Evaluate an expression via hie0 and put the result into the primary register */
{
ExprWithCheck (hie0, Expr);
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
}

View File

@ -33,9 +33,6 @@ void PushAddr (const ExprDesc* Expr);
* must be saved if it's not constant, before evaluating the rhs.
*/
void ExprLoad (unsigned flags, ExprDesc* Expr);
/* Put the result of an expression into the primary register */
void Store (ExprDesc* Expr, const type* StoreType);
/* Store the primary register into the location denoted by lval. If StoreType
* is given, use this type when storing instead of lval->Type. If StoreType
@ -48,7 +45,7 @@ void hie0 (ExprDesc* Expr);
int evalexpr (unsigned flags, void (*Func) (ExprDesc*), ExprDesc* Expr);
/* Will evaluate an expression via the given function. If the result is a
* constant, 0 is returned and the value is put in the lval struct. If the
* result is not constant, ExprLoad is called to bring the value into the
* result is not constant, LoadExpr is called to bring the value into the
* primary register and 1 is returned.
*/

View File

@ -1,227 +0,0 @@
/*****************************************************************************/
/* */
/* exprheap.c */
/* */
/* Expression node heap manager */
/* */
/* */
/* */
/* (C) 2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
/* common */
#include "check.h"
#include "xmalloc.h"
/* cc65 */
#include "exprheap.h"
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* A block of expression nodes */
typedef struct ExprNodeBlock ExprNodeBlock;
struct ExprNodeBlock {
ExprNodeBlock* Next; /* Pointer to next block */
unsigned Count; /* Number of nodes in the block */
unsigned Used; /* Number of nodes used */
ExprNode Nodes[1]; /* Nodes, dynamically allocated */
};
/* An expression heap */
struct ExprHeap {
ExprHeap* Last; /* Upper level expression tree */
ExprNodeBlock* BlockRoot; /* Root of node blocks */
ExprNodeBlock* BlockLast; /* Last node block */
ExprNode* FreeList; /* List of free nodes */
};
/* The current expression heap */
static ExprHeap* CurHeap = 0;
/*****************************************************************************/
/* struct ExprHeapBlock */
/*****************************************************************************/
static ExprNodeBlock* NewExprNodeBlock (unsigned Count)
/* Create a new ExprNodeBlock, initialize and return it */
{
/* Calculate the size of the memory block requested */
unsigned Size = sizeof (ExprNodeBlock) + (Count-1) * sizeof (ExprNode);
/* Allocate memory */
ExprNodeBlock* B = (ExprNodeBlock*) xmalloc (Size);
/* Initialize the fields */
B->Next = 0;
B->Count = Count;
B->Used = 0;
/* Return the new block */
return B;
}
/*****************************************************************************/
/* struct ExprHeap */
/*****************************************************************************/
static ExprHeap* NewExprHeap (void)
/* Create and return a new expression tree */
{
/* Allocate memory */
ExprHeap* H = (ExprHeap*) xmalloc (sizeof (ExprHeap));
/* Allocate the first node block */
H->BlockRoot = NewExprNodeBlock (64);
/* Initialize the remaining fields */
H->Last = 0;
H->BlockLast = H->BlockRoot;
H->FreeList = 0;
/* Return the new heap */
return H;
}
/*****************************************************************************/
/* Code */
/*****************************************************************************/
void PushExprHeap (void)
/* Create a new expression heap and push it onto the expression heap stack, so
* it is the current expression heap.
*/
{
/* Create a new heap */
ExprHeap* H = NewExprHeap ();
/* Push it onto the stack */
H->Last = CurHeap;
CurHeap = H;
}
ExprHeap* PopExprHeap (void)
/* Pop the current expression heap from the heap stack and return it */
{
ExprHeap* H;
/* Cannot pop a non existant heap */
PRECONDITION (CurHeap != 0);
/* Pop the heap */
H = CurHeap;
CurHeap = H->Last;
/* Return the old heap */
return H;
}
ExprNode* AllocExprNode (nodetype_t NT, type* Type, int LValue)
/* Get a new node from the current expression heap */
{
ExprNode* N;
/* Must have a heap */
PRECONDITION (CurHeap != 0);
/* Get a node from the freelist if possible */
if (CurHeap->FreeList) {
/* There are nodes in the free list */
N = CurHeap->FreeList;
CurHeap->FreeList = N->MData.Next;
} else {
/* Free list is empty, allocate a new node */
ExprNodeBlock* B = CurHeap->BlockLast;
if (B->Used >= B->Count) {
/* No nodes left, allocate a new node block */
B = NewExprNodeBlock (64);
CurHeap->BlockLast->Next = B;
CurHeap->BlockLast = B;
}
N = B->Nodes + B->Count++;
}
/* Initialize and return the allocated node */
return InitExprNode (N, NT, Type, LValue, CurHeap);
}
void FreeExprNode (ExprNode* N)
/* Free an expression node from the current expression heap */
{
/* There must be a heap, and the node must be from this heap */
PRECONDITION (CurHeap != 0 && N->MData.Owner == CurHeap);
/* Insert the node in the freelist invalidating the owner pointer */
N->MData.Next = CurHeap->FreeList;
CurHeap->FreeList = N;
}
void FreeExprTree (ExprNode* N)
/* Free a complete expression tree starting with the current node */
{
if (IsBranchNode (N)) {
/* Free the leaf nodes if necessary */
if ((N->NT & NT_MASK_LIST) == NT_LIST_EXPR) {
unsigned I;
unsigned Count = CollCount (&N->List);
for (I = 0; I < Count; ++I) {
FreeExprNode ((ExprNode*) CollAt (&N->List, I));
}
}
}
/* Free the node itself */
FreeExprNode (N);
}

View File

@ -1,86 +0,0 @@
/*****************************************************************************/
/* */
/* exprheap.h */
/* */
/* Expression node heap manager */
/* */
/* */
/* */
/* (C) 2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
#ifndef EXPRHEAP_H
#define EXPRHEAP_H
#include "exprnode.h"
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* An expression heap */
typedef struct ExprHeap ExprHeap;
/*****************************************************************************/
/* Code */
/*****************************************************************************/
void PushExprHeap (void);
/* Create a new expression heap and push it onto the expression heap stack, so
* it is the current expression heap.
*/
ExprHeap* PopExprHeap (void);
/* Pop the current expression heap from the heap stack and return it */
ExprNode* AllocExprNode (nodetype_t NT, type* Type, int LValue);
/* Get a new node from the current expression heap */
void FreeExprNode (ExprNode* N);
/* Free an expression node from the current expression heap */
void FreeExprTree (ExprNode* N);
/* Free a complete expression tree starting with the current node */
/* End of exprheap.h */
#endif

View File

@ -1,481 +0,0 @@
/*****************************************************************************/
/* */
/* exprnode.c */
/* */
/* Expression node structure for the cc65 C compiler */
/* */
/* */
/* */
/* (C) 2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
/* common */
#include "check.h"
/* cc65 */
#include "error.h"
#include "exprnode.h"
/*****************************************************************************/
/* Code */
/*****************************************************************************/
ExprNode* InitExprNode (ExprNode* E, nodetype_t NT, type* Type,
int LValue, struct ExprHeap* Owner)
/* Initialize a new expression node */
{
/* Intialize basic data */
E->MData.Owner = Owner;
E->NT = NT;
E->Type = Type;
E->LValue = LValue;
E->IVal = 0;
E->FVal = 0.0;
/* Initialize the expression list in the node */
InitCollection (&E->List);
/* Return the node just initialized */
return E;
}
void* GetItem (ExprNode* N, unsigned Index)
/* Return one of the items from the nodes item list */
{
return CollAt (&N->List, Index);
}
void AppendItem (ExprNode* N, void* Item)
/* Append an item to the nodes item list */
{
CollAppend (&N->List, Item);
}
void SetItem (ExprNode* N, void* Item, unsigned Index)
/* Set a specific node item. The item list is filled with null pointers as
* needed.
*/
{
if (Index >= CollCount (&N->List)) {
/* Fill up with NULL pointers */
while (Index >= CollCount (&N->List)) {
CollAppend (&N->List, 0);
}
/* Append the new item */
CollAppend (&N->List, Item);
} else {
/* There is an item with this index, replace it */
CollReplace (&N->List, Item, Index);
}
}
ExprNode* GetNode (ExprNode* N, unsigned Index)
/* Get one of the sub-nodes from the list */
{
return GetNode (N, Index);
}
ExprNode* GetLeftNode (ExprNode* N)
/* Get the left sub-node from the list */
{
return GetNode (N, IDX_LEFT);
}
void SetLeftNode (ExprNode* Root, ExprNode* Left)
/* Set the left node in Root */
{
SetItem (Root, Left, IDX_LEFT);
}
ExprNode* GetRightNode (ExprNode* N)
/* Get the right sub-node from the list */
{
return GetNode (N, IDX_RIGHT);
}
void SetRightNode (ExprNode* Root, ExprNode* Right)
/* Set the right node in Root */
{
SetItem (Root, Right, IDX_RIGHT);
}
struct SymEntry* GetNodeSym (ExprNode* N)
/* Get the symbol entry for a NT_SYM node */
{
return (struct SymEntry*) GetItem (N, IDX_SYM);
}
void SetNodeSym (ExprNode* N, struct SymEntry* Sym)
/* Set the symbol entry in a NT_SYM node */
{
SetItem (N, Sym, IDX_SYM);
}
int IsLeafNode (const ExprNode* E)
/* Return true if this is a leaf node */
{
return (E->NT & NT_MASK_LEAF) == NT_LEAF;
}
int IsBranchNode (const ExprNode* E)
/* Return true if this is a branch node */
{
return (E->NT & NT_MASK_LEAF) == NT_BRANCH;
}
void DumpExpr (FILE* F, const ExprNode* E)
/* Dump an expression in UPN notation to the given file */
{
if (IsLeafNode (E)) {
/* Operand */
switch (E->NT) {
case NT_SYM:
/* Symbol */
fprintf (F, "SYM ");
break;
case NT_CONST:
/* A constant of some sort */
if (IsClassInt (E->Type)) {
fprintf (F, "%0*lX ", SizeOf (E->Type), E->IVal);
} else if (IsClassFloat (E->Type)) {
fprintf (F, "%f ", E->FVal);
} else {
Internal ("Unknown type for NT_CONST");
}
break;
case NT_ASM:
/* Inline assembler */
fprintf (F, "ASM ");
break;
case NT_REG_A:
/* A register */
fprintf (F, "REG_A ");
break;
case NT_REG_X:
/* X register */
fprintf (F, "REG_X ");
break;
case NT_REG_Y:
/* Y register */
fprintf (F, "REG_Y ");
break;
case NT_REG_AX:
/* AX register */
fprintf (F, "REG_AX ");
break;
case NT_REG_EAX:
/* EAX register */
fprintf (F, "REG_EAX ");
break;
default:
Internal ("Unknown node type: %04X", E->NT);
break;
}
} else {
unsigned I, Count;
/* Dump the operands */
switch (E->NT & NT_MASK_LIST) {
case NT_LIST_EXPR:
Count = CollCount (&E->List);
for (I = 0; I < Count; ++I) {
DumpExpr (F, (const ExprNode*) CollConstAt (&E->List, I));
}
break;
default:
Internal ("Operator with LIST != NT_LIST_EXPR");
}
/* Dump the operator */
switch (E->NT) {
case NT_ARRAY_SUBSCRIPT:
/* Array subscript */
fprintf (F, "[] ");
break;
case NT_STRUCT_ACCESS:
/* Access of a struct field */
fprintf (F, ". ");
break;
case NT_STRUCTPTR_ACCESS:
/* Access via struct ptr */
fprintf (F, "-> ");
break;
case NT_FUNCTION_CALL:
/* Call a function */
fprintf (F, "CALL ");
break;
case NT_TYPECAST:
/* A cast */
fprintf (F, "CAST ");
break;
case NT_ADDRESS:
/* Address operator (&) */
fprintf (F, "ADDR ");
break;
case NT_INDIRECT:
/* Indirection operator (*) */
fprintf (F, "FETCH ");
break;
case NT_UNARY_MINUS:
/* - */
fprintf (F, "NEG ");
break;
case NT_COMPLEMENT:
/* ~ */
fprintf (F, "~ ");
break;
case NT_BOOL_NOT:
/* ! */
fprintf (F, "! ");
break;
case NT_PLUS:
/* + */
fprintf (F, "+ ");
break;
case NT_MINUS:
/* - */
fprintf (F, "- ");
break;
case NT_MUL:
/* * */
fprintf (F, "* ");
break;
case NT_DIV:
/* / */
fprintf (F, "/ ");
break;
case NT_SHL:
/* << */
fprintf (F, "<< ");
break;
case NT_SHR:
/* >> */
fprintf (F, ">> ");
break;
case NT_AND:
/* & */
fprintf (F, "& ");
break;
case NT_OR:
/* | */
fprintf (F, "| ");
break;
case NT_XOR:
/* ^ */
fprintf (F, "^ ");
break;
case NT_TERNARY:
/* ?: */
fprintf (F, "?: ");
break;
case NT_ASSIGN:
/* = */
fprintf (F, "= ");
break;
case NT_PLUS_ASSIGN:
/* += */
fprintf (F, "+= ");
break;
case NT_MINUS_ASSIGN:
/* -= */
fprintf (F, "-= ");
break;
case NT_MUL_ASSIGN:
/* *= */
fprintf (F, "*= ");
break;
case NT_DIV_ASSIGN:
/* /= */
fprintf (F, "/= ");
break;
case NT_SHL_ASSIGN:
/* <<= */
fprintf (F, "<<= ");
break;
case NT_SHR_ASSIGN:
/* >>= */
fprintf (F, ">>= ");
break;
case NT_AND_ASSIGN:
/* &= */
fprintf (F, "&= ");
break;
case NT_OR_ASSIGN:
/* |= */
fprintf (F, "|= ");
break;
case NT_XOR_ASSIGN:
/* ^= */
fprintf (F, "^= ");
break;
case NT_PRE_DEC:
/* -- */
fprintf (F, "<-- ");
break;
case NT_POST_DEC:
/* -- */
fprintf (F, "--> ");
break;
case NT_PRE_INC:
/* ++ */
fprintf (F, "<++ ");
break;
case NT_POST_INC:
/* ++ */
fprintf (F, "++> ");
break;
case NT_BOOL_OR:
/* || */
fprintf (F, "|| ");
break;
case NT_BOOL_AND:
/* && */
fprintf (F, "&& ");
break;
case NT_EQ:
/* == */
fprintf (F, "== ");
break;
case NT_NE:
/* != */
fprintf (F, "!= ");
break;
case NT_LT:
/* < */
fprintf (F, "< ");
break;
case NT_LE:
/* <= */
fprintf (F, "<= ");
break;
case NT_GT:
/* > */
fprintf (F, "> ");
break;
case NT_GE:
/* >= */
fprintf (F, ">= ");
break;
default:
Internal ("Unknown node type: %04X", E->NT);
break;
}
}
}

View File

@ -1,243 +0,0 @@
/*****************************************************************************/
/* */
/* exprnode.h */
/* */
/* Expression node structure for the cc65 C compiler */
/* */
/* */
/* */
/* (C) 2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
#ifndef EXPRNODE_H
#define EXPRNODE_H
/* common */
#include "coll.h"
/* cc65 */
#include "datatype.h"
/*****************************************************************************/
/* Forwards */
/*****************************************************************************/
struct ExprHeap;
struct SymEntry;
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Node types */
typedef enum {
/* Bits encoding the type of the objects stored in List for this
* particular node.
*/
NT_LIST_NONE = 0x0000, /* No items */
NT_LIST_EXPR = 0x0100, /* Items are expression nodes */
NT_LIST_SYM = 0x0200, /* Items are symbol table entries */
NT_LIST_STRING = 0x0300, /* List item are character strings */
NT_MASK_LIST = 0x0300,
/* Two bits telling if this is a leaf or a branch */
NT_LEAF = 0x0000, /* Leaf */
NT_BRANCH = 0x8000, /* Branch */
NT_MASK_LEAF = 0x8000,
/* Special node type */
NT_NONE = 0x0000, /* None (invalid) op */
/* Leaves */
NT_SYM = 0x0001 | NT_LEAF | NT_LIST_SYM, /* Symbol */
NT_CONST = 0x0002 | NT_LEAF | NT_LIST_NONE, /* A constant of some sort */
NT_ASM = 0x0003 | NT_LEAF | NT_LIST_STRING, /* Inline assembler */
NT_REG_A = 0x0005 | NT_LEAF | NT_LIST_NONE, /* A register */
NT_REG_X = 0x0006 | NT_LEAF | NT_LIST_NONE, /* X register */
NT_REG_Y = 0x0007 | NT_LEAF | NT_LIST_NONE, /* Y register */
NT_REG_AX = 0x0008 | NT_LEAF | NT_LIST_NONE, /* AX register */
NT_REG_EAX = 0x0009 | NT_LEAF | NT_LIST_NONE, /* EAX register */
/* Branches */
NT_ARRAY_SUBSCRIPT = 0x0010 | NT_BRANCH | NT_LIST_EXPR, /* Array subscript */
NT_STRUCT_ACCESS = 0x0011 | NT_BRANCH | NT_LIST_EXPR, /* Access of a struct field */
NT_STRUCTPTR_ACCESS = 0x0012 | NT_BRANCH | NT_LIST_EXPR, /* Access via struct ptr */
NT_FUNCTION_CALL = 0x0013 | NT_BRANCH | NT_LIST_EXPR, /* Call a function */
NT_TYPECAST = 0x0014 | NT_BRANCH | NT_LIST_EXPR, /* A cast */
NT_ADDRESS = 0x0015 | NT_BRANCH | NT_LIST_EXPR, /* Address operator (&) */
NT_INDIRECT = 0x0016 | NT_BRANCH | NT_LIST_EXPR, /* Indirection operator (*) */
NT_UNARY_MINUS = 0x0018 | NT_BRANCH | NT_LIST_EXPR,
NT_COMPLEMENT = 0x0019 | NT_BRANCH | NT_LIST_EXPR, /* ~ */
NT_BOOL_NOT = 0x001A | NT_BRANCH | NT_LIST_EXPR, /* ! */
NT_PLUS = 0x001B | NT_BRANCH | NT_LIST_EXPR, /* + */
NT_MINUS = 0x001C | NT_BRANCH | NT_LIST_EXPR, /* - */
NT_MUL = 0x001D | NT_BRANCH | NT_LIST_EXPR, /* * */
NT_DIV = 0x001E | NT_BRANCH | NT_LIST_EXPR, /* / */
NT_SHL = 0x001F | NT_BRANCH | NT_LIST_EXPR, /* << */
NT_SHR = 0x0020 | NT_BRANCH | NT_LIST_EXPR, /* >> */
NT_AND = 0x0021 | NT_BRANCH | NT_LIST_EXPR, /* & */
NT_OR = 0x0022 | NT_BRANCH | NT_LIST_EXPR, /* | */
NT_XOR = 0x0023 | NT_BRANCH | NT_LIST_EXPR, /* ^ */
NT_TERNARY = 0x0024 | NT_BRANCH | NT_LIST_EXPR, /* ?: */
NT_ASSIGN = 0x0025 | NT_BRANCH | NT_LIST_EXPR, /* = */
NT_PLUS_ASSIGN = 0x0026 | NT_BRANCH | NT_LIST_EXPR, /* += */
NT_MINUS_ASSIGN = 0x0027 | NT_BRANCH | NT_LIST_EXPR, /* -= */
NT_MUL_ASSIGN = 0x0028 | NT_BRANCH | NT_LIST_EXPR, /* *= */
NT_DIV_ASSIGN = 0x0029 | NT_BRANCH | NT_LIST_EXPR, /* /= */
NT_SHL_ASSIGN = 0x002A | NT_BRANCH | NT_LIST_EXPR, /* <<= */
NT_SHR_ASSIGN = 0x002B | NT_BRANCH | NT_LIST_EXPR, /* >>= */
NT_AND_ASSIGN = 0x002C | NT_BRANCH | NT_LIST_EXPR, /* &= */
NT_OR_ASSIGN = 0x002D | NT_BRANCH | NT_LIST_EXPR, /* |= */
NT_XOR_ASSIGN = 0x002E | NT_BRANCH | NT_LIST_EXPR, /* ^= */
NT_PRE_DEC = 0x002F | NT_BRANCH | NT_LIST_EXPR, /* -- */
NT_POST_DEC = 0x0030 | NT_BRANCH | NT_LIST_EXPR, /* -- */
NT_PRE_INC = 0x0031 | NT_BRANCH | NT_LIST_EXPR, /* ++ */
NT_POST_INC = 0x0032 | NT_BRANCH | NT_LIST_EXPR, /* ++ */
NT_BOOL_OR = 0x0033 | NT_BRANCH | NT_LIST_EXPR, /* || */
NT_BOOL_AND = 0x0034 | NT_BRANCH | NT_LIST_EXPR, /* && */
NT_EQ = 0x0035 | NT_BRANCH | NT_LIST_EXPR, /* == */
NT_NE = 0x0036 | NT_BRANCH | NT_LIST_EXPR, /* != */
NT_LT = 0x0037 | NT_BRANCH | NT_LIST_EXPR, /* < */
NT_LE = 0x0038 | NT_BRANCH | NT_LIST_EXPR, /* <= */
NT_GT = 0x0039 | NT_BRANCH | NT_LIST_EXPR, /* > */
NT_GE = 0x003A | NT_BRANCH | NT_LIST_EXPR, /* >= */
NT_MASK_TYPE = 0x00FF
} nodetype_t;
/* Struct describing one node in an expression tree */
typedef struct ExprNode ExprNode;
struct ExprNode {
/* Management data */
union {
struct ExprHeap* Owner; /* Heap, this node is in */
struct ExprNode* Next; /* Next in free list */
} MData;
Collection List; /* List of subexpressions */
nodetype_t NT; /* Node type */
type* Type; /* Resulting type */
int LValue; /* True if this is an lvalue */
/* Attributes */
long IVal; /* Constant int value if any */
double FVal; /* Constant float value if any */
};
/* Predefined indices for node items in List */
enum {
IDX_LEFT = 0,
IDX_RIGHT = 1,
IDX_SYM = 0
};
/* Some other constants for better readability */
enum {
RVALUE = 0,
LVALUE = 1
};
/*****************************************************************************/
/* Code */
/*****************************************************************************/
ExprNode* InitExprNode (ExprNode* E, nodetype_t NT, type* Type,
int LValue, struct ExprHeap* Owner);
/* Initialize a new expression node */
void* GetItem (ExprNode* N, unsigned Index);
/* Return one of the items from the nodes item list */
void AppendItem (ExprNode* N, void* Item);
/* Append an item to the nodes item list */
void SetItem (ExprNode* N, void* Item, unsigned Index);
/* Set a specific node item. The item list is filled with null pointers as
* needed.
*/
ExprNode* GetLeftNode (ExprNode* N);
/* Get the left sub-node from the list */
void SetLeftNode (ExprNode* Root, ExprNode* Left);
/* Set the left node in Root */
ExprNode* GetRightNode (ExprNode* N);
/* Get the right sub-node from the list */
void SetRightNode (ExprNode* Root, ExprNode* Right);
/* Set the right node in Root */
struct SymEntry* GetNodeSym (ExprNode* N);
/* Get the symbol entry for a NT_SYM node */
void SetNodeSym (ExprNode* N, struct SymEntry* Sym);
/* Set the symbol entry in a NT_SYM node */
int IsLeafNode (const ExprNode* E);
/* Return true if this is a leaf node */
int IsBranchNode (const ExprNode* E);
/* Return true if this is a branch node */
/* End of exprnode.h */
#endif

View File

@ -46,6 +46,7 @@
#include "expr.h"
#include "function.h"
#include "global.h"
#include "loadexpr.h"
#include "locals.h"
#include "stackptr.h"
#include "symtab.h"
@ -118,7 +119,7 @@ static unsigned ParseRegisterDecl (Declaration* Decl, unsigned* SC, int Reg)
TypeConversion (&Expr, Decl->Type);
/* Load the value into the primary */
ExprLoad (CF_NONE, &Expr);
LoadExpr (CF_NONE, &Expr);
/* Store the value into the variable */
g_putstatic (CF_REGVAR | TypeOf (Decl->Type), Reg, 0);
@ -219,7 +220,7 @@ static unsigned ParseAutoDecl (Declaration* Decl, unsigned* SC)
if (ED_IsConstAbsInt (&Expr)) {
Flags |= CF_CONST;
} else {
ExprLoad (CF_NONE, &Expr);
LoadExpr (CF_NONE, &Expr);
ED_MakeRVal (&Expr);
}
@ -290,7 +291,7 @@ static unsigned ParseAutoDecl (Declaration* Decl, unsigned* SC)
TypeConversion (&Expr, Decl->Type);
/* Load the value into the primary */
ExprLoad (CF_NONE, &Expr);
LoadExpr (CF_NONE, &Expr);
/* Store the value into the variable */
g_putstatic (TypeOf (Decl->Type), SymData, 0);

View File

@ -56,7 +56,6 @@ OBJS = anonname.o \
error.o \
expr.o \
exprdesc.o \
exprnode.o \
funcdesc.o \
function.o \
global.o \
@ -67,6 +66,7 @@ OBJS = anonname.o \
input.o \
lineinfo.o \
litpool.o \
loadexpr.o \
locals.o \
loop.o \
macrotab.o \

View File

@ -101,6 +101,7 @@ OBJS = anonname.obj \
input.obj \
lineinfo.obj \
litpool.obj \
loadexpr.obj \
locals.obj \
loop.obj \
macrotab.obj \

View File

@ -48,6 +48,7 @@
#include "funcdesc.h"
#include "global.h"
#include "litpool.h"
#include "loadexpr.h"
#include "scanner.h"
#include "stackptr.h"
#include "stdfunc.h"
@ -169,7 +170,7 @@ static void ParseArg (ArgDesc* Arg, type* Type)
Arg->Flags |= CF_CONST;
} else {
/* Load into the primary */
ExprLoad (CF_NONE, &Arg->Expr);
LoadExpr (CF_NONE, &Arg->Expr);
}
/* Remember the following code position */
@ -224,7 +225,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
*/
ParseArg (&Arg3, Arg3Type);
if (Arg3.Flags & CF_CONST) {
ExprLoad (CF_FORCECHAR, &Arg3.Expr);
LoadExpr (CF_NONE, &Arg3.Expr);
}
/* Emit the actual function call. This will also cleanup the stack. */
@ -527,7 +528,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
*/
ParseArg (&Arg3, Arg3Type);
if (Arg3.Flags & CF_CONST) {
ExprLoad (CF_FORCECHAR, &Arg3.Expr);
LoadExpr (CF_NONE, &Arg3.Expr);
}
/* Emit the actual function call. This will also cleanup the stack. */
@ -731,7 +732,7 @@ static void StdFunc_strcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
*/
ParseArg (&Arg2, Arg2Type);
if (Arg2.Flags & CF_CONST) {
ExprLoad (CF_FORCECHAR, &Arg2.Expr);
LoadExpr (CF_NONE, &Arg2.Expr);
}
/* Emit the actual function call. This will also cleanup the stack. */
@ -1017,7 +1018,7 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
} else if (CodeSizeFactor > 400 && IS_Get (&InlineStdFuncs)) {
/* Load the expression into the primary */
ExprLoad (CF_NONE, &Arg);
LoadExpr (CF_NONE, &Arg);
/* Inline the function */
L = GetLocalLabel ();
@ -1038,7 +1039,7 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
} else {
/* Load the expression into the primary */
ExprLoad (CF_NONE, &Arg);
LoadExpr (CF_NONE, &Arg);
/* Call the strlen function */
AddCodeLine ("jsr _%s", Func_strlen);

View File

@ -33,6 +33,7 @@
/* cc65 */
#include "stdnames.h"

View File

@ -51,6 +51,7 @@
#include "global.h"
#include "goto.h"
#include "litpool.h"
#include "loadexpr.h"
#include "locals.h"
#include "loop.h"
#include "pragma.h"
@ -293,7 +294,7 @@ static void ReturnStatement (void)
TypeConversion (&Expr, F_GetReturnType (CurrentFunc));
/* Load the value into the primary */
ExprLoad (CF_NONE, &Expr);
LoadExpr (CF_NONE, &Expr);
}
} else if (!F_HasVoidReturn (CurrentFunc) && !F_HasOldStyleIntRet (CurrentFunc)) {
@ -599,7 +600,7 @@ int Statement (int* PendingToken)
* marked as volatile. Otherwise the load is useless.
*/
if (ED_IsLVal (&Expr) && IsQualVolatile (Expr.Type)) {
ExprLoad (CF_NONE, &Expr);
LoadExpr (CF_NONE, &Expr);
}
/* If the statement didn't generate code, and is not of type
* void, emit a warning

View File

@ -32,10 +32,12 @@
/*****************************************************************************/
/* cc65 */
#include "codegen.h"
#include "error.h"
#include "expr.h"
#include "loadexpr.h"
#include "scanner.h"
#include "testexpr.h"
@ -84,7 +86,7 @@ unsigned Test (unsigned Label, int Invert)
}
/* Load the value into the primary register */
ExprLoad (CF_FORCECHAR, &Expr);
LoadExpr (CF_FORCECHAR, &Expr);
/* Generate the jump */
if (Invert) {

View File

@ -42,6 +42,7 @@
#include "declare.h"
#include "error.h"
#include "expr.h"
#include "loadexpr.h"
#include "scanner.h"
#include "typecmp.h"
#include "typeconv.h"
@ -112,7 +113,7 @@ static void DoConversion (ExprDesc* Expr, const type* NewType)
*/
if (NewSize > OldSize) {
/* Load the value into the primary */
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
/* Emit typecast code */
g_typecast (TypeOf (NewType), TypeOf (OldType));
@ -158,7 +159,7 @@ static void DoConversion (ExprDesc* Expr, const type* NewType)
if (OldSize != NewSize) {
/* Load the value into the primary */
ExprLoad (CF_NONE, Expr);
LoadExpr (CF_NONE, Expr);
/* Emit typecast code. */
g_typecast (TypeOf (NewType) | CF_FORCECHAR, TypeOf (OldType));