void be_Type::GenerateStreamOps (be_ClientHeader& source) { ostream & os = source.Stream (); be_Tab tab (source); // insertion os << tab << DLLMACRO << "inline void" << nl << "IOP::put(DDS::Codec::OutStream& os, const " << ScopedName() << "& v" << XBE_Ev::arg (XBE_ENV_ARGN) << ")" << nl; os << "{" << nl; tab.indent(); os << tab << "DDS::Codec::Param putArg = "; os << "{ " << Scope(TypeCodeTypeName()) << ", "; os << "(" << TypeName() << "*)" << "&v, DDS::PARAM_IN "; os << "};" << nl; os << tab << "os.put (&putArg, 1" << XBE_Ev::arg (XBE_ENV_VARN) << ");" << nl; tab.outdent(); os << "}" << nl << nl; // // extraction // os << DLLMACRO << "inline void" << nl << "IOP::get(DDS::Codec::InStream& is, " << ScopedName() << "& v" << XBE_Ev::arg (XBE_ENV_ARGN) << ")" << nl; os << "{" << nl; tab.indent(); os << tab << "DDS::Codec::Param getArg = "; os << "{ " << Scope(TypeCodeTypeName()) << ", "; os << "&v, DDS::PARAM_OUT };" << nl; os << tab << "is.get (&getArg, 1" << XBE_Ev::arg (XBE_ENV_VARN) << ");" << nl; tab.outdent(); os << "}" << nl << nl; }
int main( ) { execute( Seq( If( True( ), Print( String( "hello " ) ), Print( True( ) ) ), If( Or( False( ), Neg( True( ) ) ), Print( Unit( ) ), Print( String( "world!\n" ) ) ) ) ); execute( Seq( When( True( ), Print( String( "hello " ) ) ), Unless( False( ), Print( String( "world!\n" ) ) ) ) ); execute( Print( Print( Seq( Print( True( ) ), Print( False( ) ) ) ) ) ); execute( Print( Concat( String( "4" ), Show( True( ) ) ) ) ); assert( value_to_bool( execute( IsDefined( String( "not defined" ) ) ) ) == false ); execute( Seq( Set( String( "SomeVar" ), String( "12" ) ), Seq( Print( Get( String( "SomeVar" ) ) ), Seq( Set( Concat( String( "S" ), String( "omeVar" ) ), String( "345\n" ) ), Print( Get( Concat( String( "Some" ), String( "Var" ) ) ) ) ) ) ) ); execute( Seq( If( True( ), Set( String( "hello " ), String( "hellos \n" ) ), Print( True( ) ) ), Print( Get( String( "hello " ) ) ) ) ); execute( Seq( Scope( Set( String( "hi" ), True( ) ) ), Print( IsDefined( String( "hi" ) ) ) ) ); assert( value_to_bool( execute( Seq( Seq( Set( String( "var" ), False( ) ), Scope( Set( String( "var" ), True( ) ) ) ), Get( String( "var" ) ) ) ) ) ); execute( Seq( Seq( Set( String( "b1" ), True( ) ), Set( String( "b2" ), True( ) ) ), While( Or( Get( String( "b1" ) ), Get( String( "b2" ) ) ), If( Get( String( "b1" ) ), Seq( Set( String( "b1" ), False( ) ), Print( String( "Hello" ) ) ), Seq( Set( String( "b2" ), False( ) ), Print( String( "World" ) ) ) ) ) ) ); }
const nsCString DOMStorageDBThread::DBOperation::Target() { switch (mType) { case opAddItem: case opUpdateItem: case opRemoveItem: return Scope() + NS_LITERAL_CSTRING("|") + NS_ConvertUTF16toUTF8(mKey); default: return Scope(); } }
local SrcLineList inclHandleIf(String property) { Scope("inclHandleIf"); IfState fluid(ifState); SrcLineList result = listNil(SrcLine); if (INCLUDING(ifState)) { SrcLine sl = SysCmdLine(true); if (INCL_IsAssert(&localAssertList, property)) { ifState = ActiveIf; result = addSysCmd(inclFileContents(),sl); } else { ifState = InactiveIf; result = addSysCmd(inclFileContents(),sl); } } else { ifState = FormerlyActiveIf; result = inclFileContents(); } Return(result); }
/** * Create an OpenGL context. */ FPlatformOpenGLContext* PlatformCreateOpenGLContext(FPlatformOpenGLDevice* Device, void* InWindowHandle) { check(InWindowHandle); Device->TargetDirty = true; FPlatformOpenGLContext* Context = new FPlatformOpenGLContext; Context->WindowHandle = (HWND)InWindowHandle; Context->bReleaseWindowOnDestroy = false; Context->DeviceContext = GetDC(Context->WindowHandle); check(Context->DeviceContext); PlatformInitPixelFormatForDevice(Context->DeviceContext, false); int MajorVersion = 0; int MinorVersion = 0; PlatformOpenGLVersionFromCommandLine(MajorVersion, MinorVersion); PlatformCreateOpenGLContextCore(Context, MajorVersion, MinorVersion, Device->SharedContext.OpenGLContext); check(Context->OpenGLContext); { FScopeContext Scope(Context); InitDefaultGLContextState(); glGenFramebuffers(1, &Context->ViewportFramebuffer); } Device->ViewportContexts.Add(Context); return Context; }
ostream & be_enum::put_for_array ( ostream & os, be_Tab & tab, const DDS_StdString & arg, const DDS_StdString & index, unsigned long uid ) { // declare the put param os << tab << "DDS::Codec::Param put = "; // populate it os << "{ " << Scope(TypeCodeTypeName()) << ", "; os << "(void*)&" << arg << "[" << index << "], DDS::PARAM_IN "; os << "}"; os << ";" << nl << nl; // call put os << tab << "os.put (&put, 1" << XBE_Ev::arg (XBE_ENV_VARN) << ");" << nl; return os; }
ResolvedToken operator()(const std::string& Identifer) const { Types::Scope Scope((NullReference())); if( m_EC.This.IsNull() ) Scope = m_EC.Scope; else { Scope = m_EC.This; m_EC.This = NullReference(); } auto it = (*Scope).Find(Identifer); /* if( it == (*Scope).KeyEnd() ) throw std::logic_error("Identifier " + Identifer + " unknown"); */ while( it == (*Scope).KeyEnd() ) { auto Parent = (*Scope).Find("__PARENT__"); if( Parent == (*Scope).KeyEnd() ) //We reached global scope throw std::logic_error("Identifier " + Identifer + " unknown"); Scope = boost::apply_visitor(Get<Types::Scope>(),Parent->second); it = (*Scope).Find(Identifer); } return it->second; }
//========================================================= bool Parser::Function () { PrintRule rule("Function"); if (Accept(TokenType::Function) == false) { return false; } Expect(TokenType::Identifier); Expect(TokenType::OpenParentheses); if (Parameter()) { while (Accept(TokenType::Comma)) { if (!Parameter()) { throw ParsingException("Expected parameter after comma in function sig"); } } } Expect(TokenType::CloseParentheses); SpecifiedType(); if (!Scope()) { throw ParsingException("Expected scope after function"); } return rule.Accept(); }
ostream & be_enum::get_for_array ( ostream & os, be_Tab & tab, const DDS_StdString & arg, const DDS_StdString & index, unsigned long uid ) { // declare the get param os << tab << "DDS::Codec::Param get = "; // populate it os << "{ " << Scope(TypeCodeTypeName()) << ", "; os << "&" << arg << "[" << index << "], DDS::PARAM_OUT "; os << "}"; os << ";" << nl << nl; // call get os << tab << "is.get (&get, 1" << XBE_Ev::arg (XBE_ENV_VARN) << ");" << nl; return os; }
Scope *Scope::createGlobal(Module *_module) { Scope *sc = Scope::alloc(); *sc = Scope(); // memset sc->aligndecl = NULL; sc->linkage = LINKd; sc->inlining = PINLINEdefault; sc->protection = Prot(PROTpublic); sc->_module = _module; sc->tinst = NULL; sc->minst = _module; sc->scopesym = new ScopeDsymbol(); sc->scopesym->symtab = new DsymbolTable(); // Add top level package as member of this global scope Dsymbol *m = _module; while (m->parent) m = m->parent; m->addMember(NULL, sc->scopesym); m->parent = NULL; // got changed by addMember() // Create the module scope underneath the global scope sc = sc->push(_module); sc->parent = _module; return sc; }
DDS::Boolean be_enum::make_put_param_for_stub ( ostream & os, be_Tab & tab, const DDS_StdString & arg, VarType vt ) const { DDS::Boolean ret = FALSE; if (vt == VT_InParam || vt == VT_InOutParam) { os << tab << "{ " << Scope(TypeCodeTypeName()) << ", "; switch (vt) { case VT_InParam: os << "(void*)&" << arg << ", DDS::PARAM_IN "; break; case VT_InOutParam: os << "&" << arg << ", DDS::PARAM_INOUT "; break; default: assert (0); } os << "}"; ret = TRUE; } return ret; }
StringRef WinCodeViewLineTables::getFullFilepath(const MDNode *S) { assert(S); DIDescriptor D(S); assert((D.isCompileUnit() || D.isFile() || D.isSubprogram() || D.isLexicalBlockFile() || D.isLexicalBlock()) && "Unexpected scope info"); DIScope Scope(S); StringRef Dir = Scope.getDirectory(), Filename = Scope.getFilename(); char *&Result = DirAndFilenameToFilepathMap[std::make_pair(Dir, Filename)]; if (Result) return Result; // Clang emits directory and relative filename info into the IR, but CodeView // operates on full paths. We could change Clang to emit full paths too, but // that would increase the IR size and probably not needed for other users. // For now, just concatenate and canonicalize the path here. std::string Filepath; if (Filename.find(':') == 1) Filepath = Filename; else Filepath = (Dir + Twine("\\") + Filename).str(); // Canonicalize the path. We have to do it textually because we may no longer // have access the file in the filesystem. // First, replace all slashes with backslashes. std::replace(Filepath.begin(), Filepath.end(), '/', '\\'); // Remove all "\.\" with "\". size_t Cursor = 0; while ((Cursor = Filepath.find("\\.\\", Cursor)) != std::string::npos) Filepath.erase(Cursor, 2); // Replace all "\XXX\..\" with "\". Don't try too hard though as the original // path should be well-formatted, e.g. start with a drive letter, etc. Cursor = 0; while ((Cursor = Filepath.find("\\..\\", Cursor)) != std::string::npos) { // Something's wrong if the path starts with "\..\", abort. if (Cursor == 0) break; size_t PrevSlash = Filepath.rfind('\\', Cursor - 1); if (PrevSlash == std::string::npos) // Something's wrong, abort. break; Filepath.erase(PrevSlash, Cursor + 3 - PrevSlash); // The next ".." might be following the one we've just erased. Cursor = PrevSlash; } // Remove all duplicate backslashes. Cursor = 0; while ((Cursor = Filepath.find("\\\\", Cursor)) != std::string::npos) Filepath.erase(Cursor, 1); Result = strdup(Filepath.c_str()); return StringRef(Result); }
void HoleCollection::Add(int startT, int endT, int startS, int endS) { Hole hole(startS, endS, startT, endT); m_scope.push_back(Scope(hole)); m_sourceHoleStartPoints.push_back(startS); m_sourceHoleEndPoints.push_back(endS); m_holes.push_back(hole); m_sortedSourceHoles.clear(); }
bool FEventWinRT::Wait(uint32 WaitTime, const bool bIgnoreThreadIdleStats /*= false*/) { SCOPE_CYCLE_COUNTER(STAT_EventWait); FThreadIdleStats::FScopeIdle Scope(bIgnoreThreadIdleStats); check(Event); // return (WaitForSingleObject(Event, WaitTime) == WAIT_OBJECT_0); return WaitForSingleObjectEx(Event, WaitTime, FALSE) == WAIT_OBJECT_0; }
//========================================================= bool Parser::Else () { PrintRule rule("Else"); if (Accept(TokenType::Else) == false) { return false; } if (!If() && !Scope()) { throw ParsingException("Failed to parse Else"); } return rule.Accept(); }
void AVisitor<C>::startWalk(Y& obj, bean_key key) { rootKey=key; stack=std::stack<Scope>(); std::string ClassName=Database::getClassName<Y>(); scope=Scope(ClassName,""); actor->notifyInitWalk(*this); walk(obj); actor->notifyDoneWalk(*this); }
//========================================================= bool Parser::If () { PrintRule rule("If"); if (Accept(TokenType::If) == false) { return false; } if (!GroupedExpression() || !Scope()) { throw ParsingException("expected group expression for if"); } Else (); return rule.Accept(); }
DDS::Boolean be_structure::make_get_param_for_stub ( ostream & os, be_Tab & tab, const DDS_StdString & arg, VarType vt ) const { DDS::Boolean ret = FALSE; if (vt == VT_InOutParam || vt == VT_OutParam || vt == VT_Return) { os << tab << "{ " << Scope(TypeCodeTypeName()) << ", "; if (m_isFixedLength) { switch (vt) { case VT_Return: case VT_InOutParam: case VT_OutParam: os << "&" << arg << ", DDS::PARAM_OUT "; default: break; } } else { switch (vt) { case VT_InOutParam: os << "&" << arg << ", DDS::PARAM_OUT "; break; case VT_OutParam: os << arg << ".out(), DDS::PARAM_OUT "; break; case VT_Return: os << arg << ", DDS::PARAM_OUT "; break; default: break; } } os << "}"; ret = TRUE; } return ret; }
//========================================================= bool Parser::While () { PrintRule rule("While"); if (Accept(TokenType::While) == false) { return false; } if (!GroupedExpression()) { throw ParsingException("Expected grouped expression in while"); } if (!Scope()) { throw ParsingException("Expected scope in while"); } return rule.Accept(); }
DDS::Boolean be_sequence::make_get_param_for_union ( ostream & os, be_Tab & tab, const DDS_StdString & sptr, const DDS_StdString & fld, unsigned long uid ) { os << tab << "{ " << Scope(TypeCodeTypeName()) << ", " << sptr << "->" << fld << ", DDS::PARAM_OUT }"; return TRUE; }
DDS::Boolean be_structure::make_get_param_for_union ( ostream & os, be_Tab & tab, const DDS_StdString & sptr, const DDS_StdString & fld, unsigned long uid ) { if (m_isFixedLength) { os << tab << "{ " << Scope(TypeCodeTypeName()) << ", &" << sptr << "->" << fld << ", DDS::PARAM_OUT }"; } else { os << tab << "{ " << Scope(TypeCodeTypeName()) << ", " << sptr << "->" << fld << ", DDS::PARAM_OUT }"; } return TRUE; }
void CtrGenerator::generate(const Array<const ExprSymbol>& _src_vars, const P_ConstraintList& src, std::vector<NumConstraint*>& dest) { src_vars = &_src_vars; ctrs = &dest; assert(dest.empty()); scopes.push(Scope()); // a fresh new scope! (needed otherwise scopes.top() is NULL -> fix issue #36) visit(src); scopes.pop(); }
ostream & be_string::get_for_array ( ostream & os, be_Tab & tab, const DDS_StdString & arg, const DDS_StdString & index, unsigned long uid ) { DDS_StdString garg = (DDS_StdString) "_getArg_"; garg += uid; if (m_typecode->kind == DDS::tk_string) { /* In Strings are shallow copied so disable String_mgr from releasing string when PARAM_IN. */ os << tab << arg << "[" << index << "]" << " = (char*) 0;" << nl; os << tab << "DDS::Codec::Param " << garg << " = { " << Scope (TypeCodeTypeName ()) << ", &" << arg << "[" << index << "].m_ptr" << ", mode };" << nl; os << tab << "if (mode == DDS::PARAM_IN) " << arg << "[" << index << "].m_rel = 0;" << nl; } else { os << tab << "DDS::Codec::Param " << garg << " = { " << Scope (TypeCodeTypeName ()) << ", &(" << arg << "[" << index << "].m_ptr), mode };" << nl; } os << tab << "is.get (&" << garg << ", 1" << XBE_Ev::arg (XBE_ENV_VARN) << ");" << nl; return os; }
void PIT_ISR(void) { pit_ctr++; dir_ctr++; spd_per++; //Speed_Control(); switch (pit_ctr) { case 1: Angle_Read(); break; case 2: Angle_Merge(); balance_pwm = Balance_PID(angle_balance, gyro_balance); Motor_Control(); // Motor_Out(3000, 3000); break; case 3: spd_ctr++; if (spd_ctr > 20) { //speed_pwm = Speed_PID(speed_l, speed_r); spd_ctr = 0; spd_per = 0; } break; case 4: dir_ctr++; //Dir_VS(); //Scope(); if (dir_ctr > 4) { //Dir_Control(); dir_ctr = 0; dir_per = 0; } break; case 5: Speed_Read(); pit_ctr = 0; break; default: printf("d"); break; } //Spd_Control(); //Dir_Contorl(); Scope(); }
DDS::Boolean be_enum::make_put_param_for_union( ostream & os, be_Tab & tab, const DDS_StdString & sptr, const DDS_StdString & fld, unsigned long uid) { os << tab << "{ " << Scope(TypeCodeTypeName()) << ", " << "(void*)&" << sptr << "->" << fld << ", DDS::PARAM_IN " << "}"; return TRUE; }
void be_DispatchableType::DeclareInout ( ostream& os, be_Tab& tab, const be_CppName& implClassName, const be_CppName& argName ) const { switch (HowStoredInDispatcher (VT_InOutParam)) { case STORED_AS_STACK_VARIABLE: { os << tab << TypeName () << " " << argName << ";" << nl; } break; case STORED_IN_VAR: case STORED_IN_STRING_VAR: case STORED_IN_DESCENDANT_VAR: { os << tab << TypeName () << DDSVarExtension << " " << argName << ";" << nl; } break; case STORED_IN_ALLOCED_VAR: { DDSString relTypeName = BE_Globals::RelativeScope(DDSString(implClassName), typeName); os << tab << relTypeName << DDSVarExtension << " " << argName << " = " << relTypeName << "_alloc ();" << nl; } break; case STORED_IN_IOR_VAR: { DDSString stubFactory = BE_Globals::RelativeScope(DDSString(implClassName), Scope(localName) + ""); os << tab << ScopedName() << DDSVarExtension << " " << argName << " (new " << stubFactory << DDSStubExtension << " ());" << nl; } break; default: { assert(0); } } }
void be_sequence::init_type(const DDS_StdString& scope, const DDS_StdString& name) { enclosingScope = scope; localName = name; m_tc_ctor_val = NoColons((DDS_StdString) Scope(localName) + "_ctor"); m_tc_dtor_val = NoColons((DDS_StdString) Scope(localName) + "_dtor"); if (local() != I_TRUE) { m_tc_put_val = NoColons((DDS_StdString) Scope(localName) + "_put"); m_tc_get_val = NoColons((DDS_StdString) Scope(localName) + "_get"); } else { m_tc_put_val = (DDS_StdString)"0"; m_tc_get_val = (DDS_StdString)"0"; } m_tc_assign_val = NoColons((DDS_StdString) Scope(localName) + "_copy"); InitializeTypeMap(this); }
ostream & be_Type::get_for_array ( ostream & os, be_Tab & tab, const DDS_StdString & arg, const DDS_StdString & index, unsigned long uid ) { os << tab << "DDS::Codec::Param getArg" << uid << " = { " << Scope(TypeCodeTypeName()) << ", &" << arg << "[" << index << "], DDS::PARAM_OUT };" << nl << nl; os << tab << "is.get (&getArg" << uid << ", 1" << XBE_Ev::arg (XBE_ENV_VARN) << ");" << nl; return os; }
std::string operator()(const std::string& s)const { Types::Scope Scope((NullReference())); if( m_EC.This.IsNull() ) Scope = m_EC.Scope; else { Scope = m_EC.This; m_EC.This = NullReference(); } auto it = (*Scope).Find(s); if( it == (*Scope).KeyEnd() ) throw std::logic_error("Identifier " + s + " unknown"); return boost::apply_visitor(*this,it->second); }
ostream & be_Type::put_for_sequence ( ostream & os, be_Tab & tab, const DDS_StdString & arg, const DDS_StdString & index, unsigned long uid ) { os << tab << "DDS::Codec::Param putArg" << uid << " = { " << Scope(TypeCodeTypeName()) << ", &" << arg << "[" << index << "], DDS::PARAM_IN };" << nl << nl; os << tab << "os.put (&putArg" << uid << ", 1" << XBE_Ev::arg (XBE_ENV_VARN) << ");" << nl; return os; }