void TypeCheckerVisitor::visitReturnNode(ReturnNode* node) { if (node->returnExpr()) { node->returnExpr()->visit(this); setNodeType(node, getNodeType(node->returnExpr())); } else { setNodeType(node, VT_VOID); } }
UTI NodeConstant::checkAndLabelType() { UTI it = Nav; bool stubcopy = m_state.isClassAStub(m_state.getCompileThisIdx()); //instantiate, look up in class block; skip if stub copy and already ready. if(!stubcopy && m_constSymbol == NULL) checkForSymbol(); else { stubcopy = m_state.hasClassAStub(m_state.getCompileThisIdx()); //includes ancestors } if(m_constSymbol) { it = m_constSymbol->getUlamTypeIdx(); } else if(isReadyConstant() && stubcopy) { assert(m_state.okUTItoContinue(m_constType)); setNodeType(m_constType); //t3565, t3640, t3641, t3642, t3652 //stub copy case: still wants uti mapping it = NodeTerminal::checkAndLabelType(); } else if(stubcopy) { // still need its symbol for a value // use the member class (unlike checkForSymbol) } // map incomplete UTI if(!m_state.isComplete(it)) //reloads to recheck { std::ostringstream msg; msg << "Incomplete " << prettyNodeName().c_str() << " for type: "; msg << m_state.getUlamTypeNameBriefByIndex(it).c_str(); msg << ", used with constant symbol name '"; msg << m_state.getTokenDataAsString(m_token).c_str() << "'"; MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), WAIT); //wait until updateConstant tried. } setNodeType(it); Node::setStoreIntoAble(TBOOL_FALSE); //copy m_constant from Symbol into NodeTerminal parent. if(!isReadyConstant()) m_ready = updateConstant(); //sets ready here if(!isReadyConstant()) { it = Hzy; if(!stubcopy) m_constSymbol = NULL; //lookup again too! (e.g. inherited template instances) m_state.setGoAgain(); } return it; } //checkAndLabelType
int SHMParser::generateTree(SHMList<SHMString> list, int pos, SHMTreeNode* &root, bool first) { if (pos > list.size()) return -1; if (!root) return -1; int depth = 0; int i = 0; if (first) { root->setNodeType("fileRoot"); } else { depth = indexFirstAlnum(list[pos]); root->setLineContents(list[pos].substr(depth)); setNodeFamily(root); setNodeType(root); setNodeLineNumbers(root); setNodeAttributes(root); i = pos+1; } while (i<list.size()) { int nextDepth = indexFirstAlnum(list[i]); if (nextDepth > depth) { SHMTreeNode *nextSon = new SHMTreeNode(); nextSon->setLineStart(root->lineStart()); nextSon->setLineEnd(root->lineEnd()); i = generateTree(list, i,nextSon,false); root->appendChild(nextSon); } else { break; } } return i; }
ComTdbDiskLabelStatistics::ComTdbDiskLabelStatistics ( const char* objectName, Queue * tableOpenInfoList, Lng32 returnedRowLen, Lng32 numParts, ParallelLabelOpPartInfo *partInfo, Lng32 timeout, ex_cri_desc * given_cri_desc, ex_cri_desc * returned_cri_desc, queue_index upQueueSize, queue_index downQueueSize, Lng32 numBuffers, ULng32 bufferSize) : ComTdbParallelLabelOp(objectName, DISK_COUNT_OP, numParts, partInfo, 0, timeout, given_cri_desc, returned_cri_desc, upQueueSize, downQueueSize, numBuffers, bufferSize), tableOpenInfoList_(tableOpenInfoList), returnedRowLen_(returnedRowLen), flags_(0) { setNodeType(ComTdb::ex_DISK_LABEL_STATISTICS); tuppIndex_ = returned_cri_desc->noTuples() - 1; }
UlamValue NodeBinaryOpArithDivide::makeImmediateBinaryOp(UTI type, u32 ldata, u32 rdata, u32 len) { UlamValue rtnUV; if(rdata == 0) { MSG(getNodeLocationAsString().c_str(), "Possible Divide By Zero Attempt", ERR); rtnUV.setUlamValueTypeIdx(Nav); setNodeType(Nav); //compiler counts return rtnUV; } ULAMTYPE typEnum = m_state.getUlamTypeByIndex(type)->getUlamTypeEnum(); switch(typEnum) { case Int: rtnUV = UlamValue::makeImmediate(type, _BinOpDivideInt32(ldata, rdata, len), len); break; case Unsigned: rtnUV = UlamValue::makeImmediate(type, _BinOpDivideUnsigned32(ldata, rdata, len), len); break; case Bool: rtnUV = UlamValue::makeImmediate(type, _BinOpDivideBool32(ldata, rdata, len), len); break; case Unary: rtnUV = UlamValue::makeImmediate(type, _BinOpDivideUnary32(ldata, rdata, len), len); break; case Bits: default: m_state.abortUndefinedUlamPrimitiveType(); break; }; return rtnUV; } //makeImmediateBinaryOp
AnalyserNode::AnalyserNode(AudioContext* context, float sampleRate) : AudioBasicInspectorNode(context, sampleRate, 2) { ScriptWrappable::init(this); setNodeType(NodeTypeAnalyser); initialize(); }
UlamValue NodeBinaryOpArithRemainder::makeImmediateLongBinaryOp(UTI type, u64 ldata, u64 rdata, u32 len) { UlamValue rtnUV; if(rdata == 0) { MSG(getNodeLocationAsString().c_str(), "Possible Division By Zero Attempt in Modulus", ERR); rtnUV.setUlamValueTypeIdx(Nav); setNodeType(Nav); //compiler counts return rtnUV; } ULAMTYPE typEnum = m_state.getUlamTypeByIndex(type)->getUlamTypeEnum(); switch(typEnum) { case Int: rtnUV = UlamValue::makeImmediateLong(type, _BinOpModInt64(ldata, rdata, len), len); break; case Unsigned: rtnUV = UlamValue::makeImmediateLong(type, _BinOpModUnsigned64(ldata, rdata, len), len); break; case Bool: rtnUV = UlamValue::makeImmediateLong(type, _BinOpModBool64(ldata, rdata, len), len); break; case Unary: rtnUV = UlamValue::makeImmediateLong(type, _BinOpModUnary64(ldata, rdata, len), len); break; case Bits: default: assert(0); break; }; return rtnUV; } //makeImmediateLongBinaryOp
void NodeBinaryOpArithDivide::appendBinaryOp(UlamValue& refUV, u32 ldata, u32 rdata, u32 pos, u32 len) { if(rdata == 0) { MSG(getNodeLocationAsString().c_str(), "Possible Divide By Zero Attempt", ERR); refUV.setUlamValueTypeIdx(Nav); setNodeType(Nav); //compiler counts return; } UTI type = refUV.getUlamValueTypeIdx(); ULAMTYPE typEnum = m_state.getUlamTypeByIndex(type)->getUlamTypeEnum(); switch(typEnum) { case Int: refUV.putData(pos, len, _BinOpDivideInt32(ldata, rdata, len)); break; case Unsigned: refUV.putData(pos, len, _BinOpDivideUnsigned32(ldata, rdata, len)); break; case Bool: refUV.putData(pos, len, _BinOpDivideBool32(ldata, rdata, len)); break; case Unary: refUV.putData(pos, len, _BinOpDivideUnary32(ldata, rdata, len)); break; case Bits: default: m_state.abortUndefinedUlamPrimitiveType(); break; }; return; } //appendBinaryOp
BiquadFilterNode::BiquadFilterNode(AudioContext* context, float sampleRate) : AudioBasicProcessorNode(context, sampleRate) { // Initially setup as lowpass filter. m_processor = std::move(std::unique_ptr<WebCore::AudioProcessor>(new BiquadProcessor(context, sampleRate, 1, false))); setNodeType(NodeTypeBiquadFilter); }
Node::Node(const ZbProperty_t &zbProperty, Topology *topology) { setFlag(ItemIsMovable); setFlag(ItemIsSelectable); setFlag(ItemSendsGeometryChanges); setCacheMode(DeviceCoordinateCache); startColor.setRgba(qRgba(0, 255, 255, 255)); stopColor.setRgba(qRgba(0, 168, 168, 255)); statue = 0; //表示可移动状态 blinkStatue = 0; //表示节点没有闪烁 blinkTimer = new QTimer; connect(blinkTimer, SIGNAL(timeout()), this, SLOT(onBlink())); pressTimer = new QTimer(this); connect(pressTimer, SIGNAL(timeout()), this, SLOT(onPressTimeout())); myTopology = topology; setText(converSensorName(ZigbeeIOClass::sensorName[zbProperty.sensorType])); setNodeType(zbProperty.deviceType); setZbProperty(zbProperty); pressStaue = 0; board = NULL; }
FunctionDesc *newExternalFD(Node *type, Region *r) { FunctionDesc *desc = (FunctionDesc *) region_alloc(r, sizeof(FunctionDesc)); memset(desc, 0, sizeof(FunctionDesc)); desc->exprType = type; setNodeType(desc, N_FD_EXTERNAL); return desc; }
CArtifact::CArtifact() { setNodeType(ARTIFACT); possibleSlots[ArtBearer::HERO]; //we want to generate map entry even if it will be empty possibleSlots[ArtBearer::CREATURE]; //we want to generate map entry even if it will be empty possibleSlots[ArtBearer::COMMANDER]; }
FunctionDesc *newConstructorFD2(Node *type, Region *r) { FunctionDesc *desc = (FunctionDesc *) region_alloc(r, sizeof(FunctionDesc)); memset(desc, 0, sizeof(FunctionDesc)); desc->exprType = type; setNodeType(desc, N_FD_CONSTRUCTOR); return desc; }
Res* newRes(Region *r) { Res *res1 = (Res *) region_alloc(r,sizeof (Res)); memset(res1, 0, sizeof(Res)); setNodeType(res1, N_VAL); setIOType(res1, IO_TYPE_INPUT); return res1; }
UTI NodeBinaryOpEqualArith::checkAndLabelType() { UTI nodeType = NodeBinaryOpEqual::checkAndLabelType(); UlamType * nut = m_state.getUlamTypeByIndex(nodeType); // common part of name ULAMTYPE enodetyp = nut->getUlamTypeEnum(); if(enodetyp == Bits) { // can happen with op-equal operations when both sides are the same type MSG(getNodeLocationAsString().c_str(), "Arithmetic Operations are invalid on 'Bits' type", ERR); nodeType = Nav; } if(enodetyp == Bool) { // can happen with op-equal operations when both sides are the same type MSG(getNodeLocationAsString().c_str(), "Arithmetic Operations are invalid on 'Bool' type", ERR); nodeType = Nav; } if((nodeType != Nav) && !nut->isScalar()) { std::ostringstream msg; msg << "Non-scalars require a loop for operator" << getName(); MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR); nodeType = Nav; } setNodeType(nodeType); return nodeType; } //checkAndLabelType
void TypeCheckerVisitor::visitBinaryOpNode(BinaryOpNode* node) { AstNode* left = node->left(); AstNode* right = node->right(); left->visit(this); right->visit(this); setNodeType(node, getOperationResultType(node->kind(), left, right)); }
ScriptProcessorNode::ScriptProcessorNode(AudioContext& context, float sampleRate, size_t bufferSize, unsigned numberOfInputChannels, unsigned numberOfOutputChannels) : AudioNode(context, sampleRate) , m_doubleBufferIndex(0) , m_doubleBufferIndexForEvent(0) , m_bufferSize(bufferSize) , m_bufferReadWriteIndex(0) , m_isRequestOutstanding(false) , m_numberOfInputChannels(numberOfInputChannels) , m_numberOfOutputChannels(numberOfOutputChannels) , m_internalInputBus(AudioBus::create(numberOfInputChannels, AudioNode::ProcessingSizeInFrames, false)) , m_hasAudioProcessListener(false) { // Regardless of the allowed buffer sizes, we still need to process at the granularity of the AudioNode. if (m_bufferSize < AudioNode::ProcessingSizeInFrames) m_bufferSize = AudioNode::ProcessingSizeInFrames; ASSERT(numberOfInputChannels <= AudioContext::maxNumberOfChannels()); addInput(std::make_unique<AudioNodeInput>(this)); addOutput(std::make_unique<AudioNodeOutput>(this, numberOfOutputChannels)); setNodeType(NodeTypeJavaScript); initialize(); }
PannerNode::PannerNode(AudioContext* context, float sampleRate) : AudioNode(context, sampleRate) , m_panningModel(Panner::PanningModelHRTF) , m_distanceModel(DistanceEffect::ModelInverse) , m_position(0, 0, 0) , m_orientation(1, 0, 0) , m_velocity(0, 0, 0) , m_isAzimuthElevationDirty(true) , m_isDistanceConeGainDirty(true) , m_isDopplerRateDirty(true) , m_lastGain(-1.0) , m_cachedAzimuth(0) , m_cachedElevation(0) , m_cachedDistanceConeGain(1.0f) , m_cachedDopplerRate(1) , m_connectionCount(0) { // Load the HRTF database asynchronously so we don't block the Javascript thread while creating the HRTF database. // The HRTF panner will return zeroes until the database is loaded. m_hrtfDatabaseLoader = HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(context->sampleRate()); ScriptWrappable::init(this); addInput(); addOutput(AudioNodeOutput::create(this, 2)); // Node-specific default mixing rules. m_channelCount = 2; m_channelCountMode = ClampedMax; m_channelInterpretation = AudioBus::Speakers; setNodeType(NodeTypePanner); initialize(); }
BiquadFilterNode::BiquadFilterNode(AudioContext* context, float sampleRate) : AudioBasicProcessorNode(context, sampleRate) { // Initially setup as lowpass filter. m_processor = adoptPtr(new BiquadProcessor(context, sampleRate, 1, false)); setNodeType(NodeTypeBiquadFilter); }
AudioBufferSourceNode::AudioBufferSourceNode(AudioContext* context, float sampleRate) : AudioSourceNode(context, sampleRate) , m_buffer(0) , m_isLooping(false) , m_startTime(0.0) , m_endTime(UnknownTime) , m_virtualReadIndex(0) , m_isGrain(false) , m_grainOffset(0.0) , m_grainDuration(DefaultGrainDuration) , m_lastGain(1.0) , m_pannerNode(0) , m_playbackState(UNSCHEDULED_STATE) { setNodeType(NodeTypeAudioBufferSource); m_gain = AudioGain::create("gain", 1.0, 0.0, 1.0); m_playbackRate = AudioParam::create("playbackRate", 1.0, 0.0, MaxRate); m_gain->setContext(context); m_playbackRate->setContext(context); // Default to mono. A call to setBuffer() will set the number of output channels to that of the buffer. addOutput(adoptPtr(new AudioNodeOutput(this, 1))); initialize(); }
/////////////////////////////////////////////////////////////////////////// // // Methods for class ComTdbDDL // /////////////////////////////////////////////////////////////////////////// ComTdbDDLwithStatus::ComTdbDDLwithStatus(char * ddl_query, ULng32 ddl_querylen, Int16 ddl_querycharset, char * schemaName, ULng32 schemaNameLen, ex_expr * input_expr, ULng32 input_rowlen, ex_expr * output_expr, ULng32 output_rowlen, ex_cri_desc * work_cri_desc, const unsigned short work_atp_index, ex_cri_desc * given_cri_desc, ex_cri_desc * returned_cri_desc, queue_index down, queue_index up, Lng32 num_buffers, ULng32 buffer_size) : ComTdbDDL(ddl_query, ddl_querylen, ddl_querycharset, schemaName, schemaNameLen, input_expr, input_rowlen, output_expr, output_rowlen, work_cri_desc, work_atp_index, given_cri_desc, returned_cri_desc, down, up, num_buffers, buffer_size), flags2_(0) { setNodeType(ComTdb::ex_DDL_WITH_STATUS); }
/////////////////////////////////////////////////////////////////////////// // // Methods for class ComTdbDescribe, ExDescribeTcb, ExDescribePrivateState // /////////////////////////////////////////////////////////////////////////// ComTdbDescribe::ComTdbDescribe(char * query, ULng32 querylen, Int16 ddl_querycharset, ex_expr * input_expr, ULng32 input_rowlen, ex_expr * output_expr, ULng32 output_rowlen, ex_cri_desc * work_cri_desc, const unsigned short work_atp_index, DescribeType type, ULng32 flags, ex_cri_desc * given_cri_desc, ex_cri_desc * returned_cri_desc, queue_index down, queue_index up, Lng32 num_buffers, Lng32 buffer_size) : ComTdbDDL(query, querylen, ddl_querycharset, NULL, 0, input_expr, input_rowlen, output_expr, output_rowlen, work_cri_desc, work_atp_index, given_cri_desc, returned_cri_desc, down, up, num_buffers, buffer_size), type_(type), flags_((UInt32)flags) { setNodeType(ComTdb::ex_DESCRIBE); }
PannerNode::PannerNode(AudioContext* context, float sampleRate) : AudioNode(context, sampleRate) , m_panningModel(Panner::PanningModelHRTF) , m_lastGain(-1.0) , m_connectionCount(0) { addInput(adoptPtr(new AudioNodeInput(this))); addOutput(adoptPtr(new AudioNodeOutput(this, 2))); // Node-specific default mixing rules. m_channelCount = 2; m_channelCountMode = ClampedMax; m_channelInterpretation = AudioBus::Speakers; m_distanceGain = AudioParam::create(context, "distanceGain", 1.0, 0.0, 1.0); m_coneGain = AudioParam::create(context, "coneGain", 1.0, 0.0, 1.0); m_position = FloatPoint3D(0, 0, 0); m_orientation = FloatPoint3D(1, 0, 0); m_velocity = FloatPoint3D(0, 0, 0); setNodeType(NodeTypePanner); initialize(); }
/////////////////////////////////////////////////////////////////////////// // // Methods for class ComTdbDDL // /////////////////////////////////////////////////////////////////////////// ComTdbDDL::ComTdbDDL(char * ddl_query, ULng32 ddl_querylen, Int16 ddl_querycharset, char * schemaName, ULng32 schemaNameLen, ex_expr * input_expr, ULng32 input_rowlen, ex_expr * output_expr, ULng32 output_rowlen, ex_cri_desc * work_cri_desc, const unsigned short work_atp_index, ex_cri_desc * given_cri_desc, ex_cri_desc * returned_cri_desc, queue_index down, queue_index up, Lng32 num_buffers, ULng32 buffer_size) : ComTdbGenericUtil(ddl_query, ddl_querylen, ddl_querycharset, schemaName, schemaNameLen, input_expr, input_rowlen, output_expr, output_rowlen, work_cri_desc, work_atp_index, given_cri_desc, returned_cri_desc, down, up, num_buffers, buffer_size), flags_(0) { setNodeType(ComTdb::ex_DDL); memset(fillersComTdbDDL_, sizeof(fillersComTdbDDL_), 0); }
BiquadFilterNode::BiquadFilterNode(AudioContext& context, float sampleRate) : AudioBasicProcessorNode(context, sampleRate) { // Initially setup as lowpass filter. m_processor = std::make_unique<BiquadProcessor>(context, sampleRate, 1, false); setNodeType(NodeTypeBiquadFilter); }
AnalyserNode::AnalyserNode(AudioContext* context, float sampleRate) : AudioBasicInspectorNode(context, sampleRate, 2) { setNodeType(NodeTypeAnalyser); initialize(); }
PannerNode::PannerNode(AudioContext* context, float sampleRate) : AudioNode(context, sampleRate) , m_panningModel(Panner::PanningModelHRTF) , m_lastGain(-1.0) , m_connectionCount(0) { // Load the HRTF database asynchronously so we don't block the Javascript thread while creating the HRTF database. m_hrtfDatabaseLoader = HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(context->sampleRate()); addInput(std::make_unique<AudioNodeInput>(this)); addOutput(std::make_unique<AudioNodeOutput>(this, 2)); // Node-specific default mixing rules. m_channelCount = 2; m_channelCountMode = ClampedMax; m_channelInterpretation = AudioBus::Speakers; m_distanceGain = AudioParam::create(context, "distanceGain", 1.0, 0.0, 1.0); m_coneGain = AudioParam::create(context, "coneGain", 1.0, 0.0, 1.0); m_position = FloatPoint3D(0, 0, 0); m_orientation = FloatPoint3D(1, 0, 0); m_velocity = FloatPoint3D(0, 0, 0); setNodeType(NodeTypePanner); initialize(); }
void TypeCheckerVisitor::visitWhileNode(WhileNode* node) { node->whileExpr()->visit(this); if (getNodeType(node->whileExpr()) == VT_VOID) { setErrorMessage(node, "Should be not void"); } node->loopBlock()->visit(this); setNodeType(node, getNodeType(node->loopBlock())); }
BiquadFilterNode::BiquadFilterNode(AudioContext* context, float sampleRate) : AudioBasicProcessorNode(context, sampleRate) { ScriptWrappable::init(this); // Initially setup as lowpass filter. m_processor = adoptPtrWillBeNoop(new BiquadProcessor(context, sampleRate, 1, false)); setNodeType(NodeTypeBiquadFilter); }
void TypeCheckerVisitor::visitCallNode(CallNode* node) { uint32_t params_count = node->parametersNumber(); AstFunction* refFunc = _current_scope->lookupFunction(node->name(), true); bool matchesRefedFunction = (refFunc!= NULL) && (refFunc->parametersNumber() == params_count); for (uint32_t i = 0; i < params_count; i++) { AstNode* param = node->parameterAt(i); param->visit(this); if (matchesRefedFunction && !isAssignable(refFunc->parameterType(i), getNodeType(param))) { setErrorMessage(param, "Wrong type parameter"); } } if (matchesRefedFunction) { setNodeType(node, refFunc->returnType()); } else { setNodeType(node, VT_INVALID); } }