static String typeString(const CXType &type) { const char *builtIn = builtinTypeName(type.kind); if (builtIn) return builtIn; if (char pointer = (type.kind == CXType_Pointer ? '*' : (type.kind == CXType_LValueReference ? '&' : 0))) { const CXType pointee = clang_getPointeeType(type); String ret = typeString(pointee); if (ret.endsWith('*') || ret.endsWith('&')) { ret += pointer; } else { ret += ' '; ret += pointer; } return ret; } if (type.kind == CXType_ConstantArray) { String arrayType = typeString(clang_getArrayElementType(type)); const long long count = clang_getNumElements(type); arrayType += '['; if (count >= 0) arrayType += String::number(count); arrayType += ']'; return arrayType; } String ret = IndexerJob::typeName(clang_getTypeDeclaration(type)); if (ret.endsWith(' ')) ret.chop(1); return ret; }
QString QReportBand::header() const { if(objectName() == "") return typeString(); else return typeString() + " - " + objectName(); }
String IndexerJob::typeName(const CXCursor &cursor) { String ret; switch (clang_getCursorKind(cursor)) { case CXCursor_FunctionTemplate: // ### If the return value is a template type we get an empty string here case CXCursor_FunctionDecl: case CXCursor_CXXMethod: ret = typeString(clang_getResultType(clang_getCursorType(cursor))); break; case CXCursor_ClassTemplate: case CXCursor_ClassDecl: case CXCursor_StructDecl: case CXCursor_UnionDecl: ret = RTags::eatString(clang_getCursorSpelling(cursor)); break; case CXCursor_FieldDecl: // ### If the return value is a template type we get an empty string here case CXCursor_VarDecl: case CXCursor_ParmDecl: ret = typeString(clang_getCursorType(cursor)); break; default: return String(); } if (!ret.isEmpty() && !ret.endsWith('*') && !ret.endsWith('&')) ret.append(' '); return ret; }
void KviWindow::savePropertiesAsDefault() { QString szGroup; getConfigGroupName(szGroup); // save also the settings for THIS specialized window if(!KviQString::equalCI(szGroup, typeString())) g_pMainWindow->saveWindowProperties(this, szGroup); g_pMainWindow->saveWindowProperties(this, typeString()); }
void Interpreter::outputTokenData(const std::string & instruction) { const Instruction & i = Lexer::tokenize(instruction, machine); std::cout << (i.label.isNull() ? "" : typeString(i.label.type) + " ") << typeString(i.opcode.type) << " " << (i.operand1.isPointer ? "@" : "") + typeString(i.operand1.type) << " " << (i.operand2.isPointer ? "@" : "") + typeString(i.operand2.type) << std::endl << (i.label.isNull() ? "" : valueString(i.label) + " ") << valueString(i.opcode) << " " << valueString(i.operand1) << " " << valueString(i.operand2) << std::endl; }
void runTest() { try { parser_.parse(0, input_); } catch (falcon::Exception& e) { setErrorMessage("parsing error: " + e.getErrorMessage()); setSuccess(e.getCode() == errorCodeExpected_); return; } falcon::JsonVal* dom = parser_.getDom(); if (!dom) { if (key_ == "") { if (errorCodeExpected_ != 0) { setErrorMessage("wrong error code"); } setSuccess(errorCodeExpected_ == 0); } else { setErrorMessage("parsing error: not a valide JSon"); setSuccess(errorCodeExpected_ == EINVAL); } return; } falcon::JsonVal* obj = (falcon::JsonVal*)dom->getObject(key_); if (!obj) { if (key_ == "") { if (errorCodeExpected_ != 0) { setErrorMessage("wrong error code"); } setSuccess(errorCodeExpected_ == 0); } else { setErrorMessage("object not found: " + key_); setSuccess(false); } return; } if (obj->_type != type_) { setErrorMessage("object type error: expected(" + typeString(type_) + ") found(" + typeString(obj->_type) + ")"); setSuccess(false); return; } if (obj->_data == data_) { setSuccess(errorCodeExpected_ == 0); } else { setErrorMessage("object do not have the same value: expected(" + data_ + ") found(" + obj->_data + ")"); setSuccess(false); } }
// ----------------------------------------------------------------------------- // Returns the property value as a bool. // If [warn_wrong_type] is true, a warning message is written to the log if the // property is not of boolean type // ----------------------------------------------------------------------------- bool Property::boolValue(bool warn_wrong_type) const { // If this is a flag, just return boolean 'true' (or equivalent) if (type_ == Type::Flag) return true; // If the value is undefined, default to false if (!has_value_) return false; // Write warning to log if needed if (warn_wrong_type && type_ != Type::Boolean) Log::warning("Requested Boolean value of a {} Property", typeString()); // Return value (convert if needed) if (type_ == Type::Boolean) return value_.Boolean; else if (type_ == Type::Int) return !!value_.Integer; else if (type_ == Type::UInt) return !!value_.Unsigned; else if (type_ == Type::Float) return !!((int)value_.Floating); else if (type_ == Type::String) { // Anything except "0", "no" or "false" is considered true return !(val_string_ == '0' || StrUtil::equalCI(val_string_, "no") || StrUtil::equalCI(val_string_, "false")); } // Return default boolean value return true; }
void XMLModelDefinitionSerializer::readActivations(TiXmlElement* activationsNode, ActionDefinition* action) { const char* tmp = 0; for (TiXmlElement* activationElem = activationsNode->FirstChildElement(); activationElem != 0; activationElem = activationElem->NextSiblingElement()) { tmp = activationElem->Attribute("type"); if (tmp) { std::string typeString(tmp); ActivationDefinition::Type type; if (typeString == "movement") { type = ActivationDefinition::MOVEMENT; } else if (typeString == "action") { type = ActivationDefinition::ACTION; } else if (typeString == "task") { type = ActivationDefinition::TASK; } else { S_LOG_WARNING("No recognized activation type: " << typeString); continue; } std::string trigger = activationElem->GetText(); action->createActivationDefinition(type, trigger); S_LOG_VERBOSE( " Add activation: " << typeString << " : " << trigger); } } }
nsWindowInfo* nsWindowMediator::MostRecentWindowInfo(const PRUnichar* inType) { PRInt32 lastTimeStamp = -1; nsAutoString typeString(inType); PRBool allWindows = !inType || typeString.IsEmpty(); // Find the most window with the highest time stamp that matches // the requested type nsWindowInfo *searchInfo, *listEnd, *foundInfo = nsnull; searchInfo = mOldestWindow; listEnd = nsnull; while (searchInfo != listEnd) { if ((allWindows || searchInfo->TypeEquals(typeString)) && searchInfo->mTimeStamp >= lastTimeStamp) { foundInfo = searchInfo; lastTimeStamp = searchInfo->mTimeStamp; } searchInfo = searchInfo->mYounger; listEnd = mOldestWindow; } return foundInfo; }
// metadata section starts at offset 0x40 and ends around 0xb0 depending on filenamelength static SymbolsMetadata parseMetadata(RBuffer *buf, int off) { SymbolsMetadata sm = { 0 }; ut8 b[0x100] = { 0 }; (void)r_buf_read_at (buf, off, b, sizeof (b)); sm.addr = off; sm.cputype = r_read_le32 (b); sm.arch = typeString (sm.cputype, &sm.bits); // eprintf ("0x%08x cputype 0x%x -> %s\n", 0x40, sm.cputype, typeString (sm.cputype)); // bits = (strstr (typeString (sm.cputype, &sm.bits), "64"))? 64: 32; sm.subtype = r_read_le32 (b + 4); sm.cpu = subtypeString (sm.subtype); // eprintf ("0x%08x subtype 0x%x -> %s\n", 0x44, sm.subtype, subtypeString (sm.subtype)); sm.n_segments = r_read_le32 (b + 8); // int count = r_read_le32 (b + 0x48); sm.namelen = r_read_le32 (b + 0xc); // eprintf ("0x%08x count %d\n", 0x48, count); // eprintf ("0x%08x strlen %d\n", 0x4c, sm.namelen); // eprintf ("0x%08x filename %s\n", 0x50, b + 16); int delta = 16; sm.segments = parseSegments (buf, off + sm.namelen + delta, sm.n_segments); sm.size = (sm.n_segments * 32) + 120; // hack to detect format ut32 nm, nm2, nm3; r_buf_read_at (buf, off + sm.size, (ut8*)&nm, sizeof (nm)); r_buf_read_at (buf, off + sm.size + 4, (ut8*)&nm2, sizeof (nm2)); r_buf_read_at (buf, off + sm.size + 8, (ut8*)&nm3, sizeof (nm3)); // eprintf ("0x%x next %x %x %x\n", off + sm.size, nm, nm2, nm3); if (r_read_le32 (&nm3) != 0xa1b22b1a) { sm.size -= 8; // is64 = true; } return sm; }
LPXLFOPER EXCEL_EXPORT xltypeString( LPXLFOPER inputa) { EXCEL_BEGIN; if (XlfExcel::Instance().IsCalledByFuncWiz()) return XlfOper(true); XlfOper input( (inputa)); double t = (clock()+0.0)/CLOCKS_PER_SEC; std::string result( typeString( input) ); t = (clock()+0.0)/CLOCKS_PER_SEC-t; CellMatrix resultCells(result); CellMatrix time(1,2); time(0,0) = "time taken"; time(0,1) = t; resultCells.PushBottom(time); return XlfOper(resultCells); EXCEL_END }
/* Property::getUnsignedValue * Returns the property value as an unsigned int. If [warn_wrong_type] * is true, a warning message is written to the log if the property is * not of integer type *******************************************************************/ unsigned Property::getUnsignedValue(bool warn_wrong_type) { // If this is a flag, just return boolean 'true' (or equivalent) if (type == PROP_FLAG) return 1; // If the value is undefined, default to 0 if (!has_value) return 0; // Write warning to log if needed if (warn_wrong_type && type != PROP_INT) wxLogMessage("Warning: Requested Integer value of a %s Property", typeString().c_str()); // Return value (convert if needed) if (type == PROP_INT) return value.Integer; else if (type == PROP_BOOL) return (int)value.Boolean; else if (type == PROP_FLOAT) return (int)value.Floating; else if (type == PROP_STRING) return atoi(CHR(val_string)); else if (type == PROP_UINT) return value.Unsigned; // Return default integer value return 0; }
/* Property::getStringValue * Returns the property value as a string. If [warn_wrong_type] is * true, a warning message is written to the log if the property is * not of string type *******************************************************************/ string Property::getStringValue(bool warn_wrong_type) { // If this is a flag, just return boolean 'true' (or equivalent) if (type == PROP_FLAG) return "1"; // If the value is undefined, default to null if (!has_value) return ""; // Write warning to log if needed if (warn_wrong_type && type != PROP_STRING) wxLogMessage("Warning: Requested String value of a %s Property", typeString().c_str()); // Return value (convert if needed) if (type == PROP_STRING) return val_string; else if (type == PROP_INT) return S_FMT("%d", value.Integer); else if (type == PROP_BOOL) { if (value.Boolean) return "true"; else return "false"; } else if (type == PROP_FLOAT) return S_FMT("%f", value.Floating); // Return default string value return wxEmptyString; }
/* Property::getBoolValue * Returns the property value as a bool. If [warn_wrong_type] is * true, a warning message is written to the log if the property is * not of boolean type *******************************************************************/ bool Property::getBoolValue(bool warn_wrong_type) { // If this is a flag, just return boolean 'true' (or equivalent) if (type == PROP_FLAG) return true; // If the value is undefined, default to false if (!has_value) return false; // Write warning to log if needed if (warn_wrong_type && type != PROP_BOOL) wxLogMessage("Warning: Requested Boolean value of a %s Property", typeString().c_str()); // Return value (convert if needed) if (type == PROP_BOOL) return value.Boolean; else if (type == PROP_INT) return !!value.Integer; else if (type == PROP_FLOAT) return !!((int)value.Floating); else if (type == PROP_STRING) { // Anything except "0", "no" or "false" is considered true if (!val_string.Cmp("0") || !val_string.CmpNoCase("no") || !val_string.CmpNoCase("false")) return false; else return true; } // Return default boolean value return true; }
// ----------------------------------------------------------------------------- // Returns the property value as an unsigned int. // If [warn_wrong_type] is true, a warning message is written to the log if the // property is not of integer type // ----------------------------------------------------------------------------- unsigned Property::unsignedValue(bool warn_wrong_type) const { // If this is a flag, just return boolean 'true' (or equivalent) if (type_ == Type::Flag) return 1; // If the value is undefined, default to 0 if (!has_value_) return 0; // Write warning to log if needed if (warn_wrong_type && type_ != Type::Int) Log::warning("Requested Integer value of a {} Property", typeString()); // Return value (convert if needed) if (type_ == Type::Int) return value_.Integer; else if (type_ == Type::Boolean) return (int)value_.Boolean; else if (type_ == Type::Float) return (int)value_.Floating; else if (type_ == Type::String) return StrUtil::asUInt(val_string_); else if (type_ == Type::UInt) return value_.Unsigned; // Return default integer value return 0; }
Tag* Presence::tag() const { if( m_subtype == Invalid ) return 0; Tag* t = new Tag( "presence" ); if( m_to ) t->addAttribute( "to", m_to.full() ); if( m_from ) t->addAttribute( "from", m_from.full() ); const std::string& type = typeString( m_subtype ); if( !type.empty() ) { if( type != "available" ) t->addAttribute( "type", type ); } else { const std::string& show = showString( m_subtype ); if( !show.empty() ) new Tag( t, "show", show ); } new Tag( t, "priority", util::int2string( m_priority ) ); getLangs( m_stati, m_status, "status", t ); StanzaExtensionList::const_iterator it = m_extensionList.begin(); for( ; it != m_extensionList.end(); ++it ) t->addChild( (*it)->tag() ); return t; }
// ----------------------------------------------------------------------------- // Returns the property value as a string. // If [warn_wrong_type] is true, a warning message is written to the log if the // property is not of string type // ----------------------------------------------------------------------------- std::string Property::stringValue(bool warn_wrong_type) const { // If this is a flag, just return boolean 'true' (or equivalent) if (type_ == Type::Flag) return "1"; // If the value is undefined, default to null if (!has_value_) return ""; // Write warning to log if needed if (warn_wrong_type && type_ != Type::String) Log::warning("Warning: Requested String value of a {} Property", typeString()); // Return value (convert if needed) if (type_ == Type::String) return val_string_; else if (type_ == Type::Int) return fmt::format("{}", value_.Integer); else if (type_ == Type::UInt) return fmt::format("{}", value_.Unsigned); else if (type_ == Type::Boolean) { if (value_.Boolean) return "true"; else return "false"; } else if (type_ == Type::Float) return fmt::format("{}", value_.Floating); // Return default string value return {}; }
Tag* Message::tag() const { if( m_subtype == Invalid ) return 0; Tag* t = new Tag( "message" ); if( m_to ) t->addAttribute( "to", m_to.full() ); if( m_from ) t->addAttribute( "from", m_from.full() ); if( !m_id.empty() ) t->addAttribute( "id", m_id ); if( !m_timestamp.empty() ) t->addAttribute( "timestamp", m_timestamp ); t->addAttribute( TYPE, typeString( m_subtype ) ); getLangs( m_bodies, m_body, "body", t ); getLangs( m_subjects, m_subject, "subject", t ); getLangs( m_htmls, m_html, "html", t ); if( !m_thread.empty() ) new Tag( t, "thread", m_thread ); StanzaExtensionList::const_iterator it = m_extensionList.begin(); for( ; it != m_extensionList.end(); ++it ) t->addChild( (*it)->tag() ); return t; }
int32 Model::SupportsMimeType(const char *type, const BObjectList<BString> *list, bool exactReason) const { ASSERT((type == 0) != (list == 0)); // pass in one or the other int32 result = kDoesNotSupportType; BFile file(EntryRef(), O_RDONLY); BAppFileInfo handlerInfo(&file); BMessage message; if (handlerInfo.GetSupportedTypes(&message) != B_OK) return kDoesNotSupportType; for (int32 index = 0; ; index++) { // check if this model lists the type of dropped document as supported const char *mimeSignature; int32 bufferLength; if (message.FindData("types", 'CSTR', index, (const void **)&mimeSignature, &bufferLength)) return result; if (IsSuperHandlerSignature(mimeSignature)) { if (!exactReason) return kSuperhandlerModel; if (result == kDoesNotSupportType) result = kSuperhandlerModel; } int32 match; if (type) { BString typeString(type); match = MatchMimeTypeString(&typeString, mimeSignature); } else match = WhileEachListItem(const_cast<BObjectList<BString> *>(list), MatchMimeTypeString, mimeSignature); // const_cast shouldnt be here, have to have it until MW cleans up if (match == kMatch) // supports the actual type, it can't get any better return kModelSupportsType; else if (match == kMatchSupertype) { if (!exactReason) return kModelSupportsSupertype; // we already know this model supports the file as a supertype, // now find out if it matches the type result = kModelSupportsSupertype; } } return result; }
void Chaser::saveToFile(QFile &file) { QString s; QString t; // Comment line s = QString("# Function entry\n"); file.writeBlock((const char*) s, s.length()); // Entry type s = QString("Entry = Function") + QString("\n"); file.writeBlock((const char*) s, s.length()); // Name s = QString("Name = ") + name() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Type s = QString("Type = ") + typeString() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Device class, device name or "Global" if (deviceClass() != NULL) { // For device class chasers we need to save only the steps because // all scenes are inside the device class for (ChaserStep* step = m_steps.first(); step != NULL; step = m_steps.next()) { s = QString("Function = ") + step->feederFunction->name() + QString("\n"); file.writeBlock((const char*) s, s.length()); } } else if (device() != NULL) { // For device chasers (that are saved in the workspace file) // write also the device name that this chaser is attached to s = QString("Device = ") + device()->name() + QString("\n"); file.writeBlock((const char*) s, s.length()); for (ChaserStep* step = m_steps.first(); step != NULL; step = m_steps.next()) { s = QString("Function = ") + step->feederFunction->name() + QString("\n"); file.writeBlock((const char*) s, s.length()); } } else { // For global chasers, write device+scene pairs for (ChaserStep* step = m_steps.first(); step != NULL; step = m_steps.next()) { // Global chasers need a device+scene pair s = QString("Device = ") + step->callerDevice->name() + QString("\n"); file.writeBlock((const char*) s, s.length()); s = QString("Function = ") + step->feederFunction->name() + QString("\n"); file.writeBlock((const char*) s, s.length()); } } }
QString Field::typeFromVariantCode() const { int type = mType; if( type == Interval ) return "qvariant_cast<Interval>(%1)"; if( type == Float ) type = Double; if( type == Image || type == Color ) return "%1.value<" + typeString() + ">()"; return QString("%1.to") + variantTypeStrings[type] + "()"; }
void partNode::dump( int chars ) const { kdDebug(5006) << QString().fill( ' ', chars ) << "+ " << typeString() << '/' << subTypeString() << endl; if ( mChild ) mChild->dump( chars + 1 ); if ( mNext ) mNext->dump( chars ); }
Json::Value toJson() const { Json::Value json; json["name"] = name(); json["type"] = typeString(); json["size"] = static_cast<Json::UInt64>(size()); return json; }
void Scene::saveToFile(QFile &file) { QString s; QString t; // Comment line s = QString("# Function entry\n"); file.writeBlock((const char*) s, s.length()); // Entry type s = QString("Entry = Function") + QString("\n"); file.writeBlock((const char*) s, s.length()); // Name s = QString("Name = ") + name() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Type s = QString("Type = ") + typeString() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Device class, device name or "Global" if (deviceClass() != NULL) { // Write only the data for device class scenes for (unsigned i = 1; i < deviceClass()->m_channels.count(); i++) { t.setNum(i); s = t + QString(" = "); t.setNum(m_values[i]); s += t + QString("\n"); file.writeBlock((const char*) s, s.length()); } } else if (device() != NULL) { // For device scenes (that are saved in the workspace file) // write also the device name that this scene is attached to s = QString("Device = ") + device()->name() + QString("\n"); file.writeBlock((const char*) s, s.length()); // Data for (unsigned i = 1; i < device()->deviceClass()->m_channels.count(); i++) { t.setNum(i); s = t + QString(" = "); t.setNum(m_values[i]); s += t + QString("\n"); file.writeBlock((const char*) s, s.length()); } } else { // For global scenes the device name is "Global" s = QString("Device = Global") + QString("\n"); file.writeBlock((const char*) s, s.length()); } }
// Convertsa Type to a string value caml_typeString(value t) { CAMLparam1(t); CAMLlocal1(r); r = caml_copy_string(typeString(Type_val(t))); CAMLreturn(r); }
bool PhpConst::parseType(const folly::dynamic& cns) { auto it = cns.find("type"); if (it != cns.items().end()) { m_kindOf = kindOfFromDynamic(it->second); m_cppType = typeString(it->second, false); return true; } return false; }
PhpFunc::PhpFunc(const folly::dynamic& d, const fbstring& className) : m_name(d["name"].asString()), m_className(className), m_func(d), m_desc(getFollyDynamicDefaultString(d, "desc", "")), m_returnRef(d.getDefault("ref", "false") == "true"), m_returnKindOf(KindOfNull), m_returnCppType("void"), m_returnPhpType("void"), m_minNumParams(0), m_numTypeChecks(0) { auto returnIt = d.find("return"); if (returnIt != d.items().end()) { auto retNode = returnIt->second; auto typeIt = retNode.find("type"); if (typeIt != retNode.items().end()) { auto type = typeIt->second; if ((type.isString()) && (type != "void") && (type != "null")) { m_returnKindOf = m_returnRef ? KindOfRef : kindOfFromDynamic(type); m_returnCppType = typeString(type, true); m_returnPhpType = phpTypeFromDataType(m_returnKindOf); } } m_returnDesc = getFollyDynamicDefaultString(retNode, "desc", ""); } auto args = d.find("args"); if (args == d.items().end() || !args->second.isArray()) { throw std::logic_error( folly::format("'{0}' must have an array field 'args'", name()).str() ); } auto ret = d.find("return"); if (ret == d.items().end() || !ret->second.isObject() || ret->second.find("type") == ret->second.items().end()) { throw std::logic_error( folly::format("'{0}' must have an array field 'return', which must have " "a string field 'type'", name()).str() ); } bool magic = isMagicMethod(); for (auto &p : args->second) { PhpParam param(p, magic); m_params.push_back(param); if (!param.hasDefault()) { ++m_minNumParams; } if (param.isCheckedType()) { ++m_numTypeChecks; } } m_flags = parseFlags(m_func["flags"]); }
bool alAuditData(unsigned typeLen, char const * type, unsigned msgLen, char const * msg, unsigned dataLen, void const * dataBlock) { StringBuffer typeString(typeLen, type); typeString.toUpperCase(); StringBuffer msgString(msgLen, msg); AuditType typeValue = findAuditType(typeString.str()); if(typeValue >= NUM_AUDIT_TYPES) return false; return AUDIT(typeValue, msgString.str(), dataLen, dataBlock); }
void KviWindow::getDefaultLogFileName(QString & szBuffer, QDate date, bool bGzip, unsigned int uDatetimeFormat) { QString szLog; // dynamic log path QString szDynamicPath = KVI_OPTION_STRING(KviOption_stringLogsDynamicPath).trimmed(); if(!szDynamicPath.isEmpty()) { KviQString::escapeKvs(&szDynamicPath, KviQString::PermitVariables | KviQString::PermitFunctions); KviKvsVariant vRet; if(KviKvsScript::evaluate(szDynamicPath, this, nullptr, &vRet)) vRet.asString(szDynamicPath); } g_pApp->getLocalKvircDirectory(szLog, KviApplication::Log, szDynamicPath); KviQString::ensureLastCharIs(szLog, KVI_PATH_SEPARATOR_CHAR); //ensure the directory exists KviFileUtils::makeDir(szLog); QString szDate; switch(uDatetimeFormat) { case 1: szDate = date.toString(Qt::ISODate); break; case 2: szDate = date.toString(Qt::SystemLocaleShortDate); break; case 0: default: szDate = date.toString("yyyy.MM.dd"); break; } szDate.replace('_', '-'); // this would confuse the log viewer KviFileUtils::cleanFileName(szDate); QString szBase; getBaseLogFileName(szBase); KviFileUtils::encodeFileName(szBase); szBase = szBase.toLower(); szBase.replace("%%2e", "%2e"); QString szTmp; if(bGzip) szTmp = "%1_%2_%3.log.gz"; else szTmp = "%1_%2_%3.log"; szLog.append(QString(szTmp).arg(typeString(), szBase, szDate)); szBuffer = szLog; }
void MultiDimArrayDeclarationAST::generateCode(CodeGenerator& codeGen, GeneratedFunction& func) { if (mLengthExpressions.size() > 2) { codeGen.codeGenError("Array creation of dimension larger than 2 is not supported."); } auto& typeChecker = codeGen.typeChecker(); int outerLocal = func.newLocal("$local$_outer_" + std::to_string(func.numLocals()), typeChecker.findType(typeString())); int subArrayLocal = func.newLocal("$local$_sub_" + std::to_string(func.numLocals()), typeChecker.findType("Int")); //Create the outer array mLengthExpressions.at(0)->generateCode(codeGen, func); func.addInstruction("NEWARR " + typeChecker.findType(typeString(mLengthExpressions.size() - 1))->vmType()); func.addInstruction("STLOC " + std::to_string(outerLocal)); int condStart = func.numInstructions(); int condIndex = -1; //Condition mLengthExpressions.at(0)->generateCode(codeGen, func); func.addInstruction("LDLOC " + std::to_string(subArrayLocal)); condIndex = func.numInstructions(); func.addInstruction("BLE"); //Body func.addInstruction("LDLOC " + std::to_string(outerLocal)); func.addInstruction("LDLOC " + std::to_string(subArrayLocal)); mLengthExpressions.at(1)->generateCode(codeGen, func); func.addInstruction("NEWARR " + typeChecker.findType(typeString(mLengthExpressions.size() - 2))->vmType()); func.addInstruction("STELEM " + typeChecker.findType(typeString(mLengthExpressions.size() - 1))->vmType()); func.addInstruction("LDLOC " + std::to_string(subArrayLocal)); func.addInstruction("LDINT 1"); func.addInstruction("ADD"); func.addInstruction("STLOC " + std::to_string(subArrayLocal)); func.addInstruction("BR " + std::to_string(condStart)); func.instruction(condIndex) += " " + std::to_string(func.numInstructions()); func.addInstruction("LDLOC " + std::to_string(outerLocal)); }