Exemplo n.º 1
0
IHqlExpression * addFilter(IHqlExpression * dataset, IHqlExpression * limitField)
{
    IHqlExpression * lower = createConstant(limitField->queryType()->castFrom(true, (__int64)0));
    lower = createValue(no_colon, lower, createValue(no_stored, createConstant(LOWER_LIMIT_ID)));
    lower = createSymbol(createIdentifierAtom(LOWER_LIMIT_ID), lower, ob_private);
    dataset = createDataset(no_filter, LINK(dataset), createBoolExpr(no_ge, LINK(limitField), lower));

    IHqlExpression * upper = createConstant((int)DISKREAD_PAGE_SIZE);
    upper = createValue(no_colon, upper, createValue(no_stored, createConstant(RECORD_LIMIT_ID)));
    upper = createSymbol(createIdentifierAtom(RECORD_LIMIT_ID), upper, ob_private);
    dataset = createDataset(no_choosen, dataset, upper);
    dataset = createSymbol(createIdentifierAtom("_Filtered_"), dataset, ob_private);
    return dataset;
}
Exemplo n.º 2
0
void add_builtins () {
  pushLevel();
  add_builtin_types();
  add_builtin_functions();
  /**
   * What to do with these? Consts
   * true
   * false
   * maxint
   * minint
   * pi
   */
   
  symbol *booleanTypeDescription = getType ("boolean");
  
  symbol *oddFunctionSymbol = calloc (1, sizeof (symbol));
  GPtrArray *oddParam = g_ptr_array_new ();
  struct function_desc *funcDescription = createFunctionDesc (oddParam, 
    booleanTypeDescription, 1);
  symbol *oddSymbol = createSymbol ("odd", booleanTypeDescription, OC_FUNC, funcDescription);
  addSymbol ("odd", oddSymbol);


  printf ("Type class of odd: %d\n", getTypeClass (oddSymbol));
  printf ("Done adding builtins\n");
  showAllSymbols();
  printf ("done showing all symbols\n");
  //exit (EXIT_SUCCESS);
}
Exemplo n.º 3
0
RFedd2P::RFedd2P()
{
  Description = QObject::tr("equation defined 2-port RF device");

  Model = "RFEDD2P";
  Name  = "RF";

  // first properties !!!
  Props.append(new Property("Type", "Y", false,
		QObject::tr("type of parameters")+" [Y, Z, S, H, G, A, T]"));
  Props.append(new Property("duringDC", "open", false,
		QObject::tr("representation during DC analysis")+
			    " [open, short, unspecified, zerofrequency]"));

  // last properties
  Props.append(new Property("P11", "0", false,
		QObject::tr("parameter equation") + " 11"));
  Props.append(new Property("P12", "0", false,
		QObject::tr("parameter equation") + " 12"));
  Props.append(new Property("P21", "0", false,
		QObject::tr("parameter equation") + " 21"));
  Props.append(new Property("P22", "0", false,
		QObject::tr("parameter equation") + " 22"));

  createSymbol();
}
Exemplo n.º 4
0
Resistor::Resistor(bool european)
{
  Description = QObject::tr("resistor");

  Props.append(new Property("R", "50 Ohm", true,
    QObject::tr("ohmic resistance in Ohms")));
  Props.append(new Property("Temp", "26.85", false,
    QObject::tr("simulation temperature in degree Celsius")));
  Props.append(new Property("Tc1", "0.0", false,
    QObject::tr("first order temperature coefficient")));
  Props.append(new Property("Tc2", "0.0", false,
    QObject::tr("second order temperature coefficient")));
  Props.append(new Property("Tnom", "26.85", false,
    QObject::tr("temperature at which parameters were extracted")));

  // this must be the last property in the list !!!
  Props.append(new Property("Symbol", "european", false,
        QObject::tr("schematic symbol")+" [european, US]"));
  if(!european)  Props.getLast()->Value = "US";

  createSymbol();
  tx = x1+4;
  ty = y2+4;
  Model = "R";
  SpiceModel = "R";
  Name  = "R";
}
Exemplo n.º 5
0
MStee::MStee()
{
  Description = QObject::tr("microstrip tee");

  x1 = -30; y1 = -11;
  x2 =  30; y2 =  30;

  QFontMetrics metrics(QucsSettings.font);   // get size of text
  tx = x1+4;
  ty = y1 - 5*metrics.lineSpacing() - 4;
  Model = "MTEE";
  Name  = "MS";

  Props.append(new Property("Subst", "Subst1", true,
		QObject::tr("substrate")));
  Props.append(new Property("W1", "1 mm", true,
		QObject::tr("width of line 1")));
  Props.append(new Property("W2", "1 mm", true,
		QObject::tr("width of line 2")));
  Props.append(new Property("W3", "2 mm", true,
		QObject::tr("width of line 3")));
  Props.append(new Property("MSModel", "Hammerstad", false,
	QObject::tr("quasi-static microstrip model")+
	" [Hammerstad, Wheeler, Schneider]"));
  Props.append(new Property("MSDispModel", "Kirschning", false,
	QObject::tr("microstrip dispersion model")+" [Kirschning, Kobayashi, "
	"Yamashita, Hammerstad, Getsinger, Schneider, Pramanick]"));
  Props.append(new Property("Temp", "26.85", false,
		QObject::tr("temperature in degree Celsius")));
  Props.append(new Property("Symbol", "showNumbers", false,
	QObject::tr("show port numbers in symbol or not")+
	" [showNumbers, noNumbers]"));

  createSymbol();
}
Exemplo n.º 6
0
MScross::MScross()
{
  Description = QObject::tr("microstrip cross");

  Model = "MCROSS";
  Name  = "MS";

  Props.append(new Property("Subst", "Subst1", true,
		QObject::tr("substrate")));
  Props.append(new Property("W1", "1 mm", true,
		QObject::tr("width of line 1")));
  Props.append(new Property("W2", "2 mm", true,
		QObject::tr("width of line 2")));
  Props.append(new Property("W3", "1 mm", true,
		QObject::tr("width of line 3")));
  Props.append(new Property("W4", "2 mm", true,
		QObject::tr("width of line 4")));
  Props.append(new Property("MSModel", "Hammerstad", false,
	QObject::tr("quasi-static microstrip model")+
	" [Hammerstad, Wheeler, Schneider]"));
  Props.append(new Property("MSDispModel", "Kirschning", false,
	QObject::tr("microstrip dispersion model")+" [Kirschning, Kobayashi, "
	"Yamashita, Hammerstad, Getsinger, Schneider, Pramanick]"));
  Props.append(new Property("Symbol", "showNumbers", false,
	QObject::tr("show port numbers in symbol or not")+
	" [showNumbers, noNumbers]"));

  createSymbol();
}
Exemplo n.º 7
0
bool symbolChooser::changeSymbol(const triC& color, int newIndex) {

  const QRgb rgbColor = color.qrgb();
  const QHash<QRgb, patternSymbolIndex>::const_iterator it =
    symbolMap_.find(rgbColor);
  if (it != symbolMap_.end()) {
    const int oldIndex = it.value().index();
    if (oldIndex == newIndex) {
      return true;
    }
    // make sure the new index is available
    if (!colorIndex_.indexIsAvailable(newIndex)) {
      return false;
    }
    // free the old index
    colorIndex_.free(oldIndex);
    symbolMap_.remove(rgbColor);
    colorIndex_.reserve(newIndex);
    symbolMap_.insert(rgbColor,
                      patternSymbolIndex(createSymbol(newIndex, rgbColor),
                                         newIndex, borderDimension_,
                                         symbolDimension_));
    return true;
  }
  else {
    qWarning() << "Unreserved color in symbolChooser::changeSymbol" <<
      ::ctos(color) << newIndex;
    return false;
  }
}
Exemplo n.º 8
0
/**
 * \brief Entry point.
 * \param argc The number of input parameters.
 * \param argv The input parameters.
 */
