ValueNode_Dynamic::ValueNode_Dynamic(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); set_link("origin", ValueNode_Const::create(Vector(0,0))); set_link("force", ValueNode_Const::create(Vector(0,0))); set_link("torque", ValueNode_Const::create(Real(0.0))); set_link("damping", ValueNode_Const::create(Real(0.4))); set_link("friction", ValueNode_Const::create(Real(0.4))); set_link("spring", ValueNode_Const::create(Real(30.0))); set_link("torsion", ValueNode_Const::create(Real(30.0))); set_link("mass", ValueNode_Const::create(Real(0.3))); set_link("inertia", ValueNode_Const::create(Real(0.3))); set_link("spring_rigid",ValueNode_Const::create(false)); set_link("torsion_rigid",ValueNode_Const::create(false)); set_link("origin_drags_tip",ValueNode_Const::create(true)); if (get_type() == type_vector) set_link("tip_static",ValueNode_Const::create(value.get(Vector()))); else throw Exception::BadType(get_type().description.local_name); /* Initial values*/ state.resize(4); reset_state(Time(0.0)); /*Derivative of the base position*/ origin_d_=ValueNode_Derivative::create(ValueBase(Vector())); origin_d_->set_link("order", ValueNode_Const::create((int)(ValueNode_Derivative::SECOND))); /* Initialize the last time called to be 0*/ last_time=Time(0); }
bool CurveGradient::set_param(const String & param, const ValueBase &value) { IMPORT_VALUE(param_origin); IMPORT_VALUE(param_width); if(param=="bline" && value.get_type()==ValueBase::TYPE_LIST) { param_bline=value; bline_loop=value.get_loop(); sync(); return true; } IMPORT_VALUE(param_gradient); IMPORT_VALUE(param_loop); IMPORT_VALUE(param_zigzag); IMPORT_VALUE(param_perpendicular); IMPORT_VALUE(param_fast); if(param=="offset") return set_param("origin", value); return Layer_Composite::set_param(param,value); }
void ValueAverage::set_average_value_weighted(ValueBase &weighted_list, const ValueBase &value) { if (weighted_list.get_type() != type_list) return; ValueBase::List list = weighted_list.get_list(); if (list.empty()) return; types_namespace::TypeWeightedValueBase *t = dynamic_cast<types_namespace::TypeWeightedValueBase *>(&(list.front().get_type())); if (t == NULL) return; if (!check_weighted_type(*t)) return; ValueBase::List values_list; values_list.reserve(list.size()); std::vector<Real> weights_list; weights_list.reserve(list.size()); for(ValueBase::List::const_iterator i = list.begin(); i != list.end(); ++i) { if (i->get_type() != *t) return; weights_list.push_back( t->extract_weight(*i) ); values_list.push_back( t->extract_value(*i) ); } set_average_value_generic( values_list.begin(), values_list.end(), weights_list.begin(), weights_list.end(), value ); std::vector<Real>::const_iterator j = weights_list.begin(); for(ValueBase::List::const_iterator i = values_list.begin(); i != values_list.end(); ++i, ++j) list[i - values_list.begin()] = t->create_weighted_value(*j, *i); weighted_list = list; }
synfig::ValueNode_RadialComposite::ValueNode_RadialComposite(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); Type &type(get_type()); if (type == type_vector) { Vector vect(value.get(Vector())); set_link("r",ValueNode_Const::create(vect.mag())); set_link("t",ValueNode_Const::create(Angle(Angle::tan(vect[1],vect[0])))); } else if (type == type_color) { set_link("y",ValueNode_Const::create(value.get(Color()).get_y())); set_link("s",ValueNode_Const::create(value.get(Color()).get_s())); set_link("h",ValueNode_Const::create(value.get(Color()).get_hue())); set_link("a",ValueNode_Const::create(value.get(Color()).get_a())); } else { assert(0); throw Exception::BadType(type.description.local_name); } }
Real synfig::bline_length(const ValueBase &bline, bool bline_loop, std::vector<Real> *lengths) { BLinePoint blinepoint0, blinepoint1; const std::vector<BLinePoint> list(bline.get_list().begin(),bline.get_list().end()); int size(list.size()); if(!bline_loop) size--; if(size < 1) return Real(); // Calculate the lengths and the total length Real tl(0), l; vector<BLinePoint>::const_iterator iter, next(list.begin()); iter = bline_loop ? --list.end() : next++; for(;next!=list.end(); next++) { blinepoint0 = *iter; blinepoint1 = *next; etl::hermite<Vector> curve(blinepoint0.get_vertex(), blinepoint1.get_vertex(), blinepoint0.get_tangent2(), blinepoint1.get_tangent1()); l=curve.length(); if(lengths) lengths->push_back(l); tl+=l; iter=next; } return tl; }
bool operator()( const util::Value<T> &first, const ValueBase &second )const { // ask second for a converter from itself to Value<T> const ValueBase::Converter conv = second.getConverterTo( util::Value<T>::staticID ); if ( conv ) { //try to convert second into T and handle results util::Value<T> buff; switch ( conv->convert( second, buff ) ) { case boost::numeric::cPosOverflow: LOG( Debug, info ) << "Positive overflow when converting " << second.toString( true ) << " to " << util::Value<T>::staticName() << "."; return posOverflow( first, buff ); case boost::numeric::cNegOverflow: LOG( Debug, info ) << "Negative overflow when converting " << second.toString( true ) << " to " << util::Value<T>::staticName() << "."; return negOverflow( first, buff ); case boost::numeric::cInRange: return inRange( first, buff ); } } else { LOG( Debug, error ) << "No conversion of " << second.getTypeName() << " to " << util::Value<T>::staticName() << " available"; return false; } return false; }
ValueNode_BoneWeightPair::ValueNode_BoneWeightPair(const ValueBase &value, Canvas::LooseHandle canvas): LinkableValueNode(value.get_type()) { switch(value.get_type()) { case ValueBase::TYPE_BONE_WEIGHT_PAIR: { BoneWeightPair bone_weight_pair(value.get(BoneWeightPair())); ValueBase bone(bone_weight_pair.get_bone()); ValueNode_Bone::Handle bone_value_node; bone_value_node = ValueNode_Bone::create(bone, canvas); set_link("bone",ValueNode_Const::create(bone_value_node, canvas)); set_link("weight",ValueNode_Const::create(Real(bone_weight_pair.get_weight()))); if (getenv("SYNFIG_DEBUG_SET_PARENT_CANVAS")) printf("%s:%d set parent canvas for bwp to %lx\n", __FILE__, __LINE__, uintptr_t(canvas.get())); set_parent_canvas(canvas); ValueNode_Bone::show_bone_map(canvas, __FILE__, __LINE__, "after making new boneweightpair"); break; } default: throw Exception::BadType(ValueBase::type_local_name(value.get_type())); } }
ValueBase* NIfElseStatement::codeGen(CodeGenContext& context) { ValueBase* test = condExpr->codeGen( context ); BasicBlock *btrue = BasicBlock::Create(getGlobalContext(), "thenBlock", context.currentFunction); BasicBlock *bfalse = BasicBlock::Create(getGlobalContext(), "elseBlock", context.currentFunction); BasicBlock *bmerge = BasicBlock::Create(getGlobalContext(), "mergeStmt", context.currentFunction); auto ret = llvm::BranchInst::Create(btrue,bfalse,test->getValue(), context.currentBlock()); auto oldBlock = context.currentBlock(); context.pushBlock(btrue); auto retThen = thenBlock->codeGen(context); if (retThen == NULL){ llvm::BranchInst::Create(bmerge,context.currentBlock()); } while (context.currentBlock() != oldBlock){ context.popBlock(); } oldBlock = context.currentBlock(); context.pushBlock(bfalse); ValueBase * retElse = NULL; if (elseBlock != NULL) { retElse = elseBlock->codeGen(context); } if (retElse == NULL){ llvm::BranchInst::Create(bmerge,context.currentBlock()); } while (context.currentBlock() != oldBlock){ context.popBlock(); } context.pushBlock(bmerge); return NULL; }
ValueBase* NFunctionDeclaration::codeGen(CodeGenContext& context, const std::vector<llvm::Type*> &argTypes) { FunctionType *ftype = FunctionType::get(typeOf(type), makeArrayRef(argTypes), false); Function *function = Function::Create(ftype, GlobalValue::InternalLinkage, id.name.c_str(), context.module); BasicBlock *bblock = BasicBlock::Create(getGlobalContext(), "entry", function, 0); Function *oldFunction = context.currentFunction; context.currentFunction = function; auto oldBlock = context.currentBlock(); context.pushBlock(bblock); Function::arg_iterator argsValues = function->arg_begin(); Value* argumentValue; VariableList::const_iterator it; std::vector<llvm::Type*>::const_iterator itType = argTypes.begin(); for (it = arguments.begin(); it != arguments.end(); it++) { argumentValue = argsValues++; itType = itType ++; AllocaInst *alloc = new AllocaInst(*itType, (*it)->name.c_str(), context.currentBlock()); ValueBase* value = new LongValue(alloc); context.locals()[(*it)->name] = value; new StoreInst(argumentValue, value->getValue(), false, context.currentBlock()); } block.codeGen(context); while (context.currentBlock() != oldBlock) context.popBlock(); context.currentFunction = oldFunction; return new FunctionValue(function); }
static bool canHoistArrayArgument(ApplyInst *SemanticsCall, SILValue Arr, SILInstruction *InsertBefore, DominanceInfo *DT) { // We only know how to hoist inout, owned or guaranteed parameters. auto Convention = getSelfParameterConvention(SemanticsCall); if (Convention != ParameterConvention::Indirect_Inout && Convention != ParameterConvention::Direct_Owned && Convention != ParameterConvention::Direct_Guaranteed) return false; ValueBase *SelfVal = Arr; auto *SelfBB = SelfVal->getParentBlock(); if (DT->dominates(SelfBB, InsertBefore->getParent())) return true; if (auto LI = dyn_cast<LoadInst>(SelfVal)) { // Are we loading a value from an address in a struct defined at a point // dominating the hoist point. auto Val = LI->getOperand(); bool DoesNotDominate; StructElementAddrInst *SEI; while ((DoesNotDominate = !DT->dominates(Val->getParentBlock(), InsertBefore->getParent())) && (SEI = dyn_cast<StructElementAddrInst>(Val))) Val = SEI->getOperand(); return !DoesNotDominate; } return false; }
ValueNode_WeightedAverage::ValueNode_WeightedAverage(const ValueBase &value, Canvas::LooseHandle canvas): ValueNode_DynamicList(ValueAverage::convert_to_weighted_type(value.get_type()), value.get_type(), canvas) { if (!check_type(value.get_type())) { assert(0); throw runtime_error(get_local_name()+_(":Bad type ")+value.get_type().description.local_name); } }
ValueNode_Bone::ValueNode_Bone(const ValueBase &value, etl::loose_handle<Canvas> canvas): LinkableValueNode(value.get_type()), setup_(false) { if (getenv("SYNFIG_DEBUG_BONE_CONSTRUCTORS")) { printf("\n%s:%d ------------------------------------------------------------------------\n", __FILE__, __LINE__); printf("%s:%d --- ValueNode_Bone() for %s at %lx---\n", __FILE__, __LINE__, GET_GUID_CSTR(get_guid()), uintptr_t(this)); printf("%s:%d ------------------------------------------------------------------------\n\n", __FILE__, __LINE__); } Vocab ret(get_children_vocab()); set_children_vocab(ret); switch(value.get_type()) { case ValueBase::TYPE_BONE: { Bone bone(value.get(Bone())); String name(bone.get_name()); if (name.empty()) name = strprintf(_("Bone %d"), ++bone_counter); name = unique_name(name); set_link("name",ValueNode_Const::create(name)); #ifndef HIDE_BONE_FIELDS set_link("origin",ValueNode_Const::create(bone.get_origin())); set_link("angle",ValueNode_Const::create(bone.get_angle())); set_link("scalelx",ValueNode_Const::create(bone.get_scalelx())); set_link("scalely",ValueNode_Const::create(bone.get_scalely())); set_link("scalex",ValueNode_Const::create(bone.get_scalex())); set_link("scaley",ValueNode_Const::create(bone.get_scaley())); set_link("origin0",ValueNode_Const::create(bone.get_origin0())); set_link("angle0",ValueNode_Const::create(bone.get_angle0())); set_link("length",ValueNode_Const::create(bone.get_length())); set_link("strength",ValueNode_Const::create(bone.get_strength())); #endif ValueNode_Bone::ConstHandle parent(ValueNode_Bone::Handle::cast_const(bone.get_parent())); if (!parent) parent = get_root_bone(); set_link("parent",ValueNode_Const::create(ValueNode_Bone::Handle::cast_const(parent))); if (getenv("SYNFIG_DEBUG_BONE_MAP")) printf("%s:%d adding to canvas_map\n", __FILE__, __LINE__); canvas_map[get_root_canvas()][get_guid()] = this; if (getenv("SYNFIG_DEBUG_SET_PARENT_CANVAS")) printf("%s:%d set parent canvas for bone %lx to %lx\n", __FILE__, __LINE__, uintptr_t(this), uintptr_t(canvas.get())); set_parent_canvas(canvas); show_bone_map(get_root_canvas(), __FILE__, __LINE__, strprintf("in constructor of %s at %lx", GET_GUID_CSTR(get_guid()), uintptr_t(this))); break; } default: throw Exception::BadType(ValueBase::type_local_name(value.get_type())); } }
xmlpp::Element* encode_animated(xmlpp::Element* root,ValueNode_Animated::ConstHandle value_node,Canvas::ConstHandle canvas=0) { assert(value_node); root->set_name("animated"); root->set_attribute("type",ValueBase::type_name(value_node->get_type())); const ValueNode_Animated::WaypointList &waypoint_list=value_node->waypoint_list(); ValueNode_Animated::WaypointList::const_iterator iter; encode_interpolation(root, value_node->get_interpolation(), "interpolation"); for(iter=waypoint_list.begin();iter!=waypoint_list.end();++iter) { xmlpp::Element *waypoint_node=root->add_child("waypoint"); waypoint_node->set_attribute("time",iter->get_time().get_string()); if(iter->get_value_node()->is_exported()) waypoint_node->set_attribute("use",iter->get_value_node()->get_relative_id(canvas)); else { ValueNode::ConstHandle value_node = iter->get_value_node(); if(ValueNode_Const::ConstHandle::cast_dynamic(value_node)) { const ValueBase data = ValueNode_Const::ConstHandle::cast_dynamic(value_node)->get_value(); if (data.get_type() == ValueBase::TYPE_CANVAS) waypoint_node->set_attribute("use",data.get(Canvas::Handle()).get()->get_relative_id(canvas)); else encode_value_node(waypoint_node->add_child("value_node"),iter->get_value_node(),canvas); } else encode_value_node(waypoint_node->add_child("value_node"),iter->get_value_node(),canvas); } if (iter->get_before()!=INTERPOLATION_UNDEFINED) encode_interpolation(waypoint_node,iter->get_before(),"before"); else error("Unknown waypoint type for \"before\" attribute"); if (iter->get_after()!=INTERPOLATION_UNDEFINED) encode_interpolation(waypoint_node,iter->get_after(),"after"); else error("Unknown waypoint type for \"after\" attribute"); if(iter->get_tension()!=0.0) waypoint_node->set_attribute("tension",strprintf("%f",iter->get_tension())); if(iter->get_temporal_tension()!=0.0) waypoint_node->set_attribute("temporal-tension",strprintf("%f",iter->get_temporal_tension())); if(iter->get_continuity()!=0.0) waypoint_node->set_attribute("continuity",strprintf("%f",iter->get_continuity())); if(iter->get_bias()!=0.0) waypoint_node->set_attribute("bias",strprintf("%f",iter->get_bias())); } return root; }
ValueBase* NIdentifier::codeGen(CodeGenContext& context) { //std::cout << "Creating identifier reference: " << name << endl; ValueBase *value = context.getVar(name); if (value == NULL) { return NULL; } return createValue(value->getType(), new LoadInst(value->getValue(), "", false, context.currentBlock())); }
ValueNode_Duplicate::ValueNode_Duplicate(const ValueBase &x): LinkableValueNode(x.get_type()), index(1.0) { Vocab ret(get_children_vocab()); set_children_vocab(ret); set_link("from", ValueNode_Const::create(Real(1.0))); set_link("to", ValueNode_Const::create(x.get(Real()))); set_link("step", ValueNode_Const::create(Real(1.0))); }
ValueNode_VectorY::ValueNode_VectorY(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); if (value.get_type() == type_real) set_link("vector",ValueNode_Const::create(Vector(0, value.get(Real())))); else throw Exception::BadType(value.get_type().description.local_name); }
ValueNode_Or::ValueNode_Or(const ValueBase &x): LinkableValueNode(x.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); bool value(x.get(bool())); set_link("link1", ValueNode_Const::create(bool(false))); set_link("link2", ValueNode_Const::create(bool(false))); if (value) set_link("link1",ValueNode_Const::create(bool(true))); }
Array::Array(const Array &obj) { for (KeyValueVector::const_iterator it = obj.vector.begin(); it != obj.vector.end(); ++it) { ValueBase *v = *it; push(v); const std::string& n = v->getName(); if (n.length()) updateIndex(n, v); } #if DBG fprintf(stderr, "%s(copy) %lu\n", __func__, vector.size()); #endif }
Real synfig::std_to_hom(const ValueBase &bline, Real pos, bool index_loop, bool bline_loop) { BLinePoint blinepoint0, blinepoint1; const std::vector<BLinePoint> list(bline.get_list().begin(),bline.get_list().end()); int size = list.size(), from_vertex; // trivial cases if(pos == 0.0 || pos == 1.0) return pos; if(!bline_loop) size--; if(size < 1) return Real(); Real int_pos((int)pos); Real one(0.0); if (index_loop) { pos = pos - int_pos; if (pos < 0) { pos++; one=1.0; } } else { if (pos < 0) pos = 0; if (pos > 1) pos = 1; } // Calculate the lengths and the total length Real tl=0, pl=0; std::vector<Real> lengths; vector<BLinePoint>::const_iterator iter, next; tl=bline_length(bline, bline_loop, &lengths); // If the total length of the bline is zero return pos if(tl==0.0) return pos; from_vertex = int(pos*size); // Calculate the partial length until the bezier that holds the current std::vector<Real>::const_iterator liter(lengths.begin()); for(int i=0;i<from_vertex; i++, liter++) pl+=*liter; // Calculate the remaining length of the position over current bezier // Setup the curve of the current bezier. next=list.begin(); iter = bline_loop ? --list.end() : next++; if (from_vertex > size-1) from_vertex = size-1; // if we are at the end of the last bezier blinepoint0 = from_vertex ? *(next+from_vertex-1) : *iter; blinepoint1 = *(next+from_vertex); etl::hermite<Vector> curve(blinepoint0.get_vertex(), blinepoint1.get_vertex(), blinepoint0.get_tangent2(), blinepoint1.get_tangent1()); // add the distance on the bezier we are on. pl+=curve.find_distance(0.0, pos*size - from_vertex); // and return the homogenous position return int_pos+pl/tl-one; }
bool synfig::Layer_Bitmap::set_param(const String & param, const ValueBase & value) { IMPORT_VALUE(param_tl); IMPORT_VALUE(param_br); IMPORT_VALUE(param_c); IMPORT_VALUE_PLUS(param_gamma_adjust, if(param=="gamma_adjust"&& value.get_type()==ValueBase::TYPE_REAL) { param_gamma_adjust.set(Real(1.0/value.get(Real()))); return true; } );
ValueNode_VectorLength::ValueNode_VectorLength(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); switch(value.get_type()) { case ValueBase::TYPE_REAL: set_link("vector",ValueNode_Const::create(Vector(value.get(Real()), 0))); break; default: throw Exception::BadType(ValueBase::type_local_name(value.get_type())); } }
synfig::ValueNode_TwoTone::ValueNode_TwoTone(const ValueBase &value):LinkableValueNode(synfig::type_gradient) { Vocab ret(get_children_vocab()); set_children_vocab(ret); if (value.get_type() == type_gradient) { set_link("color1",ValueNode_Const::create(value.get(Gradient())(0))); set_link("color2",ValueNode_Const::create(value.get(Gradient())(1))); } else { throw Exception::BadType(value.get_type().description.local_name); } }
synfig::ValueNode_Add::ValueNode_Add(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); set_link("scalar",ValueNode_Const::create(Real(1.0))); Type& type(value.get_type()); if (type == type_angle) { set_link("lhs",ValueNode_Const::create(value.get(Angle()))); set_link("rhs",ValueNode_Const::create(Angle::deg(0))); } else if (type == type_color) { set_link("lhs",ValueNode_Const::create(value.get(Color()))); set_link("rhs",ValueNode_Const::create(Color(0,0,0,0))); } else if (type == type_gradient) { set_link("lhs",ValueNode_Const::create(value.get(Gradient()))); set_link("rhs",ValueNode_Const::create(Gradient())); } else if (type == type_integer) { set_link("lhs",ValueNode_Const::create(value.get(int()))); set_link("rhs",ValueNode_Const::create(int(0))); } else if (type == type_real) { set_link("lhs",ValueNode_Const::create(value.get(Real()))); set_link("rhs",ValueNode_Const::create(Real(0))); } else if (type == type_time) { set_link("lhs",ValueNode_Const::create(value.get(Time()))); set_link("rhs",ValueNode_Const::create(Time(0))); } else if (type == type_vector) { set_link("lhs",ValueNode_Const::create(value.get(Vector()))); set_link("rhs",ValueNode_Const::create(Vector(0,0))); } else { assert(0); throw runtime_error(get_local_name()+_(":Bad type ")+type.description.local_name); } }
bool Layer_Polygon::set_param(const String & param, const ValueBase &value) { if( param=="vector_list" && param_vector_list.get_type()==value.get_type()) { param_vector_list=value; Layer_Shape::clear(); add_polygon(value.get_list_of(Vector())); sync(); return true; } return Layer_Shape::set_param(param,value); }
ValueNode_Scale::ValueNode_Scale(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); set_link("scalar",ValueNode::Handle(ValueNode_Const::create(Real(1.0)))); Type &type(value.get_type()); if (type == type_angle) set_link("link",ValueNode_Const::create(value.get(Angle()))); else if (type == type_color) set_link("link",ValueNode_Const::create(value.get(Color()))); else if (type == type_integer) set_link("link",ValueNode_Const::create(value.get(int()))); else if (type == type_real) set_link("link",ValueNode_Const::create(value.get(Real()))); else if (type == type_time) set_link("link",ValueNode_Const::create(value.get(Time()))); else if (type == type_vector) set_link("link",ValueNode_Const::create(value.get(Vector()))); else { assert(0); throw runtime_error(get_local_name()+_(":Bad type ")+type.description.local_name); } assert(value_node); assert(value_node->get_type()==type); assert(get_type()==type); }
synfig::ValueNode_TwoTone::ValueNode_TwoTone(const ValueBase &value):LinkableValueNode(synfig::ValueBase::TYPE_GRADIENT) { Vocab ret(get_children_vocab()); set_children_vocab(ret); switch(value.get_type()) { case ValueBase::TYPE_GRADIENT: set_link("color1",ValueNode_Const::create(value.get(Gradient())(0))); set_link("color2",ValueNode_Const::create(value.get(Gradient())(1))); break; default: throw Exception::BadType(ValueBase::type_local_name(value.get_type())); } }
ValueNode_Exp::ValueNode_Exp(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); if (value.get_type() == type_real) { set_link("exp",ValueNode_Const::create(Real(0))); set_link("scale",ValueNode_Const::create(value.get(Real()))); } else { throw Exception::BadType(value.get_type().description.local_name); } }
ValueBase* NAssignment::codeGen(CodeGenContext& context) { //std::cout << "Creating assignment for " << lhs.name << endl; ValueBase * value = context.getVar(lhs.name); if (value == NULL) { auto type = rhs.codeGen(context)->getRealType(); AllocaInst *alloc = new AllocaInst(type, lhs.name.c_str(), context.currentBlock()); value = new LongValue(alloc); context.locals()[lhs.name] = value; } ValueBase* _target = rhs.codeGen(context); new StoreInst(_target->getValue(), value->getValue(), false, context.currentBlock()); return _target; }
ValueNode_Logarithm::ValueNode_Logarithm(const ValueBase &x): LinkableValueNode(x.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); Real value(x.get(Real())); Real infinity(999999.0); Real epsilon(0.000001); value = exp(value); set_link("link", ValueNode_Const::create(Real(value))); set_link("epsilon", ValueNode_Const::create(Real(epsilon))); set_link("infinite", ValueNode_Const::create(Real(infinity))); }
ValueNode_Atan2::ValueNode_Atan2(const ValueBase &value): LinkableValueNode(value.get_type()) { Vocab ret(get_children_vocab()); set_children_vocab(ret); if (value.get_type() == type_angle) { set_link("x",ValueNode_Const::create(Angle::cos(value.get(Angle())).get())); set_link("y",ValueNode_Const::create(Angle::sin(value.get(Angle())).get())); } else { throw Exception::BadType(value.get_type().description.local_name); } }