Example #1
0
symbol_t *modulo(symbol_t *left, symbol_t *right) {
	symbol_t *leftBackup = allocTemp(0, BT_INT);
	symbol_t *rightBackup = allocTemp(0, BT_INT);
	assemblyOutput(COP" %d %d", leftBackup->address, left->address);
	assemblyOutput(COP" %d %d", rightBackup->address, right->address);

	symbol_t *tmp = binOp(DIV, left, right);
	symbol_t *res = binOp(MUL, tmp, rightBackup);

	return binOp(SOU, leftBackup, res);
}
Example #2
0
void affectation(dereferencedSymbol_t id, symbol_t *val, bool allowConst) {
	symbol_t *sym = id.symbol;

	if(id.dereferenceCount > 0) {
		symbol_t *temp;
		for(int i = 0; i < id.dereferenceCount - 1; ++i) {
			temp = allocTemp(sym->type.indirectionCount - 1, sym->type.baseType);
			temp->type.constMask = sym->type.constMask & ~(1 << sym->type.indirectionCount);
			assemblyOutput(DR2" %d %d", temp->address, sym->address);

			freeIfTemp(sym);
			sym = temp;
		}
		symbol_t cop = *sym;
		--cop.type.indirectionCount;
		checkCompatibilityForAffectation(&cop, val, allowConst);
		assemblyOutput(DR1" %d %d", sym->address, val->address);
	}
	else {
		if(id.lvalue == false) {
			yyerror("L'expression n'est pas une lvalue.");
		}
		checkCompatibilityForAffectation(sym, val, allowConst);
		assemblyOutput(COP" %d %d ; %s", sym->address, val->address, id.symbol->name);
		sym->initialized = true;
	}

	freeIfTemp(val);
}
Example #3
0
static void dbBreakItem(char *value)
{
    double dummy;
    if (duplicate) return;
    if (epicsScanDouble(value, &dummy) != 1) {
	yyerrorAbort("Non-numeric value in breaktable");
    }
    allocTemp(epicsStrDup(value));
}
Example #4
0
symbol_t *binOp(char const *op, symbol_t *s1, symbol_t *s2) {
	checkBinOp(op, s1, s2);

	symbol_t *res = allocTemp(s1->type.indirectionCount, s1->type.baseType);

	assemblyOutput("%s %d %d %d", op, res->address, s1->address, s2->address);
	freeIfTemp(s2);
	freeIfTemp(s1);

	return res;
}
Example #5
0
static void dbBreakHead(char *name)
{
    brkTable	*pbrkTable;
    GPHENTRY	*pgphentry;

    pgphentry = gphFind(pdbbase->pgpHash,name,&pdbbase->bptList);
    if(pgphentry) {
	duplicate = TRUE;
	return;
    }
    pbrkTable = dbCalloc(1,sizeof(brkTable));
    pbrkTable->name = epicsStrDup(name);
    if(ellCount(&tempList)) yyerrorAbort("dbBreakHead:tempList not empty");
    allocTemp(pbrkTable);
}
Example #6
0
static void dbMenuHead(char *name)
{
    dbMenu		*pdbMenu;
    GPHENTRY		*pgphentry;

    pgphentry = gphFind(pdbbase->pgpHash,name,&pdbbase->menuList);
    if(pgphentry) {
	duplicate = TRUE;
	return;
    }
    if(ellCount(&tempList)) yyerrorAbort("dbMenuHead: tempList not empty");
    pdbMenu = dbCalloc(1,sizeof(dbMenu));
    pdbMenu->name = epicsStrDup(name);
    allocTemp(pdbMenu);
}
Example #7
0
static void dbRecordtypeHead(char *name)
{
    dbRecordType		*pdbRecordType;
    GPHENTRY		*pgphentry;

    pgphentry = gphFind(pdbbase->pgpHash,name,&pdbbase->recordTypeList);
    if(pgphentry) {
	duplicate = TRUE;
	return;
    }
    pdbRecordType = dbCalloc(1,sizeof(dbRecordType));
    pdbRecordType->name = epicsStrDup(name);
    if (pdbbase->loadCdefs) ellInit(&pdbRecordType->cdefList);
    if(ellCount(&tempList))
	yyerrorAbort("dbRecordtypeHead tempList not empty");
    allocTemp(pdbRecordType);
}
Example #8
0
static void dbRecordtypeFieldHead(char *name,char *type)
{
    dbFldDes		*pdbFldDes;
    int			i;
    
    if(duplicate) return;
    pdbFldDes = dbCalloc(1,sizeof(dbFldDes));
    allocTemp(pdbFldDes);
    pdbFldDes->name = epicsStrDup(name);
    pdbFldDes->as_level = ASL1;
    for(i=0; i<DBF_NTYPES; i++) {
	if(strcmp(type,pamapdbfType[i].strvalue)==0) {
	    pdbFldDes->field_type = pamapdbfType[i].value;
	    return;
	}
    }
    yyerrorAbort("Illegal Field Type");
}
Example #9
0
static void dbRecordHead(char *recordType,char *name, int visible)
{
    DBENTRY		*pdbentry;
    long		status;

    pdbentry = dbAllocEntry(pdbbase);
    if(ellCount(&tempList))
	yyerrorAbort("dbRecordHead: tempList not empty");
    allocTemp(pdbentry);
    status = dbFindRecordType(pdbentry,recordType);
    if(status) {
	epicsPrintf("Record \"%s\" is of unknown type \"%s\" - ",
                    name, recordType);
	yyerrorAbort(NULL);
	return;
    }
    /*Duplicate records ok if the same type */
    status = dbCreateRecord(pdbentry,name);
    if(status==S_dbLib_recExists) {
	if(strcmp(recordType,dbGetRecordTypeName(pdbentry))!=0) {
	    epicsPrintf("Record %s already defined with different type %s\n",
                        name, dbGetRecordTypeName(pdbentry));
            yyerror(NULL);
	    duplicate = TRUE;
	    return;
	} else if (dbRecordsOnceOnly) {
	    epicsPrintf("Record \"%s\" already defined (dbRecordsOnceOnly is set)\n",
                        name);
	    yyerror(NULL);
	    duplicate = TRUE;
	}
    } else if(status) {
	epicsPrintf("Can't create record \"%s\" of type \"%s\"\n",
                     name, recordType);
	yyerrorAbort(NULL);
    }
    if(visible) dbVisibleRecord(pdbentry);
}
Example #10
0
static void dbMenuChoice(char *name,char *value)
{
    if(duplicate) return;
    allocTemp(epicsStrDup(name));
    allocTemp(epicsStrDup(value));
}
Example #11
0
symbol_t *negate(symbol_t *s) {
	symbol_t *zero = allocTemp(0, BT_INT);
	assemblyOutput(AFC" %d %d ; negate", zero->address, 0);

	return binOp(EQU, s, zero);
}