int main(int argc, char *argv[]) {

	/* the resource manager must be initialized before any
	 * further actions are implemented */
	rm_init(&resource_mgr);

	if (process_options(argc, argv) == 1) {
		rm_cleanup_resources(&resource_mgr);
		exit(EXIT_FAILURE);
	}

	if (cc_options.print_only_errors != 1) {
		printf("Input: %s\n", cc_options.input_file);
		printf("Output: %s\n", cc_options.output_file);
		printf("IR: %s\n", cc_options.ir_file);
	}

	yyin = fopen(cc_options.input_file, "r");
	if (!yyin) {
		fprintf(stderr,
				"Input file could not be opened for reading. Maybe, file does not exist?");
	} else {
		setSymbolTable(createSymbol());
		yyparse();
		fclose(yyin);
		irCode_t* ircode = NULL;

		if (cc_options.ir_file != NULL) {
			FILE *irFile;
			irFile = fopen(cc_options.ir_file, "w+");

			// Test symbolTable
			print_symTab(irFile);

			// get ir code and print it into irFile
			struct func_t *func, *tmp;
			HASH_ITER(hh, getSymbolTable()->symFunc, func, tmp) {
				if (func->symbol != NULL) {
					fprintf(irFile, "Function %s:\n", func->id);
					printIRCode(irFile, func->symbol->ircode);
				}
			}

			fclose(irFile);
		}

		yyout = fopen(cc_options.output_file, "w+");
		if (!yyout) {
			fprintf(stderr,
					"Output file could not be opened for writing. Maybe, file does not exist?");
		} else {
			int ret = mips32gen(yyout, ircode, getSymbolTable());
			if (ret != 0) {
				fprintf(stderr, "Error generating mips32 code with code: %d\n",
						ret);
			}
			fclose(yyout);
		}
	}
Exemplo n.º 9
0
MOSFET_sub::MOSFET_sub()
{
  Description = QObject::tr("MOS field-effect transistor with substrate");
  createSymbol();
  tx = x2+4;
  ty = y1+4;
  Model = "MOSFET";
}
Exemplo n.º 10
0
BJTsub::BJTsub()
{
  Description = QObject::tr("bipolar junction transistor with substrate");
  createSymbol();
  tx = x2+4;
  ty = y1+4;
  Model = "BJT";
}
Exemplo n.º 11
0
MOSFET::MOSFET()
{
  // properties obtained from "Basic_MOSFET" in mosfet_sub.cpp
  Description = QObject::tr("MOS field-effect transistor");
  createSymbol();
  tx = x2+4;
  ty = y1+4;
  Model = "_MOSFET";
}
Exemplo n.º 12
0
Logical_NAND::Logical_NAND()
{
  Description = QObject::tr("logical NAND");
  Model = "NAND";

  createSymbol();
  tx = x1+4;
  ty = y2+4;
}
Exemplo n.º 13
0
IHqlExpression * buildWorkUnitViewerEcl(IHqlExpression * record, const char * wuid, unsigned sequence, const char * name)
{
    OwnedHqlExpr newRecord = createSymbol(createIdentifierAtom("_SourceRecord_"), LINK(record), ob_private);
    IHqlExpression * arg = name ? createConstant(name) : createConstant((int)sequence);
    OwnedHqlExpr dataset = createDataset(no_workunit_dataset, newRecord.getLink(), createComma(createConstant(wuid), arg));
    OwnedHqlExpr projected = addSimplifyProject(dataset);
    OwnedHqlExpr output = addOutput(projected);
    return output.getClear();
}
Exemplo n.º 14
0
IHqlExpression * addSimplifyProject(IHqlExpression * dataset)
{
    IHqlExpression * record = dataset->queryRecord();
    IHqlExpression * projectRecord = getSimplifiedRecord(record, false);
    if (!projectRecord)
        return LINK(dataset);

    projectRecord = createSymbol(createIdentifierAtom("_TargetRecord_"), projectRecord, ob_private);
    return createDataset(no_newusertable, LINK(dataset), createComma(projectRecord, getSimplifiedTransform(projectRecord, record, dataset)));
}
Exemplo n.º 15
0
Symbol *getTmpSym(Table *curTable, long yylineno)
{
	Symbol *retSym;
	char *newName = (char *)newTmp();
	int sRes = lookup(curTable, newName, &retSym);
	if ( sRes != NOTFOUND )
		return retSym;
	retSym = createSymbol(TMP, newName, yylineno);
	insToTable(curTable, retSym);
	return retSym;
}
Exemplo n.º 16
0
void buildTable(char filename[]){
  if(filename==NULL){ //no filename, empty table.
return;
}
FILE *file=fopen(filename,"r");

if(file==NULL){
fprintf(stderr,"Error loading symbol table\n");
exit(EXIT_FAILURE);
}

int i=0;
if(!feof(file)){
  for(;i<MAX_SYMBOLS;i++){
    char *token_type=calloc(1,1024);
    char *token_name=calloc(1,1024);
    char *token_value=calloc(1,1024);

    if(fscanf(file, "%s %s %s", token_type, token_name, token_value)!=3){
      break;
    }


    if(strcmp(token_type,"int")==0){
      Symbol int_symbol=createSymbol(TYPE_INT, token_name, token_value);
      symbol[i]=int_symbol;
    }else if(strcmp(token_type,"double")==0){
      Symbol double_symbol=createSymbol(TYPE_DOUBLE, token_name, token_value);
      symbol[i]=double_symbol;
    }
  }
}


number_of_symbols=i;

fclose(file);

return;

}
Exemplo n.º 17
0
/*
    readDeclaration reads a declaration of a class
*/
static void readClassDeclaration()
{   
    ObjectHandle classObj, metaObj, vars;
    std::string className, superName;
    int i, size, instanceTop;
    // todo: fixed length variables array!
    ObjectHandle instanceVariables[15];
    // todo: horrible fixed length arrays!
    char metaClassName[100];
    char metaSuperClassName[100];

    if (ll.nextToken() != nameconst)
        sysError("bad file format","no name in declaration");
    className = ll.strToken();
    if (ll.nextToken() == nameconst) 
    { /* read superclass name */
        superName = ll.strToken();
        ll.nextToken();
    }
    // todo: sprintf eradication!
    sprintf(metaClassName, "Meta%s", className.c_str());
    if(!superName.empty())
        sprintf(metaSuperClassName, "Meta%s", superName.c_str());
    else
        sprintf(metaSuperClassName, "Class");

    metaObj = createRawClass(metaClassName, "Class", metaSuperClassName);
    classObj = createRawClass(className.c_str(), metaClassName, superName.c_str());
    classObj->_class = metaObj;

    // Get the current class size, we'll build on this as 
    // we add instance variables.
    size = getInteger(classObj->basicAt(sizeInClass));

    if (ll.currentToken() == nameconst) 
    {     /* read instance var names */
        instanceTop = 0;
        while (ll.currentToken() == nameconst) 
        {
            instanceVariables[instanceTop++] = createSymbol(ll.strToken().c_str());
            size++;
            ll.nextToken();
        }
        vars = newArray(instanceTop);
        for (i = 0; i < instanceTop; i++) 
        {
            vars->basicAtPut(i+1, instanceVariables[i]);
        }
        classObj->basicAtPut(variablesInClass, vars);
    }
    classObj->basicAtPut(sizeInClass, newInteger(size));
    classObj->basicAtPut(methodsInClass, newDictionary(39));
}
Exemplo n.º 18
0
/*!
 * \brief vacomponent::vacomponent
 * \param filename File (JSON) containing the symbol paintins and properties.
 */
vacomponent::vacomponent(QString filename)
{
  QString data = getData(filename);

  /// \todo check if JSON is error free
  /// \todo Need to destroy engine?
  QScriptEngine engine;
  QScriptValue vadata = engine.evaluate("(" + data + ")");

  Description = getString(vadata, "description");

  QScriptValue entries = vadata.property("property");

  QScriptValueIterator it(entries);

  while (it.hasNext()) {
    it.next();

    QScriptValue entry = it.value();

    // skip length named iterate
    if (it.name().compare("length")) {
      QString name = getString(entry, "name");
      QString value = getString(entry, "value");
      QString display = getString(entry, "display");
      QString desc = getString(entry, "desc");
      // QString unit = getString(entry, "unit");

      /// \todo append units to description

      bool show;
      if (!display.compare("false"))
        show = false;
      else
        show = true;

      /// \todo what if there are no properties?

      Props.append (new Property (name, value, show, desc));
    }
  }

  createSymbol(filename);

  Model = getString(vadata, "Model");
  Name  = getString(vadata, "SymName");

  /// TODO adjust location of text
  tx = x1+100;
  ty = y1+20;
}
Exemplo n.º 19
0
logic_1::logic_1()
{
  Type = isComponent; // Analogue and digital component.
  Description = QObject::tr ("logic 1 verilog device");

 Props.append (new Property ("LEVEL", "1", false,
    QObject::tr ("logic 1 voltage level")
    +" ("+QObject::tr ("V")+")"));
  createSymbol ();
  tx = x1 + 4;
  ty = y2 + 4;
  Model = "logic_1";
  Name  = "S";
}
Exemplo n.º 20
0
pad3bit::pad3bit()
{
  Type = isComponent; // Analogue and digital component.
  Description = QObject::tr ("3bit pattern generator verilog device");

  Props.append (new Property ("Number", "0", false,
    QObject::tr ("pad output value")));
 
  createSymbol ();
  tx = x1 + 4;
  ty = y2 + 4;
  Model = "pad3bit";
  Name  = "Y";
}
Exemplo n.º 21
0
/*
    readRawDeclaration reads a declaration of a class
*/
static void readRawClassDeclaration()
{   
    ObjectHandle classObj, vars;
    std::string className, metaName, superName;
    int i, size, instanceTop;
    // todo: fixed length variables array!
    ObjectHandle instanceVariables[15];

    if (ll.nextToken() != nameconst)
        sysError("bad file format","no name in declaration");
    className = ll.strToken();
    size = 0;
    if (ll.nextToken() == nameconst) 
    { /* read metaclass name */
        metaName = ll.strToken();
        ll.nextToken();
    }
    if (ll.currentToken() == nameconst) 
    { /* read superclass name */
        superName = ll.strToken();
        ll.nextToken();
    }

    classObj = createRawClass(className.c_str(), metaName.c_str(), superName.c_str());

    // Get the current class size, we'll build on this as 
    // we add instance variables.
    size = getInteger(classObj->basicAt(sizeInClass));

    if (ll.currentToken() == nameconst) 
    {     /* read instance var names */
        instanceTop = 0;
        while (ll.currentToken() == nameconst) 
        {
            instanceVariables[instanceTop++] = createSymbol(ll.strToken().c_str());
            size++;
            ll.nextToken();
        }
        vars = newArray(instanceTop);
        for (i = 0; i < instanceTop; i++) 
        {
            vars->basicAtPut(i+1, instanceVariables[i]);
        }
        classObj->basicAtPut(variablesInClass, vars);
    }
    classObj->basicAtPut(sizeInClass, newInteger(size));
    classObj->basicAtPut(methodsInClass, newDictionary(39));
}
Exemplo n.º 22
0
DLS_1ton::DLS_1ton()
{
  Description = QObject::tr ("data voltage level shifter (digital to analogue) verilog device");

  Props.append (new Property ("LEVEL", "5 V", false,
    QObject::tr ("voltage level")));
  Props.append (new Property ("Delay", "1 ns", false,
    QObject::tr ("time delay")
    +" ("+QObject::tr ("s")+")"));

  createSymbol ();
  tx = x1 + 14;
  ty = y2 + 4;
  Model = "DLS_1ton";
  Name  = "Y";
}
Exemplo n.º 23
0
QVector<patternSymbolIndex> symbolChooser::
symbolsAvailable(const triC& color, int symbolDim) {

  symbolDimension_ = symbolDim;
  QVector<patternSymbolIndex> availableSymbols;
  const QRgb rgbColor = color.qrgb();
  const QList<int> availableIndices = colorIndex_.availableIndices();
  for (QList<int>::const_iterator it = availableIndices.begin(),
         end = availableIndices.end(); it != end; ++it) {
    availableSymbols.push_back(patternSymbolIndex(createSymbol(*it,
                                                               rgbColor),
                                                  *it, borderDimension_,
                                                  symbolDimension_));
  }
  return availableSymbols;
}
Exemplo n.º 24
0
greytobinary4bit::greytobinary4bit()
{
  Type = isComponent; // Analogue and digital component.
  Description = QObject::tr ("4bit grey to binary converter verilog device");

  Props.append (new Property ("TR", "6", false,
    QObject::tr ("transfer function scaling factor")));
  Props.append (new Property ("Delay", "1 ns", false,
    QObject::tr ("output delay")
    +" ("+QObject::tr ("s")+")"));

  createSymbol ();
  tx = x1 + 19;
  ty = y2 + 4;
  Model = "greytobinary4bit";
  Name  = "Y";
}
Exemplo n.º 25
0
hpribin4bit::hpribin4bit()
{
  Type = isComponent; // Analogue and digital component.
  Description = QObject::tr ("4bit highest priority encoder (binary form) verilog device");

  Props.append (new Property ("TR", "6", false,
    QObject::tr ("transfer function scaling factor")));
  Props.append (new Property ("Delay", "1 ns", false,
    QObject::tr ("output delay")
    +" ("+QObject::tr ("s")+")"));

  createSymbol ();
  tx = x1 + 19;
  ty = y2 + 4;
  Model = "hpribin4bit";
  Name  = "Y";
}
Exemplo n.º 26
0
fa1b::fa1b()
{
  Type = isComponent; // Analogue and digital component.
  Description = QObject::tr ("1bit full adder verilog device");

  Props.append (new Property ("TR", "6", false,
    QObject::tr ("transfer function high scaling factor")));
  Props.append (new Property ("Delay", "1 ns", false,
    QObject::tr ("output delay")
    +" ("+QObject::tr ("s")+")"));
 
  createSymbol ();
  tx = x1 + 19;
  ty = y2 + 4;
  Model = "fa1b";
  Name  = "Y";
}
Exemplo n.º 27
0
Capacitor::Capacitor()
{
  Description = QObject::tr("capacitor");

  Props.append(new Property("C", "1 pF", true,
		QObject::tr("capacitance in Farad")));
  Props.append(new Property("V", "", false,
		QObject::tr("initial voltage for transient simulation")));
  Props.append(new Property("Symbol", "neutral", false,
	QObject::tr("schematic symbol")+" [neutral, polar]"));

  createSymbol();
  tx = x1+4;
  ty = y2+4;
  Model = "C";
  Name  = "C";
}
Exemplo n.º 28
0
SubCirPort::SubCirPort()
{
  Type = isComponent;   // both analog and digital
  Description = QObject::tr("port of a subcircuit");

  // This property must be the first one !
  Props.append(new Property("Num", "1", true,
		QObject::tr("number of the port within the subcircuit")));
  // This property must be the second one !
  Props.append(new Property("Type", "analog", false,
		QObject::tr("type of the port (for digital simulation only)")
		+" [analog, in, out, inout]"));

  createSymbol();
  tx = x1+4;
  ty = y2+4;
  Model = "Port";
  Name  = "P";
}
Exemplo n.º 29
0
gatedDlatch::gatedDlatch()
{
  Type = isComponent; // Analogue and digital component.
  Description = QObject::tr ("gated D latch verilog device");

  Props.append (new Property ("TR_H", "6", false,
    QObject::tr ("cross coupled gate transfer function high scaling factor")));
  Props.append (new Property ("TR_L", "5", false,
    QObject::tr ("cross coupled gate transfer function low scaling factor")));
  Props.append (new Property ("Delay", "1 ns", false,
    QObject::tr ("cross coupled gate delay")
    +" ("+QObject::tr ("s")+")"));

  createSymbol ();
  tx = x1 + 19;
  ty = y2 + 4;
  Model = "gatedDlatch";
  Name  = "Y";
}
Exemplo n.º 30
0
IHqlExpression * buildDiskFileViewerEcl(const char * logicalName, IHqlExpression * record)
{
    //Add filepos to the incomming record structure...
    IHqlExpression * filePosAttr = createAttribute(virtualAtom, createAttribute(filepositionAtom));
    OwnedHqlExpr filepos = createField(fileposName, makeIntType(8, false), NULL, filePosAttr);
    IHqlExpression * sizeofAttr = createAttribute(virtualAtom, createAttribute(sizeofAtom));
    OwnedHqlExpr reclen = createField(recordlenName, makeIntType(2, false), NULL, sizeofAttr);
    HqlExprArray fields;
    unwindChildren(fields, record);
    fields.append(*filepos.getLink());
    fields.append(*reclen.getLink());

    OwnedHqlExpr newRecord = createRecord(fields);
    newRecord.setown(createSymbol(createIdentifierAtom("_SourceRecord_"), newRecord.getLink(), ob_private));

    OwnedHqlExpr dataset = createNewDataset(createConstant(logicalName), newRecord.getLink(), createValue(no_thor), NULL, NULL, NULL);
    OwnedHqlExpr filtered = addFilter(dataset, filepos);
    OwnedHqlExpr projected = addSimplifyProject(filtered);
    OwnedHqlExpr output = addOutput(projected);
    return output.getClear();
}