Exemplo n.º 1
0
void OPTypeBase::PrintNote(DialectLocationBase& location, DialectNote& noteitem,
                           opSectionStream& stream) {
    if (!noteitem.GetNoteDefinition()) return;

    // check against criteria
    if (!noteitem.IsMapped(this)) return;

    NoteDefinitionNode* notenode = noteitem.GetNoteDefinition();

    if (!notenode) return;

    // NOTE: should I print something on skip?
    if (notenode->IsBodyEmpty()) return;

    // print initial conditionals
    int conditions = PrintConditions(stream);

    stream.PrintComment("\t//defined note: " + GetTypeSettings()->GetName() +
                        "::" + location.GetName() + "::" + noteitem.GetName());
    stream << endl;

    PrintNote(noteitem, stream);

    // print ending conditionals
    PrintConditionEnd(conditions, stream);
}
Exemplo n.º 2
0
int handle_REQ_PROG_STEP_REPLY( unsigned char * pkt, unsigned short )
{
    prog_step_ret * pr = ( prog_step_ret * ) pkt;

    printf( "Trap reply: REQ_PROG_STEP\n" );

    printf( "    Stack:  %.04x:%.08x\n", pr->stack_pointer.segment, pr->stack_pointer.offset );
    printf( "    PC:     %.04x:%.08x\n", pr->program_counter.segment, pr->program_counter.offset );
    PrintConditions( pr->conditions );

    return 1;
}
Exemplo n.º 3
0
//--------------------------------------------------------------------------------------------------------赛题入口
void search_route(char *graphStream[5000], int edge_num, char *conditionsStream)
{
    Graph graph;
    EdgeInfoDict edgeInfoDict;
    int source;
    int dest;
    Conditions conditions;
    ShortestPathDict pathDict;


    ReadGraphData(graphStream, graph, edgeInfoDict);
    ReadConditionsData(conditionsStream, source, dest, conditions);

    std::set<int> without;
    without.insert(1);
    without.insert(2);
    Dijkstra(graph, edgeInfoDict, 1, pathDict);

    PrintGraph(graph, edgeInfoDict);
    PrintConditions(source, dest, conditions);
    PrintShortestPathDict(pathDict);
}
Exemplo n.º 4
0
void OPObjectNode::PrintFunctionMapping(opSectionStream& stream,
                                        DialectCategory& category,
                                        DialectLocation& location,
                                        DialectMap& mapinfo,
                                        FunctionStatementBase* statement,
                                        int map_index) {
    const opParameters& p = opParameters::Get();

    DialectNote& note = mapinfo.GetMappingNote();
    NoteDefinitionNode& notenode = *note.GetNoteDefinition();

    stream.PrintComment("\t//defined note: " + category.GetName() +
                        "::" + location.GetName() + "::" + mapinfo.GetName() +
                        "::mapping");
    stream << endl;

    // print all start conditions
    int conditions = PrintConditions(stream);

    // get all available modifier values
    vector<ValuedModifierNode*> arguments;
    statement->BuildValueModifiers(arguments);

    // get the argument names from the note definition
    vector<opString> argumentnames;
    notenode.GetArguments(argumentnames);

    stacked<BraceBlockNode> clonebody = notenode.GetBody()->Clone();
    stacked<ExpandableNode> clonenode =
        opNode::Transform<ExpandableNode>(clonebody);

    stackedgroup temparguments;

    // loop over all the argument names, find values for them
    int numargs = (int)argumentnames.size();
    for (int i = 0; i < numargs; i++) {
        opNode* argumentvalue = NULL;
        opString argumentname = argumentnames[i];

        if (!argumentvalue) argumentvalue = GetContextArgument(argumentname);
        if (!argumentvalue)
            argumentvalue = GetModifierArgument(argumentname, arguments);
        if (!argumentvalue)
            argumentvalue =
                GetStatementArgument(argumentname, statement, temparguments);
        if (!argumentvalue)
            argumentvalue =
                GetMappingArgument(argumentname, map_index, temparguments);

        if (!argumentvalue) {
            // error couldn't find argument
            // this should never happen in release
            // since it should be caught earlier
            Log("internal error! couldn't find function mapping argument: " +
                argumentnames[i]);
            opException::ThrowException();
        } else {
            if (p.Notations) {
                IgnoreNewlines setting(stream.body);

                stream << "\t//\targument '" << argumentnames[i] << "' = \"";
                argumentvalue->PrintOriginal(stream);
                setting.Disable();

                stream << "\"" << endl;
            }

            clonenode->ReplaceNodes(argumentname, argumentvalue);
        }
    }

    // perform operations
    //	MacroOperationWalker operations(*clonenode);

    bool bHidden = note.IsHidden();

    stream.Indent();
    stream.Indent();

    if (p.Notations) {
        stream.PrintComment("//expansion start");
        stream << endl;
    }

    bool bCompact;

    // handle verbatim
    if (notenode.GetVerbatim()) {
        bCompact = opParameters::Get().Compact;

        opParameters::GetWritable().Compact = false;
    }

    {
        LineOrigin origin(stream, statement);

        if (!bHidden) {
            clonenode->PrintOriginal(stream);
            stream << endl;
        } else {
            LineOverride linesetting(stream, statement);
            clonenode->PrintOriginal(stream);
            stream << endl;
        }
        if (p.Notations) {
            stream.PrintComment("//expansion end");
            stream << endl;
        }
    }

    // handle verbatim
    if (notenode.GetVerbatim()) opParameters::GetWritable().Compact = bCompact;

    stream.DeIndent();
    stream.DeIndent();

    clonenode.Delete();

    // print conditions end
    PrintConditionEnd(conditions, stream);
}
Exemplo n.º 5
0
void OPObjectNode::PrintFunctionMap(opSectionStream& stream,
                                    DialectCategory& category,
                                    DialectLocation& location,
                                    DialectMap& mapinfo) {
    const opParameters& p = opParameters::Get();

    iterator i = Body->GetBegin();
    iterator end = Body->GetEnd();

    stream << endl;
    stream.PrintComment("// function map '" + mapinfo.GetName() + "'");
    stream << endl;

    int conditions = PrintConditions(stream);

    // add a printer that uses the categories...
    // which could easily map into an expansion layer.
    PrintFunctionMapStart(stream, category, location, mapinfo);

    int map_index = 0;

    while (i != end) {
        FunctionStatementBase* statement = i->ToFunctionStatementBase();

        if (statement) {
            // does this statement satisfy the mapping criteria?
            if (!mapinfo.IsMapped(statement)) {
                ++i;
                continue;
            }

            if (p.Notations) {
                stream << "\t// function mapping found: ";
                {
                    IgnoreNewlines ignorelines(stream.body);
                    statement->PrintOriginal(stream);
                }
                stream << endl;

                if (ModifiersNode* automods = statement->GetAutoModifiers()) {
                    stream << "\t//\tautomatic modifiers: ";
                    {
                        IgnoreNewlines ignorelines(stream.body);
                        automods->PrintOriginal(stream);
                    }
                    stream << endl;
                }
            }

            PrintFunctionMapping(stream, category, location, mapinfo, statement,
                                 map_index);
            ++map_index;
        }

        ++i;
    }

    PrintFunctionMapEnd(stream, category, location, mapinfo, map_index);

    // print end conditions
    PrintConditionEnd(conditions, stream);
}