void Tptp::makeApplication(Expr& expr, std::string& name, std::vector<Expr>& args, bool term) { if (args.empty()) { // Its a constant if (isDeclared(name)) { // already appeared expr = getVariable(name); } else { Type t = term ? d_unsorted : getExprManager()->booleanType(); expr = mkVar(name, t, ExprManager::VAR_FLAG_GLOBAL); // levelZero preemptCommand(new DeclareFunctionCommand(name, expr, t)); } } else { // Its an application if (isDeclared(name)) { // already appeared expr = getVariable(name); } else { std::vector<Type> sorts(args.size(), d_unsorted); Type t = term ? d_unsorted : getExprManager()->booleanType(); t = getExprManager()->mkFunctionType(sorts, t); expr = mkVar(name, t, ExprManager::VAR_FLAG_GLOBAL); // levelZero preemptCommand(new DeclareFunctionCommand(name, expr, t)); } // args might be rationals, in which case we need to create // distinct constants of the "unsorted" sort to represent them for (size_t i = 0; i < args.size(); ++i) { if (args[i].getType().isReal() && FunctionType(expr.getType()).getArgTypes()[i] == d_unsorted) { args[i] = convertRatToUnsorted(args[i]); } } expr = getExprManager()->mkExpr(kind::APPLY_UF, expr, args); } }
FunctionRecord_Impl::FunctionRecord_Impl(const QSqlQuery& query, ProjectDatabase& database) : ObjectRecord_Impl(database, query) { OS_ASSERT(query.isValid()); OS_ASSERT(query.isActive()); OS_ASSERT(query.isSelect()); QVariant value; value = query.value(FunctionRecord::ColumnsType::problemRecordId); OS_ASSERT(value.isValid() && !value.isNull()); m_problemRecordId = value.toInt(); value = query.value(FunctionRecord::ColumnsType::functionType); OS_ASSERT(value.isValid() && !value.isNull()); m_functionType = FunctionType(value.toInt()); value = query.value(FunctionRecord::ColumnsType::functionVectorIndex); OS_ASSERT(value.isValid() && !value.isNull()); m_functionVectorIndex = value.toInt(); value = query.value(FunctionRecord::ColumnsType::functionRecordType); OS_ASSERT(value.isValid() && !value.isNull()); m_functionRecordType = FunctionRecordType(value.toInt()); }
FunctionType FunctionType::substitute(const TemplateVarMap& templateVarMap, const Predicate& selfconst) const { if (templateVarMap.empty() && selfconst.isSelfConst()) { return *this; } const auto substitutedReturnType = returnType()->substitute(templateVarMap, selfconst); bool changed = (substitutedReturnType != returnType()); TypeArray substitutedParameterTypes; for (const auto parameterType: parameterTypes()) { const auto substitutedParameterType = parameterType->substitute(templateVarMap, selfconst); changed |= (substitutedParameterType != parameterType); substitutedParameterTypes.push_back(substitutedParameterType); } auto noExceptPredicate = attributes().noExceptPredicate().substitute(templateVarMap, selfconst); changed |= (noExceptPredicate != attributes().noExceptPredicate()); if (changed) { FunctionAttributes newAttributes(attributes().isVarArg(), attributes().isMethod(), attributes().isTemplated(), std::move(noExceptPredicate)); return FunctionType(std::move(newAttributes), substitutedReturnType, std::move(substitutedParameterTypes)); } else { return *this; } }
TestFunctionType parseFunctionType() { const auto returnType = parseType(); assert(stream_.peek() == '('); stream_.consume(); llvm::SmallVector<Type, 8> argumentTypes; while (stream_.peek() != ')' && stream_.peek() != '.') { argumentTypes.push_back(parseType()); assert(stream_.peek() == ',' || stream_.peek() == ')'); if (stream_.peek() == ',') { stream_.consume(); } } llvm::SmallVector<Type, 8> varArgsTypes; const bool isVarArg = (stream_.peek() == '.'); if (isVarArg) { varArgsTypes = parseVarArgsTypes(); } assert(stream_.peek() == ')'); stream_.consume(); return TestFunctionType(FunctionType(returnType, argumentTypes, isVarArg), varArgsTypes); }
bool FunctionRecord_Impl::compareValues(const QSqlQuery& query) const { OS_ASSERT(query.isValid()); OS_ASSERT(query.isActive()); OS_ASSERT(query.isSelect()); bool result = ObjectRecord_Impl::compareValues(query); QVariant value; value = query.value(FunctionRecord::ColumnsType::problemRecordId); OS_ASSERT(value.isValid() && !value.isNull()); result = result && (m_problemRecordId == value.toInt()); value = query.value(FunctionRecord::ColumnsType::functionType); OS_ASSERT(value.isValid() && !value.isNull()); result = result && (m_functionType == FunctionType(value.toInt())); value = query.value(FunctionRecord::ColumnsType::functionVectorIndex); OS_ASSERT(value.isValid() && !value.isNull()); result = result && (m_functionVectorIndex == value.toInt()); value = query.value(FunctionRecord::ColumnsType::functionRecordType); OS_ASSERT(value.isValid() && !value.isNull()); result = result && (m_functionRecordType == FunctionRecordType(value.toInt())); return result; }
UIFunctionTable::FunctionType UIFunctionTable::Find(const String& name) const { NamedFunctionMap::const_iterator it = items.find(name); if (it != items.end()) return (*it).second; else return FunctionType(nullptr, nullptr); }
Value:: Value(const Function* fn): type(FunctionType()), base_address(0), size(sizeof(uintptr_t)), data(new uint8_t[sizeof(uintptr_t)]) { reinterpret_cast<uintptr_t&>(data) = reinterpret_cast<uintptr_t>(fn); }
FunctionType FunctionType::makeTemplated() const { if (attributes().isTemplated()) { return *this; } const bool newIsTemplated = true; FunctionAttributes newAttributes(attributes().isVarArg(), attributes().isMethod(), newIsTemplated, attributes().noExceptPredicate().copy()); return FunctionType(std::move(newAttributes), returnType(), parameterTypes().copy()); }
eth::AssemblyItem CompilerContext::virtualFunctionEntryLabel( FunctionDefinition const& _function, vector<ContractDefinition const*>::const_iterator _searchStart ) { string name = _function.name(); FunctionType functionType(_function); auto it = _searchStart; for (; it != m_inheritanceHierarchy.end(); ++it) for (FunctionDefinition const* function: (*it)->definedFunctions()) if ( function->name() == name && !function->isConstructor() && FunctionType(*function).hasEqualArgumentTypes(functionType) ) return functionEntryLabel(*function); solAssert(false, "Super function " + name + " not found."); return m_asm.newTag(); // not reached }
/* * Write generic parameters (FunctionType, Domain, Range) on a parameter list. */ int fn_common_get_params(const gs_function_t *pfn, gs_param_list *plist) { int ecode = param_write_int(plist, "FunctionType", &FunctionType(pfn)); int code; if (pfn->params.Domain) { code = param_write_float_values(plist, "Domain", pfn->params.Domain, 2 * pfn->params.m, false); if (code < 0) ecode = code; } if (pfn->params.Range) { code = param_write_float_values(plist, "Range", pfn->params.Range, 2 * pfn->params.n, false); if (code < 0) ecode = code; } return ecode; }
void BuiltIns::defineBuiltIns() { auto factory = SymbolFactory{ }; auto makeRef = [](auto&& type, bool is_const) { return VariableType(TypeFactory::getReference(type.get()), is_const); }; auto global_scope = std::make_shared<GlobalScope>(); auto int_ = factory.makeStruct("int", new StructScope("int", global_scope.get())); auto ref_int = makeRef(int_, false); auto const_ref_int = makeRef(int_, true); auto char_ = factory.makeStruct("char", new StructScope("char", global_scope.get())); auto ref_char = makeRef(char_, false); auto const_ref_char = makeRef(char_, true); auto str = factory.makeStruct("string", new StructScope("string", global_scope.get())); auto ref_str = makeRef(str, false); auto const_ref_str = makeRef(str, true); auto int_builtin = VariableType(new BuiltInTypeSymbol("~~int", Comp::config().int_size), false); auto char_builtin = VariableType(new BuiltInTypeSymbol("~~char", Comp::config().int_size), false); auto simple_traits = FunctionTraits::simple(); auto op_traits = FunctionTraits::methodOper(); auto meth_traits = FunctionTraits::method(); auto constr_traits = FunctionTraits::constructor(); auto tp = FunctionType(int_.get(), {ref_int, int_.get()}); auto void_type = std::make_unique<BuiltInTypeSymbol>("void", 0); global_scope -> define(factory.makeFunction("putchar", FunctionType(void_type.get(), {char_.get()}), simple_traits, false)); global_scope -> define(factory.makeFunction("getchar", FunctionType(int_.get(), { }), simple_traits, false)); auto string_builtin = VariableType(new BuiltInTypeSymbol("~~string", 256), false); str -> defineMember(factory.makeVariable("~~impl", string_builtin, VariableSymbolType::FIELD)); auto str_tp = FunctionType(ref_str, {ref_str, const_ref_str}); int_ -> defineMember(factory.makeVariable("~~impl", int_builtin, VariableSymbolType::FIELD)); int_ -> defineMethod(factory.makeFunction("int", FunctionType(ref_int, {ref_int}), constr_traits, false)); int_ -> defineMethod(factory.makeFunction("int", FunctionType(ref_int, {ref_int, const_ref_int}), constr_traits, false)); int_ -> defineMethod(factory.makeFunction("operator=", FunctionType(ref_int, {ref_int, const_ref_int}), op_traits, false)); int_ -> defineMethod(factory.makeFunction("operator+", tp, op_traits, false)); int_ -> defineMethod(factory.makeFunction("operator-", tp, op_traits, false)); int_ -> defineMethod(factory.makeFunction("operator*", tp, op_traits, false)); int_ -> defineMethod(factory.makeFunction("operator/", tp, op_traits, false)); int_ -> defineMethod(factory.makeFunction("operator%", tp, op_traits, false)); int_ -> defineMethod(factory.makeFunction("operator==", tp, op_traits, false)); int_ -> defineMethod(factory.makeFunction("operator!=", tp, op_traits, false)); int_ -> defineMethod(factory.makeFunction("operator&&", tp, op_traits, false)); int_ -> defineMethod(factory.makeFunction("operator||", tp, op_traits, false)); int_ -> defineMethod(factory.makeFunction("int", FunctionType(ref_int, {ref_int, char_.get()}), constr_traits, false)); char_ -> defineMember(factory.makeVariable("~~impl", char_builtin, VariableSymbolType::FIELD)); char_ -> defineMethod(factory.makeFunction("char", FunctionType(ref_char, {ref_char}), constr_traits, false)); char_ -> defineMethod(factory.makeFunction("char", FunctionType(ref_char, {ref_char, const_ref_char}), constr_traits, false)); char_ -> defineMethod(factory.makeFunction("char", FunctionType(ref_char, {ref_char, const_ref_int}), constr_traits, false)); char_ -> defineMethod(factory.makeFunction("operator=", FunctionType(ref_char, {ref_char, const_ref_char}), constr_traits, false)); str -> defineMethod(factory.makeFunction("string", str_tp, constr_traits, false)); str -> defineMethod(factory.makeFunction("length", FunctionType(int_.get(), {ref_str}), meth_traits, false)); str -> defineMethod(factory.makeFunction("operator[]", FunctionType(ref_char, {ref_str, int_.get()}), op_traits, false)); str -> defineMethod(factory.makeFunction("operator+", FunctionType(str.get(), {ref_str, const_ref_str}), op_traits, false)); str -> defineMethod(factory.makeFunction("operator=", str_tp, op_traits, false)); global_scope -> define(factory.makeFunction("print", FunctionType(void_type.get(), {const_ref_str}), simple_traits, false)); BuiltIns::int_type = int_.get(); BuiltIns::char_type = char_.get(); BuiltIns::ASCII_string_type = str.get(); BuiltIns::void_type = void_type.get(); global_scope -> define(std::move(void_type)); global_scope -> define(std::move(int_)); global_scope -> define(std::move(str)); global_scope -> define(std::move(char_)); BuiltIns::global_scope = global_scope; }
FunctionType funcType() const { return FunctionType(argtypes_->arguments(), rtype_->type()); }
void UIFunctionTable::Add(const String& name, GlobalFunctionType function, void* userData) { items[name] = FunctionType(function, userData); }
functor(generic_function_ptr func) :func_(FunctionType(func)) {}
FunctionType MethodSetElement::createFunctionType(const bool isTemplated) const { const bool isVarArg = false; const bool isMethod = !isStatic(); FunctionAttributes attributes(isVarArg, isMethod, isTemplated, noexceptPredicate().copy()); return FunctionType(std::move(attributes), returnType(), parameterTypes().copy()); }
//========================================================= bool Parser::Type () { PrintRule rule("Type"); return rule.Accept(NamedType()) || rule.Accept(FunctionType()); }
QuickTestResult::FunctionType QuickTestResult::functionType() const { return FunctionType(QTestResult::currentTestLocation()); }