TEST(ContinuationAlgTest, GetSurfaceCellsOffLeftEdge) { Rectangle bounds(-2.0, 10.0, -10.0, 10.0); Grid grid(bounds, 1.0); Point2D location(0.0, 0.0); double radius = 5.0; double isoValue = 0.5; PointPrimitive primitive(location, radius, isoValue); std::list<Primitive *> primitives; primitives.push_back(&primitive); SummationBlend blend(primitives, isoValue); ContinuationAlgorithm alg(&grid, &primitive, &blend); std::list<Cell *> surfaceCells = alg.GetSurfaceCells(); EXPECT_EQ(18, surfaceCells.size()); ExpectContainsCell(10, 0, surfaceCells); ExpectContainsCell(11, 0, surfaceCells); ExpectContainsCell(12, 0, surfaceCells); ExpectContainsCell(12, 1, surfaceCells); ExpectContainsCell(12, 2, surfaceCells); ExpectContainsCell(12, 3, surfaceCells); ExpectContainsCell(11, 3, surfaceCells); ExpectContainsCell(11, 4, surfaceCells); ExpectContainsCell(10, 4, surfaceCells); ExpectContainsCell(9, 4, surfaceCells); ExpectContainsCell(8, 4, surfaceCells); ExpectContainsCell(8, 3, surfaceCells); ExpectContainsCell(7, 3, surfaceCells); ExpectContainsCell(7, 2, surfaceCells); ExpectContainsCell(7, 1, surfaceCells); ExpectContainsCell(7, 0, surfaceCells); ExpectContainsCell(8, 0, surfaceCells); ExpectContainsCell(9, 0, surfaceCells); }
// primary: primitive // | idExpr // | parenExpr // | OB optExpressionList CB // | anonFunc Lexeme *primary(Parser *p) { if(primitivePending(p)) { return primitive(p); } else if(idExprPending(p)) { return idExpr(p); } else if(parenExprPending(p)) { return parenExpr(p); } else if(uOpPending(p)) { Lexeme *a = uOp(p); a->right = primary(p); return a; } else if(check(p,OB)) { Lexeme *a = lexeme(ARRAY); match(p,OB); if(expressionListPending(p)) { a->right = expressionList(p); } match(p,CB); return a; } else { return anonFunc(p); } }
Primitive::Ptr Renderer::CreateImage( const sf::FloatRect& rect, const sf::Image& image, sf::Color background_color_hint ) { sf::Vector2f offset( LoadImage( image, background_color_hint ) ); Primitive::Ptr primitive( new Primitive ); Primitive::Vertex vertex0; Primitive::Vertex vertex1; Primitive::Vertex vertex2; Primitive::Vertex vertex3; vertex0.position = sf::Vector2f( std::floor( rect.left + .5f ), std::floor( rect.top + .5f ) ); vertex1.position = sf::Vector2f( std::floor( rect.left + .5f ), std::floor( rect.top + .5f ) + std::floor( rect.height + .5f ) ); vertex2.position = sf::Vector2f( std::floor( rect.left + .5f ) + std::floor( rect.width + .5f ), std::floor( rect.top + .5f ) ); vertex3.position = sf::Vector2f( std::floor( rect.left + .5f ) + std::floor( rect.width + .5f ), std::floor( rect.top + .5f ) + std::floor( rect.height + .5f ) ); vertex0.color = sf::Color( 255, 255, 255, 255 ); vertex1.color = sf::Color( 255, 255, 255, 255 ); vertex2.color = sf::Color( 255, 255, 255, 255 ); vertex3.color = sf::Color( 255, 255, 255, 255 ); vertex0.texture_coordinate = offset + sf::Vector2f( 0.f, 0.f ); vertex1.texture_coordinate = offset + sf::Vector2f( 0.f, static_cast<float>( image.getHeight() ) ); vertex2.texture_coordinate = offset + sf::Vector2f( static_cast<float>( image.getWidth() ), 0.f ); vertex3.texture_coordinate = offset + sf::Vector2f( static_cast<float>( image.getWidth() ), static_cast<float>( image.getHeight() ) ); primitive->AddVertex( vertex0 ); primitive->AddVertex( vertex1 ); primitive->AddVertex( vertex2 ); primitive->AddVertex( vertex2 ); primitive->AddVertex( vertex1 ); primitive->AddVertex( vertex3 ); AddPrimitive( primitive ); return primitive; }
Primitive::Ptr Renderer::CreateQuad( const sf::Vector2f& top_left, const sf::Vector2f& bottom_left, const sf::Vector2f& bottom_right, const sf::Vector2f& top_right, const sf::Color& color ) { Primitive::Ptr primitive( new Primitive ); Primitive::Vertex vertex0; Primitive::Vertex vertex1; Primitive::Vertex vertex2; Primitive::Vertex vertex3; vertex0.position = sf::Vector2f( std::floor( top_left.x + .5f ), std::floor( top_left.y + .5f ) ); vertex1.position = sf::Vector2f( std::floor( bottom_left.x + .5f ), std::floor( bottom_left.y + .5f ) ); vertex2.position = sf::Vector2f( std::floor( top_right.x + .5f ), std::floor( top_right.y + .5f ) ); vertex3.position = sf::Vector2f( std::floor( bottom_right.x + .5f ), std::floor( bottom_right.y + .5f ) ); vertex0.color = color; vertex1.color = color; vertex2.color = color; vertex3.color = color; vertex0.texture_coordinate = sf::Vector2f( 0.f, 0.f ); vertex1.texture_coordinate = sf::Vector2f( 0.f, 1.f ); vertex2.texture_coordinate = sf::Vector2f( 1.f, 0.f ); vertex3.texture_coordinate = sf::Vector2f( 1.f, 1.f ); primitive->AddVertex( vertex0 ); primitive->AddVertex( vertex1 ); primitive->AddVertex( vertex2 ); primitive->AddVertex( vertex2 ); primitive->AddVertex( vertex1 ); primitive->AddVertex( vertex3 ); AddPrimitive( primitive ); return primitive; }
void pushElement( const XMLElement& element ){ ASSERT_MESSAGE( string_equal( element.name(), "entity" ), PARSE_ERROR ); constructor( node(), NodeSmartReference( m_entityTable.createEntity( GlobalEntityClassManager().findOrInsert( "", true ) ) ) ); constructor( primitive(), makeReference( node().get() ) ); }
NodeSmartReference Entity_parseTokens(Tokeniser& tokeniser, EntityCreator& entityTable, const PrimitiveParser& parser, int index) { NodeSmartReference entity(g_nullNode); KeyValues keyValues; const char* classname = ""; int count_primitives = 0; while(1) { tokeniser.nextLine(); const char* token = tokeniser.getToken(); if(token == 0) { Tokeniser_unexpectedError(tokeniser, token, "#entity-token"); return g_nullNode; } if (!strcmp(token, "}")) // end entity { if(entity == g_nullNode) { // entity does not have brushes entity = Entity_create(entityTable, GlobalEntityClassManager().findOrInsert(classname, false), keyValues); } return entity; } else if(!strcmp(token, "{")) // begin primitive { if(entity == g_nullNode) { // entity has brushes entity = Entity_create(entityTable, GlobalEntityClassManager().findOrInsert(classname, true), keyValues); } tokeniser.nextLine(); NodeSmartReference primitive(parser.parsePrimitive(tokeniser)); if(primitive == g_nullNode || !Node_getMapImporter(primitive)->importTokens(tokeniser)) { globalErrorStream() << "brush " << count_primitives << ": parse error\n"; return g_nullNode; } scene::Traversable* traversable = Node_getTraversable(entity); if(Node_getEntity(entity)->isContainer() && traversable != 0) { traversable->insert(primitive); } else { globalErrorStream() << "entity " << index << ": type " << classname << ": discarding brush " << count_primitives << "\n"; } ++count_primitives; } else // epair { CopiedString key(token); token = tokeniser.getToken(); if(token == 0) { Tokeniser_unexpectedError(tokeniser, token, "#epair-value"); return g_nullNode; } keyValues.push_back(KeyValues::value_type(key, token)); if(string_equal(key.c_str(), "classname")) { classname = keyValues.back().second.c_str(); } } } // unreachable code return g_nullNode; }
static void draw(void) { float x, y; int cx, cy, cw, ch; int w = al_get_bitmap_width(ex.zoom); int h = al_get_bitmap_height(ex.zoom); ALLEGRO_BITMAP *screen = al_get_target_bitmap(); ALLEGRO_BITMAP *mem; int rects_num = 16, i, j; float rects[16 * 4]; for (j = 0; j < 4; j++) { for (i = 0; i < 4; i++) { rects[(j * 4 + i) * 4 + 0] = 2 + i * 0.25 + i * 7; rects[(j * 4 + i) * 4 + 1] = 2 + j * 0.25 + j * 7; rects[(j * 4 + i) * 4 + 2] = 2 + i * 0.25 + i * 7 + 5; rects[(j * 4 + i) * 4 + 3] = 2 + j * 0.25 + j * 7 + 5; } } al_get_clipping_rectangle(&cx, &cy, &cw, &ch); al_clear_to_color(ex.background); set_xy(8, 0); print("Drawing %s (press SPACE to change)", names[ex.what]); set_xy(8, 16); print("Original"); set_xy(80, 16); print("Enlarged x 16"); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); if (ex.software) { al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_new_bitmap_format(al_get_bitmap_format(al_get_target_bitmap())); mem = al_create_bitmap(w, h); al_set_target_bitmap(mem); x = 0; y = 0; } else { mem = NULL; x = 8; y = 40; } al_draw_bitmap(ex.pattern, x, y, 0); /* Draw the test scene. */ al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); for (i = 0; i < rects_num; i++) { ALLEGRO_COLOR rgba = ex.foreground; rgba.a *= 0.5; primitive( x + rects[i * 4 + 0], y + rects[i * 4 + 1], x + rects[i * 4 + 2], y + rects[i * 4 + 3], rgba, false); } al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); if (ex.software) { al_set_target_bitmap(screen); x = 8; y = 40; al_draw_bitmap(mem, x, y, 0); al_destroy_bitmap(mem); } /* Grab screen contents into our bitmap. */ al_set_target_bitmap(ex.zoom); al_draw_bitmap_region(screen, x, y, w, h, 0, 0, 0); al_set_target_bitmap(screen); /* Draw it enlarged. */ x = 80; y = 40; al_draw_scaled_bitmap(ex.zoom, 0, 0, w, h, x, y, w * 16, h * 16, 0); /* Draw outlines. */ for (i = 0; i < rects_num; i++) { primitive( x + rects[i * 4 + 0] * 16, y + rects[i * 4 + 1] * 16, x + rects[i * 4 + 2] * 16, y + rects[i * 4 + 3] * 16, ex.outline, true); } set_xy(8, 640 - 48); print("Thickness: %d (press T to change)", ex.thickness); print("Drawing with: %s (press S to change)", ex.software ? "software" : "hardware"); print("Supersampling: %dx (edit ex_draw.ini to change)", ex.samples); // FIXME: doesn't work // al_get_display_option(ALLEGRO_SAMPLE_BUFFERS)); }
void TurboMoleParser::createContracted(arma::vec nucleusPosition) { m_inFile.clear() ; m_inFile.seekg(0, std::ios::beg) ; m_contracted.clear(); char buf[256]; // Random size buffer, assuming no important lines to be longer than this std::stringstream s; int numBasisFunctionsInContracted; char orbitalType; double coefficient; double exponent; while (m_inFile.getline(buf, 256)) { if (startswith(buf, "$basis")){ m_inFile.getline(buf, 256); m_inFile.getline(buf, 256); m_inFile.getline(buf, 256); // From here is the information on the basis m_inFile.getline(buf, 256); while (!startswith(buf, "*")) { s << buf; s >> numBasisFunctionsInContracted; s >> orbitalType; switch (orbitalType) { case 's': { Contracted contracted; for (int numPrimitives = 0; numPrimitives<numBasisFunctionsInContracted; numPrimitives++) { m_inFile.getline(buf, 256); s << buf; s >> exponent; s >> coefficient; Primitive primitive(coefficient, 0, 0, 0, exponent, nucleusPosition); contracted.addPrimitive(primitive); } m_contracted.push_back(contracted); m_inFile.getline(buf, 256); break; } case 'p': { Contracted contractedX; Contracted contractedY; Contracted contractedZ; for (int numPrimitives = 0; numPrimitives<numBasisFunctionsInContracted; numPrimitives++) { m_inFile.getline(buf, 256); s << buf; s >> exponent; s >> coefficient; Primitive px(coefficient, 1, 0, 0, exponent, nucleusPosition); Primitive py(coefficient, 0, 1, 0, exponent, nucleusPosition); Primitive pz(coefficient, 0, 0, 1, exponent, nucleusPosition); contractedX.addPrimitive(px); contractedY.addPrimitive(py); contractedZ.addPrimitive(pz); } m_contracted.push_back(contractedX); m_contracted.push_back(contractedY); m_contracted.push_back(contractedZ); m_inFile.getline(buf, 256); break; } } } } }
void paint_mesh(const k3d::mesh& Mesh, const k3d::ri::render_state& RenderState) { for(k3d::mesh::primitives_t::const_iterator p = Mesh.primitives.begin(); p != Mesh.primitives.end(); ++p) { boost::scoped_ptr<k3d::blobby::const_primitive> primitive(k3d::blobby::validate(Mesh, **p)); if(!primitive) continue; const size_t blobby_begin = 0; const size_t blobby_end = blobby_begin + primitive->first_primitives.size(); for(size_t blobby = blobby_begin; blobby != blobby_end; ++blobby) { array_copier ri_constant_attributes; ri_constant_attributes.add_arrays(primitive->constant_attributes); array_copier ri_uniform_attributes; ri_uniform_attributes.add_arrays(primitive->surface_attributes); array_copier ri_varying_attributes; ri_varying_attributes.add_arrays(primitive->parameter_attributes); array_copier ri_vertex_attributes; ri_vertex_attributes.add_arrays(primitive->vertex_attributes); const k3d::ri::unsigned_integer ri_nleaf = primitive->primitive_counts[blobby]; k3d::ri::unsigned_integers ri_codes; k3d::ri::reals ri_floats; k3d::ri::strings ri_strings; const size_t primitives_begin = primitive->first_primitives[blobby]; const size_t primitives_end = primitives_begin + primitive->primitive_counts[blobby]; for(size_t blobby_primitive = primitives_begin; blobby_primitive != primitives_end; ++blobby_primitive) { ri_codes.push_back(primitive->primitives[blobby_primitive]); ri_codes.push_back(ri_floats.size()); const size_t floats_begin = primitive->primitive_first_floats[blobby_primitive]; const size_t floats_end = floats_begin + primitive->primitive_float_counts[blobby_primitive]; ri_floats.insert(ri_floats.end(), &primitive->floats[floats_begin], &primitive->floats[floats_end]); ri_varying_attributes.push_back(blobby_primitive); ri_vertex_attributes.push_back(blobby_primitive); } const size_t operators_begin = primitive->first_operators[blobby]; const size_t operators_end = operators_begin + primitive->operator_counts[blobby]; for(size_t op = operators_begin; op != operators_end; ++op) { ri_codes.push_back(primitive->operators[op]); const size_t operands_begin = primitive->operator_first_operands[op]; const size_t operands_end = operands_begin + primitive->operator_operand_counts[op]; for(size_t operand = operands_begin; operand != operands_end; ++operand) ri_codes.push_back(primitive->operands[operand]); } ri_constant_attributes.push_back(blobby); ri_uniform_attributes.push_back(blobby); k3d::ri::parameter_list ri_parameters; ri_constant_attributes.copy_to(k3d::ri::CONSTANT, ri_parameters); ri_uniform_attributes.copy_to(k3d::ri::UNIFORM, ri_parameters); ri_varying_attributes.copy_to(k3d::ri::VARYING, ri_parameters); ri_vertex_attributes.copy_to(k3d::ri::VERTEX, ri_parameters); k3d::ri::setup_material(primitive->materials[blobby], RenderState); // We always have at least one string? ri_strings.push_back(k3d::ri::string()); RenderState.stream.RiBlobbyV(ri_nleaf, ri_codes, ri_floats, ri_strings, ri_parameters); } } }
Real PolynomialFunction::definiteIntegral(Time t1, Time t2) const { return primitive(t2)-primitive(t1); }
/** * Implementation of the MUF debugger * * This implements the command parsing for the MUF debugger. It also clears * temporary bookmarks if this was triggered from a temporary one. * * This relies on some static globals, so it is not threadsafe. If the * 'prim' debugger command is ever used to trigger the MUF debugger somehow * in a recursive fashion, and then you call 'prim' again, it will probably * cause havock. * * @param descr the descriptor of the debugging player * @param player the debugging player * @param program the program we are debugging * @param text the input text from the user * @param fr the current frame pointer * @return boolean true if the program should exit, false if not */ int muf_debugger(int descr, dbref player, dbref program, const char *text, struct frame *fr) { char cmd[BUFFER_LEN]; char buf[BUFFER_LEN]; char buf2[BUFFER_LEN]; char *ptr, *ptr2, *arg; struct inst *pinst; int i, j, cnt; static struct inst primset[5]; static struct muf_proc_data temp_muf_proc_data = { "__Temp_Debugger_Proc", 0, 0, NULL }; /* * Basic massaging of the input - clearing spaces, finding the * argument. */ skip_whitespace(&text); strcpyn(cmd, sizeof(cmd), text); ptr = cmd; remove_ending_whitespace(&ptr); for (arg = cmd; *arg && !isspace(*arg); arg++) ; if (*arg) *arg++ = '\0'; /* Empty command means repeat last command, if available */ if (!*cmd && fr->brkpt.lastcmd) { strcpyn(cmd, sizeof(cmd), fr->brkpt.lastcmd); } else { free(fr->brkpt.lastcmd); if (*cmd) fr->brkpt.lastcmd = strdup(cmd); } /* delete triggering breakpoint, if it's only temp. */ j = fr->brkpt.breaknum; if (j >= 0 && fr->brkpt.temp[j]) { for (j++; j < fr->brkpt.count; j++) { fr->brkpt.temp[j - 1] = fr->brkpt.temp[j]; fr->brkpt.level[j - 1] = fr->brkpt.level[j]; fr->brkpt.line[j - 1] = fr->brkpt.line[j]; fr->brkpt.linecount[j - 1] = fr->brkpt.linecount[j]; fr->brkpt.pc[j - 1] = fr->brkpt.pc[j]; fr->brkpt.pccount[j - 1] = fr->brkpt.pccount[j]; fr->brkpt.prog[j - 1] = fr->brkpt.prog[j]; } fr->brkpt.count--; } fr->brkpt.breaknum = -1; /** * @TODO This giant if statement is pretty gnarly; we'd be better * of looping over an array of callbacks to break this up * nicer and make it more extensible. */ if (!strcasecmp(cmd, "cont")) { /* Nothing to do -- this will continue to next breakpoint */ } else if (!strcasecmp(cmd, "finish")) { if (fr->brkpt.count >= MAX_BREAKS) { notify_nolisten(player, "Cannot finish because there are too many breakpoints set.", 1); add_muf_read_event(descr, player, program, fr); return 0; } j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = fr->system.top - 1; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = -2; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = -2; fr->brkpt.prog[j] = program; fr->brkpt.bypass = 1; return 0; } else if (!strcasecmp(cmd, "stepi")) { i = atoi(arg); if (!i) i = 1; if (fr->brkpt.count >= MAX_BREAKS) { notify_nolisten(player, "Cannot stepi because there are too many breakpoints set.", 1); add_muf_read_event(descr, player, program, fr); return 0; } j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = -1; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = -2; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = i; fr->brkpt.prog[j] = NOTHING; fr->brkpt.bypass = 1; return 0; } else if (!strcasecmp(cmd, "step")) { i = atoi(arg); if (!i) i = 1; if (fr->brkpt.count >= MAX_BREAKS) { notify_nolisten(player, "Cannot step because there are too many breakpoints set.", 1); add_muf_read_event(descr, player, program, fr); return 0; } j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = -1; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = i; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = -2; fr->brkpt.prog[j] = NOTHING; fr->brkpt.bypass = 1; return 0; } else if (!strcasecmp(cmd, "nexti")) { i = atoi(arg); if (!i) i = 1; if (fr->brkpt.count >= MAX_BREAKS) { notify_nolisten(player, "Cannot nexti because there are too many breakpoints set.", 1); add_muf_read_event(descr, player, program, fr); return 0; } j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = fr->system.top; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = -2; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = i; fr->brkpt.prog[j] = program; fr->brkpt.bypass = 1; return 0; } else if (!strcasecmp(cmd, "next")) { i = atoi(arg); if (!i) i = 1; if (fr->brkpt.count >= MAX_BREAKS) { notify_nolisten(player, "Cannot next because there are too many breakpoints set.", 1); add_muf_read_event(descr, player, program, fr); return 0; } j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = fr->system.top; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = i; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = -2; fr->brkpt.prog[j] = program; fr->brkpt.bypass = 1; return 0; } else if (!strcasecmp(cmd, "exec")) { if (fr->brkpt.count >= MAX_BREAKS) { notify_nolisten(player, "Cannot finish because there are too many breakpoints set.", 1); add_muf_read_event(descr, player, program, fr); return 0; } if (!(pinst = funcname_to_pc(program, arg))) { notify_nolisten(player, "I don't know a function by that name.", 1); add_muf_read_event(descr, player, program, fr); return 0; } if (fr->system.top >= STACK_SIZE) { notify_nolisten(player, "That would exceed the system stack size for this program.", 1); add_muf_read_event(descr, player, program, fr); return 0; } fr->system.st[fr->system.top].progref = program; fr->system.st[fr->system.top++].offset = fr->pc; fr->pc = pinst; j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = fr->system.top - 1; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = -2; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = -2; fr->brkpt.prog[j] = program; fr->brkpt.bypass = 1; return 0; } else if (!strcasecmp(cmd, "prim")) { /* * @TODO The way this works is a little funky. It looks like * it would be possible to cause some weird havoc if we * manage to run a primitive that in turn triggers muf_debugger * * I am uncertain if this is possible; looks like the only * way it could happen is by typing 'prim debugger_break' * but I don't know much about about how muf_debugger is * triggered. Some digging should be done to make this * safe. * * Even better would be to not use statics for this somehow * without introducing a memory leak. (tanabi) */ if (fr->brkpt.count >= MAX_BREAKS) { notify_nolisten(player, "Cannot finish because there are too many breakpoints set.", 1); add_muf_read_event(descr, player, program, fr); return 0; } if (!primitive(arg)) { notify_nolisten(player, "I don't recognize that primitive.", 1); add_muf_read_event(descr, player, program, fr); return 0; } if (fr->system.top >= STACK_SIZE) { notify_nolisten(player, "That would exceed the system stack size for this program.", 1); add_muf_read_event(descr, player, program, fr); return 0; } primset[0].type = PROG_FUNCTION; primset[0].line = 0; primset[0].data.mufproc = &temp_muf_proc_data; primset[0].data.mufproc->vars = 0; primset[0].data.mufproc->args = 0; primset[0].data.mufproc->varnames = NULL; primset[1].type = PROG_PRIMITIVE; primset[1].line = 0; primset[1].data.number = get_primitive(arg); primset[2].type = PROG_PRIMITIVE; primset[2].line = 0; primset[2].data.number = IN_RET; /* primset[3].data.number = primitive("EXIT"); */ fr->system.st[fr->system.top].progref = program; fr->system.st[fr->system.top++].offset = fr->pc; fr->pc = &primset[1]; j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = -1; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = -2; fr->brkpt.pc[j] = &primset[2]; fr->brkpt.pccount[j] = -2; fr->brkpt.prog[j] = program; fr->brkpt.bypass = 1; fr->brkpt.dosyspop = 1; return 0; } else if (!strcasecmp(cmd, "break")) { add_muf_read_event(descr, player, program, fr); if (fr->brkpt.count >= MAX_BREAKS) { notify_nolisten(player, "Too many breakpoints set.", 1); return 0; } if (number(arg)) { i = atoi(arg); } else { if (!(pinst = funcname_to_pc(program, arg))) { notify_nolisten(player, "I don't know a function by that name.", 1); return 0; } else { i = pinst->line; } } if (!i) i = fr->pc->line; j = fr->brkpt.count++; fr->brkpt.temp[j] = 0; fr->brkpt.level[j] = -1; fr->brkpt.line[j] = i; fr->brkpt.linecount[j] = -2; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = -2; fr->brkpt.prog[j] = program; notify_nolisten(player, "Breakpoint set.", 1); return 0; } else if (!strcasecmp(cmd, "delete")) { add_muf_read_event(descr, player, program, fr); i = atoi(arg); if (!i) { notify_nolisten(player, "Which breakpoint did you want to delete?", 1); return 0; } if (i < 1 || i > fr->brkpt.count) { notify_nolisten(player, "No such breakpoint.", 1); return 0; } j = i - 1; for (j++; j < fr->brkpt.count; j++) { fr->brkpt.temp[j - 1] = fr->brkpt.temp[j]; fr->brkpt.level[j - 1] = fr->brkpt.level[j]; fr->brkpt.line[j - 1] = fr->brkpt.line[j]; fr->brkpt.linecount[j - 1] = fr->brkpt.linecount[j]; fr->brkpt.pc[j - 1] = fr->brkpt.pc[j]; fr->brkpt.pccount[j - 1] = fr->brkpt.pccount[j]; fr->brkpt.prog[j - 1] = fr->brkpt.prog[j]; } fr->brkpt.count--; notify_nolisten(player, "Breakpoint deleted.", 1); return 0; } else if (!strcasecmp(cmd, "breaks")) { notify_nolisten(player, "Breakpoints:", 1); for (i = 0; i < fr->brkpt.count; i++) { ptr = unparse_breakpoint(fr, i); notify_nolisten(player, ptr, 1); } notify_nolisten(player, "*done*", 1); add_muf_read_event(descr, player, program, fr); return 0; } else if (!strcasecmp(cmd, "where")) { i = atoi(arg); muf_backtrace(player, program, i, fr); add_muf_read_event(descr, player, program, fr); return 0; } else if (!strcasecmp(cmd, "stack")) { notify_nolisten(player, "*Argument stack top*", 1); i = atoi(arg); if (!i) i = STACK_SIZE; ptr = ""; for (j = fr->argument.top; j > 0 && i-- > 0;) { cnt = 0; do { strcpyn(buf, sizeof(buf), ptr); ptr = insttotext(NULL, 0, &fr->argument.st[--j], buf2, sizeof(buf2), 4000, program, 1); cnt++; } while (!strcasecmp(ptr, buf) && j > 0); if (cnt > 1) notifyf(player, " [repeats %d times]", cnt); if (strcasecmp(ptr, buf)) notifyf(player, "%3d) %s", j + 1, ptr); } notify_nolisten(player, "*done*", 1); add_muf_read_event(descr, player, program, fr); return 0; } else if (!strcasecmp(cmd, "list") || !strcasecmp(cmd, "listi")) { int startline, endline; add_muf_read_event(descr, player, program, fr); if ((ptr2 = (char *) strchr(arg, ','))) { *ptr2++ = '\0'; } else { ptr2 = ""; } if (!*arg) { if (fr->brkpt.lastlisted) { startline = fr->brkpt.lastlisted + 1; } else { startline = fr->pc->line; } endline = startline + 15; } else { if (!number(arg)) { if (!(pinst = funcname_to_pc(program, arg))) { notify_nolisten(player, "I don't know a function by that name. (starting arg, 1)", 1); return 0; } else { startline = pinst->line; endline = startline + 15; } } else { if (*ptr2) { endline = startline = atoi(arg); } else { startline = atoi(arg) - 7; endline = startline + 15; } } } if (*ptr2) { if (!number(ptr2)) { if (!(pinst = funcname_to_pc(program, ptr2))) { notify_nolisten(player, "I don't know a function by that name. (ending arg, 1)", 1); return 0; } else { endline = pinst->line; } } else { endline = atoi(ptr2); } } i = (PROGRAM_CODE(program) + PROGRAM_SIZ(program) - 1)->line; if (startline > i) { notify_nolisten(player, "Starting line is beyond end of program.", 1); return 0; } if (startline < 1) startline = 1; if (endline > i) endline = i; if (endline < startline) endline = startline; notify_nolisten(player, "Listing:", 1); if (!strcasecmp(cmd, "listi")) { for (i = startline; i <= endline; i++) { pinst = linenum_to_pc(program, i); if (pinst) { notifyf_nolisten(player, "line %d: %s", i, (i == fr->pc->line) ? show_line_prims(program, fr->pc, STACK_SIZE, 1) : show_line_prims(program, pinst, STACK_SIZE, 0)); } } } else { list_proglines(player, program, fr, startline, endline); } fr->brkpt.lastlisted = endline; notify_nolisten(player, "*done*", 1); return 0; } else if (!strcasecmp(cmd, "quit")) { notify_nolisten(player, "Halting execution.", 1); return 1; } else if (!strcasecmp(cmd, "trace")) { add_muf_read_event(descr, player, program, fr); if (!strcasecmp(arg, "on")) { fr->brkpt.showstack = 1; notify_nolisten(player, "Trace turned on.", 1); } else if (!strcasecmp(arg, "off")) { fr->brkpt.showstack = 0; notify_nolisten(player, "Trace turned off.", 1); } else { notifyf_nolisten(player, "Trace is currently %s.", fr->brkpt.showstack ? "on" : "off"); } return 0; } else if (!strcasecmp(cmd, "words")) { list_program_functions(player, program, arg); add_muf_read_event(descr, player, program, fr); return 0; } else if (!strcasecmp(cmd, "print")) { debug_printvar(player, program, fr, arg); add_muf_read_event(descr, player, program, fr); return 0; } else if (!strcasecmp(cmd, "push")) { push_arg(player, fr, arg); add_muf_read_event(descr, player, program, fr); return 0; } else if (!strcasecmp(cmd, "pop")) { add_muf_read_event(descr, player, program, fr); if (fr->argument.top < 1) { notify_nolisten(player, "Nothing to pop.", 1); return 0; } fr->argument.top--; CLEAR(fr->argument.st + fr->argument.top); notify_nolisten(player, "Stack item popped.", 1); return 0; } else if (!strcasecmp(cmd, "help")) { do_helpfile(player, tp_file_man_dir, tp_file_man, "debugger_commands", ""); return 0; } else { notify_nolisten(player, "I don't understand that debugger command. Type 'help' for help.", 1); add_muf_read_event(descr, player, program, fr); return 0; } return 0; }
Cell make_env(void) { Cell e = extend_env(null, null, null); define(atom("make"), primitive(make_primitive), e); define(atom("car"), primitive(car_primitive), e); define(atom("cdr"), primitive(cdr_primitive), e); define(atom("type"), primitive(type_primitive), e); define(atom("set-car!"), primitive(set_car_primitive), e); define(atom("set-cdr!"), primitive(set_cdr_primitive), e); define(atom("null?"), primitive(is_null_primitive), e); define(atom("eq?"), primitive(is_eq_primitive), e); define(atom("add1"), primitive(add1_primitive), e); define(atom("sub1"), primitive(sub1_primitive), e); define(atom("eval"), primitive(eval_primitive), e); define(atom("read"), primitive(read_primitive), e); define(atom("put"), primitive(put_primitive), e); return e; }
SceneTreeItem* Body::child(int indx) { return primitive(indx); }
TreeXMLImporter& child(){ return primitive(); }
Primitive::Ptr Renderer::CreatePane( const sf::Vector2f& position, const sf::Vector2f& size, float border_width, const sf::Color& color, const sf::Color& border_color, int border_color_shift ) { if( border_width <= 0.f ) { return CreateRect( position, position + size, color ); } Primitive::Ptr primitive( new Primitive ); sf::Color dark_border( border_color ); sf::Color light_border( border_color ); Context::Get().GetEngine().ShiftBorderColors( light_border, dark_border, border_color_shift ); float left = position.x; float top = position.y; float right = left + size.x; float bottom = top + size.y; Primitive::Ptr rect( CreateQuad( sf::Vector2f( left + border_width, top + border_width ), sf::Vector2f( left + border_width, bottom - border_width ), sf::Vector2f( right - border_width, bottom - border_width ), sf::Vector2f( right - border_width, top + border_width ), color ) ); Primitive::Ptr line_top( CreateLine( sf::Vector2f( left, top + border_width / 2.f ), sf::Vector2f( right - border_width, top + border_width / 2.f ), light_border, border_width ) ); Primitive::Ptr line_right( CreateLine( sf::Vector2f( right - border_width / 2.f, top ), sf::Vector2f( right - border_width / 2.f, bottom - border_width ), dark_border, border_width ) ); Primitive::Ptr line_bottom( CreateLine( sf::Vector2f( right, bottom - border_width / 2.f ), sf::Vector2f( left + border_width, bottom - border_width / 2.f ), dark_border, border_width ) ); Primitive::Ptr line_left( CreateLine( sf::Vector2f( left + border_width / 2.f, bottom ), sf::Vector2f( left + border_width / 2.f, top + border_width ), light_border, border_width ) ); primitive->Add( *rect.get() ); primitive->Add( *line_top.get() ); primitive->Add( *line_right.get() ); primitive->Add( *line_bottom.get() ); primitive->Add( *line_left.get() ); std::vector<Primitive::Ptr>::iterator iter( std::find( m_primitives.begin(), m_primitives.end(), rect ) ); assert( iter != m_primitives.end() ); iter = m_primitives.erase( iter ); // rect iter = m_primitives.erase( iter ); // line_top iter = m_primitives.erase( iter ); // line_right iter = m_primitives.erase( iter ); // line_bottom m_primitives.erase( iter ); // line_left AddPrimitive( primitive ); return primitive; }
Hexagonal::Hexagonal(double i_alat, char* i_element) { alat = blat = clat = i_alat; species.push_back(i_element); primitive(); }
void get_primitive(PrimitiveType t, Primitive *pri) { pri->Clear(); if (t == kTriangleOut) { Primitive primitive(3, nullptr, nullptr); //primitive.colors[0] = Vector4(1.0, 0, 0, 1.0); //primitive.colors[1] = Vector4(0, 1.0, 0, 1.0); //primitive.colors[2] = Vector4(0, 0, 1.0, 1.0); primitive.colors[0] = Vector4(1.0, 1.0, 1.0, 1.0); primitive.colors[1] = Vector4(1.0, 1.0, 1.0, 1.0); primitive.colors[2] = Vector4(1.0, 1.0, 1.0, 1.0); primitive.positions[0] = Vector3(0, 0, 1); primitive.positions[1] = Vector3(0.25, 0, 0); primitive.positions[2] = Vector3(-0.25, 0, 0); primitive.normals[0] = Vector3(0, 1, 0); primitive.normals[1] = Vector3(0, 1, 0); primitive.normals[2] = Vector3(0, 1, 0); primitive.uvs[0] = Vector2(0, 0); primitive.uvs[1] = Vector2(0, 1); primitive.uvs[2] = Vector2(1, 0); *pri = std::move(primitive); } else if (t == kTriangleIn) { Primitive primitive(3, nullptr, nullptr); primitive.colors[0] = Vector4(1, 1, 1, 1); primitive.colors[1] = Vector4(1, 1, 1, 1); primitive.colors[2] = Vector4(1, 1, 1, 1); primitive.positions[0] = Vector3(0, 0, -1); primitive.positions[1] = Vector3(0.25, 0, 0); primitive.positions[2] = Vector3(-0.25, 0, 0); primitive.normals[0] = Vector3(0, -1, 0); primitive.normals[1] = Vector3(0, -1, 0); primitive.normals[2] = Vector3(0, -1, 0); primitive.uvs[0] = Vector2(0, 0); primitive.uvs[1] = Vector2(0, 1); primitive.uvs[2] = Vector2(1, 0); *pri = std::move(primitive); } else if (t == kSquare) { Primitive primitive(6, nullptr, nullptr); for (int i = 0; i < 6; ++i) { primitive.colors[i] = Vector4(1, 1, 1, 1); primitive.normals[i] = Vector3(0, 0, -1); } primitive.positions[0] = Vector3(-0.5, 0.5, 0); primitive.positions[1] = Vector3(0.5, 0.5, 0); primitive.positions[2] = Vector3(0.5, -0.5, 0); primitive.positions[3] = Vector3(-0.5, 0.5, 0); primitive.positions[4] = Vector3(0.5, -0.5, 0); primitive.positions[5] = Vector3(-0.5, -0.5, 0); primitive.uvs[0] = Vector2(0, 0); primitive.uvs[1] = Vector2(1, 0); primitive.uvs[2] = Vector2(1, 1); primitive.uvs[3] = Vector2(0, 0); primitive.uvs[4] = Vector2(1, 1); primitive.uvs[5] = Vector2(0, 1); *pri = std::move(primitive); } else if (t == kPyramid) { Primitive primitive(18, nullptr, nullptr); for (int i = 0; i < 18; ++i) { primitive.colors[i] = Vector4(1.0f, 1.0, 1.0, 1.0); primitive.normals[i] = Vector3(0, 1, 0); } primitive.positions[0] = Vector3(0, 0, -1); primitive.positions[1] = Vector3(0, 1, 0); primitive.positions[2] = Vector3(1, 0, 0); primitive.positions[3] = Vector3(1, 0, 0); primitive.positions[4] = Vector3(0, 1, 0); primitive.positions[5] = Vector3(0, 0, 1); primitive.positions[6] = Vector3(0, 0, 1); primitive.positions[7] = Vector3(0, 1, 0); primitive.positions[8] = Vector3(-1, 0, 0); primitive.positions[9] = Vector3(-1, 0, 0); primitive.positions[10] = Vector3(0, 1, 0); primitive.positions[11] = Vector3(0, 0, -1); primitive.positions[12] = Vector3(0, 0, -1); primitive.positions[13] = Vector3(1, 0, 0); primitive.positions[14] = Vector3(0, 0, 1); primitive.positions[15] = Vector3(0, 0, -1); primitive.positions[16] = Vector3(0, 0, 1); primitive.positions[17] = Vector3(-1, 0, 0); *pri = std::move(primitive); } }
Real AbcdMathFunction::definiteIntegral(Time t1, Time t2) const { return primitive(t2)-primitive(t1); }
void initprim ( void ) { primitive ( 409 , 41 , 1 ) ; primitive ( 410 , 41 , 2 ) ; primitive ( 411 , 41 , 3 ) ; primitive ( 412 , 41 , 4 ) ; primitive ( 413 , 41 , 5 ) ; primitive ( 414 , 41 , 6 ) ; primitive ( 415 , 41 , 7 ) ; primitive ( 416 , 41 , 8 ) ; primitive ( 417 , 41 , 9 ) ; primitive ( 418 , 41 , 10 ) ; primitive ( 419 , 41 , 11 ) ; primitive ( 420 , 41 , 12 ) ; primitive ( 421 , 41 , 13 ) ; primitive ( 422 , 41 , 14 ) ; primitive ( 423 , 41 , 15 ) ; primitive ( 424 , 41 , 16 ) ; primitive ( 425 , 41 , 17 ) ; primitive ( 426 , 41 , 18 ) ; primitive ( 427 , 41 , 19 ) ; primitive ( 428 , 41 , 20 ) ; primitive ( 429 , 41 , 21 ) ; primitive ( 430 , 41 , 22 ) ; primitive ( 431 , 41 , 23 ) ; primitive ( 432 , 41 , 24 ) ; primitive ( 433 , 41 , 25 ) ; primitive ( 434 , 41 , 26 ) ; primitive ( 435 , 41 , 27 ) ; primitive ( 436 , 41 , 28 ) ; primitive ( 437 , 41 , 29 ) ; primitive ( 438 , 41 , 30 ) ; primitive ( 439 , 41 , 31 ) ; primitive ( 440 , 41 , 32 ) ; primitive ( 441 , 41 , 33 ) ; primitive ( 442 , 41 , 34 ) ; primitive ( 443 , 41 , 35 ) ; primitive ( 444 , 41 , 36 ) ; primitive ( 445 , 41 , 37 ) ; primitive ( 446 , 41 , 38 ) ; primitive ( 447 , 41 , 39 ) ; primitive ( 448 , 41 , 40 ) ; primitive ( 449 , 41 , 41 ) ; primitive ( 408 , 48 , 0 ) ; primitive ( 91 , 64 , 0 ) ; eqtb [9760 ]= eqtb [cursym ]; primitive ( 93 , 65 , 0 ) ; primitive ( 125 , 66 , 0 ) ; primitive ( 123 , 47 , 0 ) ; primitive ( 58 , 82 , 0 ) ; eqtb [9762 ]= eqtb [cursym ]; primitive ( 459 , 81 , 0 ) ; primitive ( 460 , 80 , 0 ) ; primitive ( 461 , 78 , 0 ) ; primitive ( 44 , 83 , 0 ) ; primitive ( 59 , 84 , 0 ) ; eqtb [9763 ]= eqtb [cursym ]; primitive ( 92 , 7 , 0 ) ; primitive ( 462 , 19 , 0 ) ; primitive ( 463 , 73 , 0 ) ; primitive ( 464 , 60 , 0 ) ; primitive ( 465 , 33 , 0 ) ; bgloc = cursym ; primitive ( 466 , 58 , 0 ) ; primitive ( 467 , 20 , 0 ) ; primitive ( 468 , 61 , 0 ) ; primitive ( 469 , 28 , 0 ) ; primitive ( 470 , 12 , 0 ) ; primitive ( 453 , 85 , 0 ) ; eqtb [9767 ]= eqtb [cursym ]; egloc = cursym ; primitive ( 471 , 27 , 0 ) ; primitive ( 472 , 6 , 0 ) ; primitive ( 473 , 10 , 0 ) ; primitive ( 474 , 71 , 0 ) ; primitive ( 475 , 74 , 0 ) ; primitive ( 476 , 14 , 0 ) ; primitive ( 477 , 15 , 0 ) ; primitive ( 478 , 16 , 0 ) ; primitive ( 479 , 70 , 0 ) ; primitive ( 480 , 29 , 0 ) ; primitive ( 481 , 25 , 0 ) ; primitive ( 482 , 9 , 0 ) ; primitive ( 483 , 13 , 0 ) ; primitive ( 484 , 8 , 0 ) ; primitive ( 485 , 18 , 0 ) ; primitive ( 486 , 79 , 0 ) ; primitive ( 487 , 75 , 0 ) ; primitive ( 488 , 36 , 0 ) ; primitive ( 489 , 59 , 0 ) ; primitive ( 490 , 72 , 0 ) ; primitive ( 491 , 76 , 0 ) ; primitive ( 656 , 17 , 1 ) ; primitive ( 657 , 17 , 2 ) ; primitive ( 658 , 17 , 54 ) ; primitive ( 659 , 17 , 45 ) ; primitive ( 660 , 17 , 50 ) ; primitive ( 454 , 17 , 0 ) ; eqtb [9765 ]= eqtb [cursym ]; primitive ( 661 , 4 , 9770 ) ; primitive ( 662 , 4 , 9920 ) ; primitive ( 663 , 4 , 1 ) ; primitive ( 455 , 4 , 0 ) ; eqtb [9764 ]= eqtb [cursym ]; primitive ( 664 , 62 , 0 ) ; primitive ( 665 , 62 , 1 ) ; primitive ( 64 , 62 , 2 ) ; primitive ( 666 , 62 , 3 ) ; primitive ( 677 , 57 , 9770 ) ; primitive ( 678 , 57 , 9920 ) ; primitive ( 679 , 57 , 10070 ) ; primitive ( 680 , 57 , 1 ) ; primitive ( 681 , 57 , 2 ) ; primitive ( 682 , 57 , 3 ) ; primitive ( 692 , 3 , 0 ) ; primitive ( 618 , 3 , 1 ) ; primitive ( 719 , 1 , 1 ) ; primitive ( 452 , 2 , 2 ) ; eqtb [9766 ]= eqtb [cursym ]; primitive ( 720 , 2 , 3 ) ; primitive ( 721 , 2 , 4 ) ; primitive ( 347 , 34 , 30 ) ; primitive ( 348 , 34 , 31 ) ; primitive ( 349 , 34 , 32 ) ; primitive ( 350 , 34 , 33 ) ; primitive ( 351 , 34 , 34 ) ; primitive ( 352 , 34 , 35 ) ; primitive ( 353 , 34 , 36 ) ; primitive ( 354 , 34 , 37 ) ; primitive ( 355 , 35 , 38 ) ; primitive ( 356 , 35 , 39 ) ; primitive ( 357 , 35 , 40 ) ; primitive ( 358 , 35 , 41 ) ; primitive ( 359 , 35 , 42 ) ; primitive ( 360 , 35 , 43 ) ; primitive ( 361 , 35 , 44 ) ; primitive ( 362 , 35 , 45 ) ; primitive ( 363 , 35 , 46 ) ; primitive ( 364 , 35 , 47 ) ; primitive ( 365 , 35 , 48 ) ; primitive ( 366 , 35 , 49 ) ; primitive ( 367 , 35 , 50 ) ; primitive ( 368 , 35 , 51 ) ; primitive ( 369 , 35 , 52 ) ; primitive ( 370 , 35 , 53 ) ; primitive ( 371 , 35 , 54 ) ; primitive ( 372 , 35 , 55 ) ; primitive ( 373 , 35 , 56 ) ; primitive ( 374 , 35 , 57 ) ; primitive ( 375 , 35 , 58 ) ; primitive ( 376 , 35 , 59 ) ; primitive ( 377 , 35 , 60 ) ; primitive ( 378 , 35 , 61 ) ; primitive ( 379 , 35 , 62 ) ; primitive ( 380 , 35 , 63 ) ; primitive ( 381 , 35 , 64 ) ; primitive ( 382 , 35 , 65 ) ; primitive ( 383 , 35 , 66 ) ; primitive ( 384 , 35 , 67 ) ; primitive ( 385 , 37 , 68 ) ; primitive ( 43 , 44 , 69 ) ; primitive ( 45 , 44 , 70 ) ; primitive ( 42 , 56 , 71 ) ; primitive ( 47 , 55 , 72 ) ; eqtb [9761 ]= eqtb [cursym ]; primitive ( 386 , 46 , 73 ) ; primitive ( 310 , 46 , 74 ) ; primitive ( 388 , 53 , 76 ) ; primitive ( 387 , 46 , 75 ) ; primitive ( 60 , 51 , 77 ) ; primitive ( 389 , 51 , 78 ) ; primitive ( 62 , 51 , 79 ) ; primitive ( 390 , 51 , 80 ) ; primitive ( 61 , 52 , 81 ) ; primitive ( 391 , 51 , 82 ) ; primitive ( 401 , 38 , 94 ) ; primitive ( 402 , 38 , 95 ) ; primitive ( 403 , 38 , 96 ) ; primitive ( 404 , 38 , 97 ) ; primitive ( 405 , 38 , 98 ) ; primitive ( 406 , 38 , 99 ) ; primitive ( 407 , 38 , 100 ) ; primitive ( 38 , 49 , 83 ) ; primitive ( 392 , 56 , 84 ) ; primitive ( 393 , 56 , 85 ) ; primitive ( 394 , 56 , 86 ) ; primitive ( 395 , 56 , 87 ) ; primitive ( 396 , 56 , 88 ) ; primitive ( 397 , 56 , 89 ) ; primitive ( 398 , 56 , 90 ) ; primitive ( 399 , 56 , 91 ) ; primitive ( 400 , 46 , 92 ) ; primitive ( 340 , 31 , 15 ) ; primitive ( 326 , 31 , 4 ) ; primitive ( 324 , 31 , 2 ) ; primitive ( 331 , 31 , 9 ) ; primitive ( 328 , 31 , 6 ) ; primitive ( 333 , 31 , 11 ) ; primitive ( 335 , 31 , 13 ) ; primitive ( 336 , 31 , 14 ) ; primitive ( 913 , 86 , 0 ) ; primitive ( 914 , 86 , 1 ) ; primitive ( 273 , 24 , 0 ) ; primitive ( 274 , 24 , 1 ) ; primitive ( 275 , 24 , 2 ) ; primitive ( 920 , 24 , 3 ) ; primitive ( 921 , 22 , 0 ) ; primitive ( 922 , 22 , 1 ) ; primitive ( 936 , 23 , 0 ) ; primitive ( 937 , 23 , 1 ) ; primitive ( 938 , 23 , 2 ) ; primitive ( 939 , 23 , 3 ) ; primitive ( 940 , 23 , 4 ) ; primitive ( 957 , 69 , 1 ) ; primitive ( 958 , 69 , 0 ) ; primitive ( 959 , 69 , 2 ) ; primitive ( 960 , 67 , 6 ) ; primitive ( 961 , 67 , 16 ) ; primitive ( 962 , 68 , 0 ) ; primitive ( 963 , 68 , 1 ) ; primitive ( 993 , 26 , 0 ) ; primitive ( 994 , 26 , 1 ) ; primitive ( 995 , 26 , 2 ) ; primitive ( 1005 , 21 , 0 ) ; primitive ( 1006 , 21 , 1 ) ; primitive ( 1007 , 21 , 2 ) ; primitive ( 1008 , 21 , 3 ) ; primitive ( 1009 , 21 , 4 ) ; primitive ( 1027 , 77 , 0 ) ; primitive ( 1028 , 77 , 1 ) ; primitive ( 1029 , 77 , 5 ) ; primitive ( 1030 , 77 , 2 ) ; primitive ( 1031 , 77 , 6 ) ; primitive ( 1032 , 77 , 3 ) ; primitive ( 1033 , 77 , 7 ) ; primitive ( 1034 , 77 , 11 ) ; primitive ( 1035 , 77 , 128 ) ; primitive ( 1060 , 30 , 4 ) ; primitive ( 1061 , 30 , 16 ) ; }
int muf_debugger(dbref player, dbref program, const char *text, struct frame *fr) { char cmd[BUFFER_LEN]; char buf[BUFFER_LEN]; char *ptr, *ptr2, *arg; struct inst *pinst; int i, j, cnt; while (isspace(*text)) text++; strcpy(cmd, text); ptr = cmd + strlen(cmd); if (ptr > cmd) ptr--; while (ptr >= cmd && isspace(*ptr)) *ptr-- = '\0'; for (arg = cmd; *arg && !isspace(*arg); arg++); if (*arg) *arg++ = '\0'; if (!*cmd && fr->brkpt.lastcmd) { strcpy(cmd, fr->brkpt.lastcmd); } else { if (fr->brkpt.lastcmd) free(fr->brkpt.lastcmd); if (*cmd) fr->brkpt.lastcmd = string_dup(cmd); } /* delete triggering breakpoint, if it's only temp. */ j = fr->brkpt.breaknum; if (j >= 0 && fr->brkpt.temp[j]) { for (j++; j < fr->brkpt.count; j++) { fr->brkpt.temp[j-1] = fr->brkpt.temp[j]; fr->brkpt.level[j-1] = fr->brkpt.level[j]; fr->brkpt.line[j-1] = fr->brkpt.line[j]; fr->brkpt.linecount[j-1] = fr->brkpt.linecount[j]; fr->brkpt.pc[j-1] = fr->brkpt.pc[j]; fr->brkpt.pccount[j-1] = fr->brkpt.pccount[j]; fr->brkpt.prog[j-1] = fr->brkpt.prog[j]; } fr->brkpt.count--; } fr->brkpt.breaknum = -1; if (!string_compare(cmd, "cont")) { } else if (!string_compare(cmd, "finish")) { if (fr->brkpt.count >= MAX_BREAKS) { anotify_nolisten(player, CFAIL "Cannot finish because there are too many breakpoints set.", 1); add_muf_read_event(player, program, fr); return 0; } j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = fr->system.top - 1; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = -2; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = -2; fr->brkpt.prog[j] = program; fr->brkpt.bypass = 1; return 0; } else if (!string_compare(cmd, "stepi")) { i = atoi(arg); if (!i) i = 1; if (fr->brkpt.count >= MAX_BREAKS) { anotify_nolisten(player, CFAIL "Cannot stepi because there are too many breakpoints set.", 1); add_muf_read_event(player, program, fr); return 0; } j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = -1; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = -2; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = i; fr->brkpt.prog[j] = NOTHING; fr->brkpt.bypass = 1; return 0; } else if (!string_compare(cmd, "step")) { i = atoi(arg); if (!i) i = 1; if (fr->brkpt.count >= MAX_BREAKS) { anotify_nolisten(player, CFAIL "Cannot step because there are too many breakpoints set.", 1); add_muf_read_event(player, program, fr); return 0; } j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = -1; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = i; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = -2; fr->brkpt.prog[j] = NOTHING; fr->brkpt.bypass = 1; return 0; } else if (!string_compare(cmd, "nexti")) { i = atoi(arg); if (!i) i = 1; if (fr->brkpt.count >= MAX_BREAKS) { anotify_nolisten(player, CFAIL "Cannot nexti because there are too many breakpoints set.", 1); add_muf_read_event(player, program, fr); return 0; } j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = fr->system.top; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = -2; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = i; fr->brkpt.prog[j] = program; fr->brkpt.bypass = 1; return 0; } else if (!string_compare(cmd, "next")) { i = atoi(arg); if (!i) i = 1; if (fr->brkpt.count >= MAX_BREAKS) { anotify_nolisten(player, CFAIL "Cannot next because there are too many breakpoints set.", 1); add_muf_read_event(player, program, fr); return 0; } j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = fr->system.top; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = i; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = -2; fr->brkpt.prog[j] = program; fr->brkpt.bypass = 1; return 0; } else if (!string_compare(cmd, "exec")) { if (fr->brkpt.count >= MAX_BREAKS) { anotify_nolisten(player, CFAIL "Cannot finish because there are too many breakpoints set.", 1); add_muf_read_event(player, program, fr); return 0; } if (!(pinst = funcname_to_pc(program, arg))) { anotify_nolisten(player, CINFO "I don't know a function by that name.", 1); add_muf_read_event(player, program, fr); return 0; } if (fr->system.top >= STACK_SIZE) { anotify_nolisten(player, CFAIL "That would exceed the system stack size for this program.", 1); add_muf_read_event(player, program, fr); return 0; } fr->system.st[fr->system.top].progref = program; fr->system.st[fr->system.top++].offset = fr->pc; fr->pc = pinst; j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = fr->system.top - 1; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = -2; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = -2; fr->brkpt.prog[j] = program; fr->brkpt.bypass = 1; return 0; } else if (!string_compare(cmd, "prim")) { if (fr->brkpt.count >= MAX_BREAKS) { anotify_nolisten(player, CFAIL "Cannot finish because there are too many breakpoints set.", 1); add_muf_read_event(player, program, fr); return 0; } if (!(i = primitive(arg))) { anotify_nolisten(player, CINFO "I don't recognize that primitive.", 1); add_muf_read_event(player, program, fr); return 0; } if (fr->system.top >= STACK_SIZE) { anotify_nolisten(player, CFAIL "That would exceed the system stack size for this program.", 1); add_muf_read_event(player, program, fr); return 0; } shstr.data[0] = '\0'; shstr.links = 1; shstr.length= strlen(shstr.data); primset[0].type = PROG_FUNCTION; primset[0].line = 0; primset[0].data.string = &shstr; primset[1].type = PROG_PRIMITIVE; primset[1].line = 0; primset[1].data.number = i; primset[2].type = PROG_PRIMITIVE; primset[2].line = 0; primset[2].data.number = primitive("EXIT"); fr->system.st[fr->system.top].progref = program; fr->system.st[fr->system.top++].offset = fr->pc; fr->pc = primset; j = fr->brkpt.count++; fr->brkpt.temp[j] = 1; fr->brkpt.level[j] = fr->system.top - 1; fr->brkpt.line[j] = -1; fr->brkpt.linecount[j] = -2; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = -2; fr->brkpt.prog[j] = program; fr->brkpt.bypass = 1; return 0; } else if (!string_compare(cmd, "break")) { add_muf_read_event(player, program, fr); if (fr->brkpt.count >= MAX_BREAKS) { anotify_nolisten(player, CFAIL "Too many breakpoints set.", 1); return 0; } if (number(arg)) { i = atoi(arg); } else { if (!(pinst = funcname_to_pc(program, arg))) { anotify_nolisten(player, CINFO "I don't know a function by that name.", 1); return 0; } else { i = pinst->line; } } if (!i) i = fr->pc->line; j = fr->brkpt.count++; fr->brkpt.temp[j] = 0; fr->brkpt.level[j] = -1; fr->brkpt.line[j] = i; fr->brkpt.linecount[j] = -2; fr->brkpt.pc[j] = NULL; fr->brkpt.pccount[j] = -2; fr->brkpt.prog[j] = program; anotify_nolisten(player, CSUCC "Breakpoint set.", 1); return 0; } else if (!string_compare(cmd, "delete")) { add_muf_read_event(player, program, fr); i = atoi(arg); if (!i) { anotify_nolisten(player, CINFO "Which breakpoint did you want to delete?", 1); return 0; } if (i < 1 || i > fr->brkpt.count) { anotify_nolisten(player, CFAIL "No such breakpoint.", 1); return 0; } j = i - 1; for (j++; j < fr->brkpt.count; j++) { fr->brkpt.temp[j-1] = fr->brkpt.temp[j]; fr->brkpt.level[j-1] = fr->brkpt.level[j]; fr->brkpt.line[j-1] = fr->brkpt.line[j]; fr->brkpt.linecount[j-1] = fr->brkpt.linecount[j]; fr->brkpt.pc[j-1] = fr->brkpt.pc[j]; fr->brkpt.pccount[j-1] = fr->brkpt.pccount[j]; fr->brkpt.prog[j-1] = fr->brkpt.prog[j]; } fr->brkpt.count--; anotify_nolisten(player, CSUCC "Breakpoint deleted.", 1); return 0; } else if (!string_compare(cmd, "breaks")) { anotify_nolisten(player, CINFO "Breakpoints:", 1); for (i = 0; i < fr->brkpt.count; i++) { ptr = unparse_breakpoint(fr, i); notify_nolisten(player, ptr, 1); } anotify_nolisten(player, CINFO "Done.", 1); add_muf_read_event(player, program, fr); return 0; } else if (!string_compare(cmd, "where")) { i = atoi(arg); muf_backtrace(player, program, i, fr); add_muf_read_event(player, program, fr); return 0; } else if (!string_compare(cmd, "stack")) { anotify_nolisten(player, CINFO "*Argument stack top*", 1); i = atoi(arg); if (!i) i = STACK_SIZE; ptr = ""; for (j = fr->argument.top; j>0 && i-->0;) { cnt = 0; do { strcpy(buf, ptr); ptr = insttotext(&fr->argument.st[--j], 4000, program); cnt++; } while (!string_compare(ptr, buf) && j>0); if (cnt > 1) notify_fmt(player, " [repeats %d times]", cnt); if (string_compare(ptr, buf)) notify_fmt(player, "%3d) %s", j+1, ptr); } anotify_nolisten(player, CINFO "Done.", 1); add_muf_read_event(player, program, fr); return 0; } else if (!string_compare(cmd, "list") || !string_compare(cmd, "listi")) { int startline, endline; startline = endline = 0; add_muf_read_event(player, program, fr); if ((ptr2 = (char *)index(arg, ','))) { *ptr2++ = '\0'; } else { ptr2 = ""; } if (!*arg) { if (fr->brkpt.lastlisted) { startline = fr->brkpt.lastlisted + 1; } else { startline = fr->pc->line; } endline = startline + 15; } else { if (!number(arg)) { if (!(pinst = funcname_to_pc(program, arg))) { anotify_nolisten(player, CINFO "I don't know a function by that name. (starting arg, 1)", 1); return 0; } else { startline = pinst->line; endline = startline + 15; } } else { if (*ptr2) { endline = startline = atoi(arg); } else { startline = atoi(arg) - 7; endline = startline + 15; } } } if (*ptr2) { if (!number(ptr2)) { if (!(pinst = funcname_to_pc(program, ptr2))) { anotify_nolisten(player, CINFO "I don't know a function by that name. (ending arg, 1)", 1); return 0; } else { endline = pinst->line; } } else { endline = atoi(ptr2); } } i = (DBFETCH(program)->sp.program.code + DBFETCH(program)->sp.program.siz - 1)->line; if (startline > i) { anotify_nolisten(player, CFAIL "Starting line is beyond end of program.", 1); return 0; } if (startline < 1) startline = 1; if (endline > i) endline = i; if (endline < startline) endline = startline; anotify_nolisten(player, CINFO "Listing:", 1); if (!string_compare(cmd, "listi")) { for (i = startline; i <= endline; i++) { pinst = linenum_to_pc(program, i); if (pinst) { sprintf(buf, "line %d: %s", i, (i == fr->pc->line) ? show_line_prims(program, fr->pc, STACK_SIZE, 1) : show_line_prims(program, pinst, STACK_SIZE, 0)); notify_nolisten(player, buf, 1); } } } else { list_proglines(player, program, fr, startline, endline); } fr->brkpt.lastlisted = endline; anotify_nolisten(player, CINFO "Done.", 1); return 0; } else if (!string_compare(cmd, "quit")) { anotify_nolisten(player, CINFO "Halting execution.", 1); return 1; } else if (!string_compare(cmd, "trace")) { add_muf_read_event(player, program, fr); if (!string_compare(arg, "on")) { fr->brkpt.showstack = 1; anotify_nolisten(player, CSUCC "Trace turned on.", 1); } else if (!string_compare(arg, "off")) { fr->brkpt.showstack = 0; anotify_nolisten(player, CSUCC "Trace turned off.", 1); } else { sprintf(buf, CINFO "Trace is currently %s.", fr->brkpt.showstack? "on" : "off"); anotify_nolisten(player, buf, 1); } return 0; } else if (!string_compare(cmd, "words")) { list_program_functions(player, program, arg); add_muf_read_event(player, program, fr); return 0; } else if (!string_compare(cmd, "print")) { debug_printvar(player, fr, arg); add_muf_read_event(player, program, fr); return 0; } else if (!string_compare(cmd, "push")) { push_arg(player, fr, arg); add_muf_read_event(player, program, fr); return 0; } else if (!string_compare(cmd, "pop")) { add_muf_read_event(player, program, fr); if (fr->argument.top < 1) { anotify_nolisten(player, CFAIL "Nothing to pop.", 1); return 0; } fr->argument.top--; CLEAR(fr->argument.st + fr->argument.top); anotify_nolisten(player, CSUCC "Stack item popped.", 1); return 0; } else if (!string_compare(cmd, "help")) { notify_nolisten(player, "cont continues execution until a breakpoint is hit.", 1); notify_nolisten(player, "finish completes execution of current function.", 1); notify_nolisten(player, "step [NUM] executes one (or NUM, 1) lines of muf.", 1); notify_nolisten(player, "stepi [NUM] executes one (or NUM, 1) muf instructions.", 1); notify_nolisten(player, "next [NUM] like step, except skips CALL and EXECUTE.", 1); notify_nolisten(player, "nexti [NUM] like stepi, except skips CALL and EXECUTE.", 1); notify_nolisten(player, "break LINE# sets breakpoint at given LINE number.", 1); notify_nolisten(player, "break FUNCNAME sets breakpoint at start of given function.", 1); notify_nolisten(player, "breaks lists all currently set breakpoints.", 1); notify_nolisten(player, "delete NUM deletes breakpoint by NUM, as listed by 'breaks'", 1); notify_nolisten(player, "where [LEVS] displays function call backtrace of up to num levels deep.", 1); notify_nolisten(player, "stack [NUM] shows the top num items on the stack.", 1); notify_nolisten(player, "print v# displays the value of given global variable #.", 1); notify_nolisten(player, "print lv# displays the value of given local variable #.", 1); notify_nolisten(player, "trace [on|off] turns on/off debug stack tracing.", 1); notify_nolisten(player, "list [L1,[L2]] lists source code of given line range.", 1); notify_nolisten(player, "list FUNCNAME lists source code of given function.", 1); notify_nolisten(player, "listi [L1,[L2]] lists instructions in given line range.", 1); notify_nolisten(player, "listi FUNCNAME lists instructions in given function.", 1); notify_nolisten(player, "words lists all function word names in program.", 1); notify_nolisten(player, "words PATTERN lists all function word names that match PATTERN.", 1); notify_nolisten(player, "exec FUNCNAME calls given function with the current stack data.", 1); notify_nolisten(player, "prim PRIMITIVE executes given primitive with current stack data.", 1); notify_nolisten(player, "push DATA pushes an int, dbref, var, or string onto the stack.", 1); notify_nolisten(player, "pop pops top data item off the stack.", 1); notify_nolisten(player, "help displays this help screen.", 1); notify_nolisten(player, "quit stop execution here.", 1); add_muf_read_event(player, program, fr); return 0; } else { anotify_nolisten(player, CINFO "I don't understand that debugger command. Type 'help' for help.", 1); add_muf_read_event(player, program, fr); return 0; } return 0; }
Primitive::Ptr Renderer::CreateText( const sf::Text& text, sf::Color background_color_hint ) { Primitive::Ptr primitive( new Primitive ); const sf::Font& font = text.getFont(); unsigned int character_size = text.getCharacterSize(); sf::Color color = text.getColor(); if( m_preblend ) { color = sf::Color::White; } sf::Vector2f atlas_offset = LoadFont( font, character_size, background_color_hint, text.getColor() ); const sf::String& str = text.getString(); std::size_t length = str.getSize(); float horizontal_spacing = static_cast<float>( font.getGlyph( L' ', character_size, false ).advance ); float vertical_spacing = static_cast<float>( font.getLineSpacing( character_size ) ); sf::Vector2f position( std::floor( text.getPosition().x + .5f ), std::floor( text.getPosition().y + static_cast<float>( character_size ) + .5f ) ); const static float tab_spaces = 2.f; sf::Uint32 previous_character = 0; for( std::size_t index = 0; index < length; ++index ) { sf::Uint32 current_character = str[index]; position.x += static_cast<float>( font.getKerning( previous_character, current_character, character_size ) ); switch( current_character ) { case L' ': position.x += horizontal_spacing; continue; case L'\t': position.x += horizontal_spacing * tab_spaces; continue; case L'\n': position.y += vertical_spacing; position.x = 0.f; continue; case L'\v': position.y += vertical_spacing * tab_spaces; continue; default: break; } const sf::Glyph& glyph = font.getGlyph( current_character, character_size, false ); Primitive::Vertex vertex0; Primitive::Vertex vertex1; Primitive::Vertex vertex2; Primitive::Vertex vertex3; vertex0.position = position + sf::Vector2f( static_cast<float>( glyph.bounds.left ), static_cast<float>( glyph.bounds.top ) ); vertex1.position = position + sf::Vector2f( static_cast<float>( glyph.bounds.left ), static_cast<float>( glyph.bounds.top + glyph.bounds.height ) ); vertex2.position = position + sf::Vector2f( static_cast<float>( glyph.bounds.left + glyph.bounds.width ), static_cast<float>( glyph.bounds.top ) ); vertex3.position = position + sf::Vector2f( static_cast<float>( glyph.bounds.left + glyph.bounds.width ), static_cast<float>( glyph.bounds.top + glyph.bounds.height ) ); vertex0.color = color; vertex1.color = color; vertex2.color = color; vertex3.color = color; // Let SFML cast the Rect for us. sf::FloatRect texture_rect( glyph.textureRect ); vertex0.texture_coordinate = atlas_offset + sf::Vector2f( texture_rect.left, texture_rect.top ); vertex1.texture_coordinate = atlas_offset + sf::Vector2f( texture_rect.left, texture_rect.top + texture_rect.height ); vertex2.texture_coordinate = atlas_offset + sf::Vector2f( texture_rect.left + texture_rect.width, texture_rect.top ); vertex3.texture_coordinate = atlas_offset + sf::Vector2f( texture_rect.left + texture_rect.width, texture_rect.top + texture_rect.height ); primitive->AddVertex( vertex0 ); primitive->AddVertex( vertex1 ); primitive->AddVertex( vertex2 ); primitive->AddVertex( vertex2 ); primitive->AddVertex( vertex1 ); primitive->AddVertex( vertex3 ); position.x += static_cast<float>( glyph.advance ); previous_character = current_character; } AddPrimitive( primitive ); return primitive; }
var tau::operator()(const var&v){ var out; out.real=mapping(v.real); for_each_copy(v.dual->begin(),v.dual->end(),inserter(*(out.dual),out.dual->begin()),mul_make_pair<std::pair<int,double> >, primitive(v.real)); return out; }
SortedDistanceComparisonData::SortedDistanceComparisonData(const common::Structure & structure, const bool volumeAgnostic, const bool usePrimitive) { // This needs to be in this scope so it lasts until we return common::StructurePtr primitive(new common::Structure(structure)); if(usePrimitive) primitive->makePrimitive(); const common::UnitCell * const unitCell = primitive->getUnitCell(); if(volumeAgnostic) { // If we are to be volume agnostic then set the volume to 1.0 per atom const double scaleFactor = primitive->getNumAtoms() / unitCell->getVolume(); primitive->scale(scaleFactor); } if(unitCell) { ::arma::vec3 diag = unitCell->getLongestDiagonal(); const double longestDiag = sqrt(::arma::dot(diag, diag)); cutoff = SortedDistanceComparator::CUTOFF_FACTOR * longestDiag; } const common::DistanceCalculator & distCalc = primitive->getDistanceCalculator(); // Get the unit cell and number of atoms, need to do this as making the // structure primitive may have changed these so we need to store them volume = unitCell->getVolume(); numAtoms = primitive->getNumAtoms(); primitive->getAtomSpecies(species); ::std::set<common::AtomSpeciesId::Value> speciesSet(species.begin(), species.end()); species.resize(speciesSet.size()); ::std::copy(speciesSet.begin(), speciesSet.end(), species.begin()); const size_t numSpecies = species.size(); initSpeciesDistancesMap(); // Calculate the distances ... common::AtomSpeciesId::Value specI, specJ; DistancesVecPtr distVecIJ; for(size_t i = 0; i < numAtoms; ++i) { const common::Atom & atomI = primitive->getAtom(i); specI = atomI.getSpecies(); DistancesMap & iDistMap = speciesDistancesMap[specI]; // Now to all the others for(size_t j = 0; j < numAtoms; ++j) { const common::Atom & atomJ = primitive->getAtom(j); specJ = atomJ.getSpecies(); distVecIJ = iDistMap[specJ]; distCalc.getDistsBetween(atomI, atomJ, cutoff, *distVecIJ); } } // ... and sort them for(size_t i = 0; i < numSpecies; ++i) { specI = species[i]; DistancesMap & iDistMap = speciesDistancesMap[specI]; for(size_t j = i; j < numSpecies; ++j) { specJ = species[j]; distVecIJ = iDistMap[specJ]; ::std::sort(distVecIJ->begin(), distVecIJ->end()); } } }