CN106293653A - Code process method and device - Google Patents

Code process method and device Download PDF

Info

Publication number
CN106293653A
CN106293653A CN201510256398.XA CN201510256398A CN106293653A CN 106293653 A CN106293653 A CN 106293653A CN 201510256398 A CN201510256398 A CN 201510256398A CN 106293653 A CN106293653 A CN 106293653A
Authority
CN
China
Prior art keywords
node
code
sequence
pending
title
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201510256398.XA
Other languages
Chinese (zh)
Other versions
CN106293653B (en
Inventor
李金龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Tencent Computer Systems Co Ltd
Original Assignee
Shenzhen Tencent Computer Systems Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Tencent Computer Systems Co Ltd filed Critical Shenzhen Tencent Computer Systems Co Ltd
Priority to CN201510256398.XA priority Critical patent/CN106293653B/en
Publication of CN106293653A publication Critical patent/CN106293653A/en
Application granted granted Critical
Publication of CN106293653B publication Critical patent/CN106293653B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Devices For Executing Special Programs (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The open a kind of code process method and device of the present invention, method includes: resolves object code and obtains the syntax tree that described object code is corresponding;Resolve described syntax tree, determine the operation that described object code includes, and by described syntax tree is carried out topological sorting, the sequence of operation that described object code is comprised;Generate the operation node one to one included with described object code, and serializing result of based on the operation included by described object code, and the node generated generates sequence node, the serializing result of the sequence of the node included by described sequence node operation included with described object code is corresponding;Each node in described sequence node is resolved by based on each node in described sequence node information successively, obtains the intermediate language code that described object code is corresponding.Use the present invention, it is possible in the transformation process of vectogram, export readable medium content realizing object code.

Description

Code process method and device
Technical field
The present invention relates to intermediate language technology, particularly relate to a kind of code process method and device.
Background technology
SQL (SQL, Structured Query Language) be a kind of data base querying and Programming language, data circulation refer to one group sequential, have the node set of beginning and end, use The form of data stream represents SQL, and the atomic node set in SQL text is organized in a certain order Get up, finally give data flow diagram, referred to as a vectogram;
At present about the technical scheme that the related art scheme that SQL is converted into vector graphics is considerably less, main It is first SQL to be resolved, and gained content will be resolved by extensible markup language (XML, Extensible Markup Language) store or directly process, and use the shape library of high level language to be depicted as The vectogram of equal value with SQL.
SQL is converted into vectogram, from form and structure, there is the biggest difference cause based on correlation technique Realize realizing during this conversion extremely complex, there is not readable exportable medium content, even if this results in The data craft being proficient in SQL is difficult to participate in the conversion process from SQL to vector graphics.
In sum, correlation technique is for realizing SQL in the transformation process of vectogram, and how to realize can Read the output of medium content, there is no effective solution.
Summary of the invention
The embodiment of the present invention provides a kind of code process method and device, it is possible to realizing at object code such as SQL exports readable medium content in the transformation process of vectogram.
The technical scheme of the embodiment of the present invention is achieved in that
The embodiment of the present invention provides a kind of code process method, and described method includes:
Resolve object code and obtain the syntax tree that described object code is corresponding;
Resolve described syntax tree, determine the operation that described object code includes, and by described syntax tree is entered Row topological sorting, the sequence of operation that described object code is comprised;
Generate the operation node one to one included with described object code, and based on described object code institute Including the serializing result of operation, and the node generated generates sequence node, described sequence node institute Including the sequence serializing result that operate included with described object code of node corresponding;
Described each node is resolved by based on each node in described sequence node title successively, To the intermediate language code that described object code is corresponding.
The embodiment of the present invention provides a kind of code processing apparatus, and described device includes:
First resolution unit, obtains, for resolving object code, the syntax tree that described object code is corresponding;
Second resolution unit, is used for resolving described syntax tree, determines the operation that described object code includes, and By described syntax tree is carried out topological sorting, determine the serializing result of the operation that described code includes;
Sequence node signal generating unit, for generating the operation node one to one included with described object code, And serializing result of based on the operation included by described object code, and the node generated generates node Sequence, the serializing of the sequence of the node included by described sequence node operation included with described object code Result is corresponding;
Code generating unit, for title based on each node in described sequence node successively to described often Individual node resolves, and obtains the intermediate language code that described object code is corresponding.
In the embodiment of the present invention, characterized the syntax tree structure of object code by sequence node, by node The resolving of sequence creates readable medium content (intermediate language code), in order to data craft participates in With interfere conversion process, follow-up can based on intermediate language code generate vectogram, reduce by object code to The complexity of vector graphics conversion.
Accompanying drawing explanation
Fig. 1 is the flow chart one of code process method in the embodiment of the present invention;
Fig. 2 a is the structural representation one of code processing apparatus in the embodiment of the present invention;
Fig. 2 b is the structural representation two of code processing apparatus in the embodiment of the present invention;
Fig. 2 c is the hardware structure schematic diagram of code processing apparatus in the embodiment of the present invention;
Fig. 3 is to generate vectogram based on SQL code in the embodiment of the present invention, and output can in transformation process Read intermediate language realize schematic flow sheet;
Fig. 4 is the structural representation of JSON node in the embodiment of the present invention;
Fig. 5 a be in the embodiment of the present invention as the entitled data_source of the node of JSON sequence to joint Click on row operation process realizes schematic flow sheet;
Fig. 5 b is to carry out node as the entitled filter of the node of JSON sequence in the embodiment of the present invention Calculation process realize schematic flow sheet;
Fig. 5 c is to transport node as the entitled join of the node of JSON sequence in the embodiment of the present invention What calculation processed realizes schematic flow sheet;
Fig. 6 is to carry out generating DSIL code to a complete JSON sequence in the embodiment of the present invention Process realizes schematic flow sheet;
Fig. 7 is the schematic diagram that designs a model of data_source class in the embodiment of the present invention;
Fig. 8 is the schematic diagram of the Runtime class figure that DSIL relies in the embodiment of the present invention;
Fig. 9 be in the embodiment of the present invention draw vectogram realize schematic flow sheet;
Figure 10 is the schematic diagram of class figure corresponding with JSON node in the embodiment of the present invention.
Detailed description of the invention
Below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that herein Described specific embodiment, only in order to explain the present invention, is not intended to limit the present invention.
Intermediate language (Intermediate Language), in computer science, refers to that one is applied to abstract The programming language of machine (Abstract Machine), the purpose of its design, it is used to help analytical calculation machine Program, in the embodiment of the present invention, the characteristic according to SQL employs a kind of brand-new intermediate language, by this Between language can simplify the difficulty changed by SQL to vector graphics, and support to change to vectogram at SOL During export readable intermediate language.
Field language-specific (DSL, Domain-specific Language) is to pay close attention to certain field specific, There is readability and be easy to the language that developer preferably exchanges with domain expert, general by DSL of inventor Read and devise the intermediate language changed to vector graphics for SQL, i.e. DISH Intermediate for DISH Language, is called for short DSIL.
Embodiments provide and a kind of realize SQL by DSIL and change to vector graphics, and support defeated Going out the solution of readable intermediate language, DSIL therein is easy to data craft and is participated in and interfere transformed Journey, for by Object Code Generator vectogram the process that exports intermediate language corresponding to object code, including The design of intermediate language, generate, run three parts, generate intermediate language code corresponding to object code The flow process of process is as it is shown in figure 1, comprise the following steps:
Step 101, resolves object code and obtains the syntax tree that described object code is corresponding.
Namely object code text resolution is become the data being easy to be resolved by computer program to tie by parsing object code Structure, it is simple to follow-up process (such as obtaining sequence node).
Step 102, resolves described syntax tree, determines the operation that described object code includes, and by institute Belong to syntax tree and carry out topological sorting, the sequence of operation that described object code is comprised.
Operational order in operation namely code, as a example by SQL, the operational order such as including join, filter.
Step 103, generates the operation node one to one included with described object code, and based on described The serializing result of the operation included by object code, and the node generation sequence node generated, described The serializing result of the sequence of the node included by sequence node operation included with described object code is corresponding.
Here node based on default data standard (hereinafter will be described in more detail) by object code Operation recombinate in a specified pattern, such as represent (JSON, JavaScript with JavaScript scripting object Object Natation) form restructuring, or recombinate with extending mark language (XML) form, obtain node Sequence.
As an example, the operation node one to one that described generation and described object code include, bag Include: in terms of determining the title corresponding to the operation that described object code includes, attribute, output at least three Information;Based on the information in terms of at least three corresponding to each described operation, generate each described operation right The node answered.
Step 104, described each node is entered by based on each node in described sequence node title successively Row resolves, and obtains the intermediate language code that described object code is corresponding.
Step 104 can be accomplished by: based on the pending node in described sequence node extremely The information of few three aspects generates instantiation code, comprises corresponding with pending node in described instantiation code The title of object;In order to safeguard intermediate code context relation, introduce a stack and store described pending The title of the object of node.After the instantiation code that node belonging to having generated is corresponding, the example that will be generated The title changing the node object corresponding to code carries out stack-incoming operation.
Above-mentioned implementation title based on pending node (namely title of the operation of correspondence) of step 104 Carry out alignment processing:
1) when the entitled data source of the pending node in described sequence node (namely in sequence node To first node, corresponding action name is data_source), at least three to described pending node The information of aspect generates the instantiation code corresponding with described pending node;
The title of the node object of the described pending node of correspondence arranged by the instantiation code of generation enters Stack operation.
2) when described pending node entitled common factor or merge time (namely the operation of correspondence be join or Union), the title of the corresponding node object of two processed nodes before corresponding described pending node Carry out twice Pop operations, utilize two the node object titles popped to generate corresponding with described pending node Instantiation code, and the title of the node object of the described node of correspondence that the instantiation code that obtains is arranged Carry out stack-incoming operation.
3) when the entitled non-data source of the pending node in described sequence node, non-common factor and unconsolidated time (namely the title of operation corresponding to pending node is not appointing in data_source, join and union One operation), the title of the node object corresponding to the processed node before described pending node is popped Operation, utilizes the information in terms of at least three of node object title and the described pending node popped Generate instantiation code and the function call code of corresponding described pending node;
The title of the node object of the described pending node of correspondence arranged by the instantiation code of generation enters Stack operation.
The instantiation code of above-mentioned generation and function call code are that the intermediate language of corresponding object code describes Code, intermediate language code by reading intermediate language code and can be modified, with right by data craft The pilot process being converted to vectogram from object code is interfered.
Generate vectogram based on intermediate language code can be accomplished by: based on pre-loaded fortune The application programming interfaces that row storehouse provides and operation class, perform described intermediate language code, draw out and described joint Point graph of a correspondence element;The vectogram corresponding with described object code is built based on described graphic element;By In exporting readable intermediate language code by aforementioned processing, data craft can be by language in the middle of amendment Speech code carries out artificial interference adjustment to the process from object code to vectogram, and based on interfering and adjusting after Intermediate language code draws vectogram.
Corresponding with above-mentioned process, the embodiment of the present invention records a kind of code processing apparatus, as shown in Figure 2 a, bag Include:
First resolution unit 10, obtains, for resolving object code, the syntax tree that described object code is corresponding;
Second resolution unit 20, is used for resolving described syntax tree, determines the operation that described object code includes, And by described syntax tree is carried out topological sorting, the sequence of operation that described object code is comprised;
Sequence node signal generating unit 30, saves one to one for generating the operation included with described object code Point, and serializing result based on the operation included by described object code, and the node generation generated Sequence node, the sequence of the sequence of the node included by described sequence node operation included with described object code Rowization result is corresponding;
Code generating unit 40, for information based on each node in described sequence node successively to described Each node in sequence node resolves, and obtains the intermediate language code that described object code is corresponding.
As an embodiment, described sequence node signal generating unit 30, including:
Output subelement 301, for determine title corresponding to the operation that described object code includes, attribute, Information in terms of output at least three;
Node generates subelement 302 (coupling with output subelement 301), for based on each described operation institute The corresponding information in terms of at least three, generates the node corresponding with each described operation.
As an embodiment, described code generating unit 40 is additionally operable to based on treating in described sequence node The information in terms of at least three of node that processes at least generates instantiation code, comprises in described instantiation code The title of the node object corresponding with described pending node;The joint set by instantiation code that will be generated The title of some object carries out stack-incoming operation.
As an embodiment, described code generating unit 40 includes:
First code generation module 401, for when the entitled number of the pending node in described sequence node During according to source, the information in terms of at least three of described pending node is generated corresponding with described pending node Instantiation code;
First stack operation module 402, for waiting to locate described in the correspondence of the instantiation code of described generation setting The title of the node object of reason node carries out stack-incoming operation.
As an embodiment, described code generating unit 40 includes:
3rd stack operation module 403, for when the entitled non-number of the pending node in described sequence node According to source, non-common factor and unconsolidated time, the node pair corresponding to the processed node before described pending node The title of elephant carries out Pop operations, and it is right that the instantiation code generated by third generation code generation module 404 is arranged The title answering the node object of described pending node carries out stack-incoming operation.
Described third generation code generation module 404, for utilize the node object title popped and described in treat Process node at least three in terms of information generate the instantiation code corresponding with described pending node and Function call code.
As an embodiment, described code generating unit 40 includes:
Second stack operation module 405, for when described pending node entitled common factor or merge time, right The title of the corresponding node object of two processed nodes before described pending node carries out twice popping Operation, the described pending node of correspondence that the instantiation code obtained by second code generation module 406 is arranged The title of node object carry out stack-incoming operation;
Described second code generation module 405, for utilizing two the node object titles popped to generate and institute State the instantiation code that pending node is corresponding.
As an embodiment, as shown in Figure 2 b, described device can also include:
Intermediate language code running unit 50, connects for the application program provided based on pre-loaded Runtime Library Mouth and operation class, perform described intermediate language code, draw out and described node graph of a correspondence element;
The vectogram corresponding with described object code is built based on described graphic element.
Each unit in code processing apparatus can be by single calculating equipment (such as server, PC) or server set Calculating resource (including CPU and internal memory) in Qun realizes;Or use client/server (C/S) Framework form, or use the framework form of browser/server (B/S);One example as shown in Figure 2 c, Code processing apparatus can be distributed and be arranged in the cluster that multiple server rack is configured to.
The present embodiment records a kind of computer-readable medium, can be ROM (such as, read only memory, FLASH memory, transfer device etc.), magnetic storage medium (such as, tape, disc driver etc.), light Learn storage medium (such as, CD-ROM, DVD-ROM, paper card, paper tape etc.) and other know class The program storage of type;In described computer-readable medium, storage has computer executable instructions, when performing institute When stating instruction, at least one processor is caused to perform to include following operation:
Resolve object code and obtain the syntax tree that described object code is corresponding;
Resolve described syntax tree, determine the operation that described object code includes, and by described syntax tree is entered Row topological sorting, the sequence of operation that described object code is comprised;
Generate the operation node one to one included with described object code, and based on described object code institute Including the serializing result of operation, and the node generated generates sequence node, described sequence node institute Including the sequence serializing result that operate included with described object code of node corresponding;
Described each node is resolved by based on each node in described sequence node title successively, To the intermediate language code that described object code is corresponding.
Generate vectogram in conjunction with based on SQL code below, and in transformation process, export readable middle language The process of speech illustrates, as it is shown on figure 3, comprise the following steps:
Step 201, parsing SQL (corresponding object code) obtain data.
Resolve SQL and obtain the statement that data refer to SQL text resolution one-tenth can be identified, be performed, The topological structure of statement namely syntax tree.
Step 202, DSIL generation module resolve data.
DSIL generation module (first resolution unit the 10, second resolution unit 20 in corresponding diagram 2a, node Sequence generating unit 30 and code generating unit 40) resolve state a data standard, it is only necessary to press The data namely the syntax tree that are obtained by parsing SQL according to this data standard are recombinated with JSON form, obtain length JSON (node) sequence of at least 1, it should be noted that can also use XML in actual application Form will resolve the data recombination that SQL obtains, but inventor finds in the practice of the invention, uses The data that JSON form restructuring parsing SQL obtains can be obviously improved follow-up treatment effeciency.
Being described in detail below of data standard:
The data recombination that parsing SQL obtains can be become a length to be at least the JSON of 1 by DSIL generation module Sequence, as shown in Figure 4, the least unit of sequence node is referred to as JSON node, and each JSON node has There are title (name), attribute (attribute) and the information of output (outpins) three aspects.Wherein Name represents the title of a SQL operation, as containing that example, the value of name and each value represent Justice is as follows:
1) data_source, corresponding simple Select statement;
2) filter, the Where condition in corresponding SQL;
3) field_ext, increases self-defined row in corresponding SQL;
4) group, the Group by corresponding SQL;
5) limit, the line number in corresponding SQL limits Limit;
6) order, the Order by statement in corresponding SQL;
7) full_join, left_join, join, the Join operation in corresponding SQL, and carried out exhaustive division;
8) the Union operation of union, corresponding SQL.
Attribute can with use array form, for store SQL operation details, such as condition, point Group etc.;The attribute that different SQL operations is corresponding is the most different, as example, SQL operation correspondence The concrete corresponding relation of attribute is as follows:
1) attribute of data_source includes tableinfo_src attribute, is used for storing data base's table name;
2) attribute of filter includes whereinfo attribute, for storage condition content, such as " col > 1 ";
3) attribute of field_ext includes filednew attribute, is used for storing the content of extension columns, filednew Being the array in Javascript, the row of extension are stored in array element form, and each element comprises attribute as (field another name in sql), handle (produces the statement of this field, such as constant value or sql statement etc.), DataType (data type, such as string, number etc.);
4) attribute of group includes groupinfo attribute, is used for storing the specifying information of division operation, Comprise two attributes, value and groupBy;Value attribute is used for storing the field portions of group statement, The aggregate function etc. often occurred in such as group, value is Javascript array, wherein each field letter Breath is element, comprises as (field another name), and handle (produces the sql of this field, such as aggregate function), Three attributes of colName (producing the original field of another name field, the parameter of aggregate function can be made).
5) attribute of limit includes limitinfo attribute, is used for storing the concrete of pulling data line number restriction Information, only retains the numerical value after Limit, does not comprise limit character string;
6) attribute of order includes orderinfo attribute, for the specifying information of memory sequencing operation, Comprise two attributes, value and orderBy;Value attribute is used for storing the sort sections of order statement, Value is Javascript array, and wherein each sequence is element, comprise handle (sortord desc, Asc), two attributes of colName (field of sequence).
7) attribute of full_join, left_join, join includes joininfo attribute, is used for storing table The specifying information of linked operation, is array including value and valueOn, value, and the inside stored table connects Annexation, each element includes two attributes of colName and on, and both represent respectively from a table and b The field of table, connection is to carry out at the record that two field values are equal, and valueOn is then whole annexation The character string linked by " AND ";
8) attribute of union includes unioninfo attribute, is used for storing the specifying information of converging operationJu Hecaozuo, Comprise value and uniontype, tetra-attributes of inpinsa, inpinsb;Value is array, each polymerization Relation, to being an element, comprises colName, tri-attributes of eq, as, represents the colName of a table Field is vertical merged as newer field as with the eq field of another one table;Uniontype is polymeric type, Mainly there is union and union all two kinds;Inpinsa with inpinsb structure is consistent, is array, storage polymerization Relation, each element is the character string of [colName] as [eq].
9) outpins is also an array, the output row of one SQL statement of storage, comprises outpinBase With outpinInfo two parts, outpinBase is array, and internal each element is the output row of present node, Comprise tri-attributes of colName, as, dataType, outpinInfo then be use ", " split multiple The long character string of [colName] as [as] substring.
Step 203, DSIL generation module analysis result based on data generates DSIL code of equal value.
Namely DSIL generation module generates DSIL code of equal value by resolving JSON sequence further: will In JSON sequence, Key namely the name of each JSON node are referred to as operator, by the knot after calculation process Fruit is as operand, such that it is able to entered by the process conversion DSIL generation module resolving whole JSON sequence The process that row Inverse Polish notation resolves.
The Key of JSON node is carried out Inverse Polish notation dissection process, a complete JSON as operator Just using Key as the mark for recognition node, base when sequence carries out calculation process (Inverse Polish notation parsing) When finite-state automata carries out calculation process, the foundation of state switching, transports each JSON node Calculation process during, the node object obtained through calculation process is put in stack as operand, under According to state status node object popped during next state conversion or continue stacked operation.
Here based on finite-state automata each JSON node carried out the type of state during calculation process Consistent with title (name) value in JSON node, wherein state is data source (data_source) Time need to carry out single stack-incoming operation, when for occuring simultaneously (join) or performing continuously during union operation (union) Popping twice operation, state is to first carry out Pop operations during other types to perform stack-incoming operation again.
Here generation instantiation code refers to the javascript code that can be used to draw figure of equal value, this portion The Main Function dividing code is exactly the information of node to be expressed with the form of javascript statement, in order to DSIL runs module (the intermediate language code running unit 50 in corresponding diagram 2b) and performs.With a node The establishment of corresponding DSIL data object (instantiation code) divides three parts, and first is basic object Creating, second is to set property, and the 3rd is to arrange output pin information, and corresponding diagram 5a is to figure respectively Generation xxx instantiation code, generation attribute*** and * * * code and setOutpins function in 5c are adjusted By the step (wherein * * * is asterisk wildcard) of code.It addition, last generation confirm code is by currently The title of the node object set by embodiment code is stacked.
For the operation of filter and join two types (title), owing to the input of this operation is two nodes, Therefore, when reading such node, need be successively read from stack two nodes as input parameter, With one filter or join object of information corresponding instanceization of the two node, the new node object obtained Title (can be to use the form of name index) can replace two nodes just popped to deposit as new node In stacked.
For other types node, owing to need not Pop operations, the most directly carry out instantiated nodes corresponding Node object, continue read next node carry out type judgement, when all node traverses complete, finally Generate one section of DSIL code that can perform in DSIL runs module, to draw vectogram.
First below to type value difference based on finite-state automata state time (namely process JSON During title difference in sequence) JSON node is carried out calculation process enter with the process generating DSIL code Row explanation.
1) the type value of state of automata is data_source
As shown in Figure 5 a, when the title of node of JSON sequence namely type are data_source, base In finite-state automata, node being carried out calculation process, the process generating DSIL code can be by following Step realizes:
Step 301a, generates data source instantiation code based on JSON node.
Step 302a, reads the attribute information of JSON node.
Step 303a, generates attribute statement code and the code of setAttribute function call.
Step 304a, generates setOutpins function call code.
Step 305a, generates confirm code.
Step 306a, is created the code that step 303a to step 305a generates and (is stated that code is for sound Bright node object, other codes arrange node object for utilizing the information of three aspects of node) node The title of object is stacked.
Can generate an object when reality performs, above-mentioned code is stacked actual to be referred to the mark of node object Know (can be with the form of employing index) stacked, say, that above-mentioned stack can be considered as index stack, step 304a is to the DSIL code that the code that step 306a generates is corresponding JSON node.
2) the type value of state of automata is filter
As shown in Figure 5 b, as the entitled filter of the node of JSON sequence, based on finity state machine Machine carries out calculation process to node, and the process generating DSIL code can be realized by following steps:
Step 301b, carries out Pop operations, reads stack top element and is denoted as arg1.
Step 302b, generates based on arg1 and filters information instances code.
Step 303b, generates setInpins function call code based on arg1.
Step 304b, generates attribute statement code and the code of setAttribute function call.
Step 305b, generates setOutpins function call code.
Step 306b, generates confirm code.
Step 307b, the node object that the code that step 304b to step 306b generates is created (statement Code is used for declaration node object, and other codes arrange node pair for utilizing the information of three aspects of node As) title stacked.
Can generate an object when reality performs, above-mentioned code is stacked actual to be referred to enter the mark of object Stack, say, that above-mentioned stack can be considered as index stack, the code that step 304b to step 306b generates DSIL code for corresponding JSON node.
It is pointed out that step 301b to step 307b for join, union, data_source outside Node the most applicable.
3) the type value of state of automata is join
As shown in Figure 5 c, as the entitled join of the node of JSON sequence, based on finite-state automata Node carries out calculation process, and generating DSIL coding process can be realized by following steps:
Step 301c, carries out Pop operations, reads stack top element and is denoted as arg1.
Step 302c, carries out Pop operations, reads stack top element and is denoted as arg2.
Step 303c, generates common factor instantiation code based on arg1 and arg2.
Step 304c, generates setOutpins function call code based on arg1 and arg2.
Step 305c, generates attribute statement code and the code of setAttribute function call.
Step 306c, generates setOutpins function call code.
Step 307c, generates confirm code.
Step 308c, the node object that the code that step 304c to step 307c generates is created (statement Code is used for declaration node object, and other codes arrange node pair for utilizing the information of three aspects of node As) title stacked.
Code step 304c to step 307c generated can generate a node object when reality performs, Above-mentioned code is stacked actual to be referred to stacked for the mark of object, say, that above-mentioned stack can be considered as rope Drawing stack, step 304c to step 307c is the DSIL code of corresponding JSON node.
Above-mentioned 1)~3) for carrying out, for different JSON nodes, the process that processes to generate DSIL code, One JOSN sequence is often be made up of multiple JSON nodes, is therefore generating based on JSON sequence During DSIL code, need to process based on for each JSON node, and the DSIL that process is obtained Code is stacked, during until all of JSON node processing is complete in JSON sequence, by stacked confirm Code is submitted to as the DSIL code of JSON sequence, carries out a complete JSON sequence generating The process that realizes of the process of DSIL code as shown in Figure 6, comprises the following steps:
Step 401, obtains queue state information.
Here queue state information is the title of each JSON node in the JSON sequence that SOL is of equal value.
Step 402, it is judged that whether queue terminates, namely judge whether the JSON node in JSON sequence is located Reason terminates, if it is, perform step 421;Otherwise, step 403 is performed.
Step 403, reads in queue.
Be successively read the title of pending JSON node according to the sequencing of JSON sequence, JSON saves The class of the title of point and the state based on finite-state automata each JSON node carried out during calculation process Type is consistent.
Step 404, it is judged that when based on finite-state automata current JSON node being carried out calculation process The type of state.
Step 405, it is judged that whether type is data_source, if it is, perform step 406 to step 407, and proceed to step 417;If it is not, then proceed to step 408.
Step 406, generates data source instantiation code based on currently pending node.
Step 407, reads attribute (attribute) information of currently pending JSON node.
Step 408, it is judged that whether type is the type such as filter outside data_source, join, union, If it is, perform step 409 to step 411 and to proceed to step 417;Otherwise, step 412 is proceeded to.
Step 409, performs Pop operations, reads stack top element and is denoted as arg1.
Step 410, generates based on arg1 and filters information instances code.
Step 411, generates SetInpins function call code based on arg1.
Step 412, it is judged that whether pending node type is join, if join then performs step 413 To step 416 and proceed to step 417;Otherwise, step 402 is returned.
Step 413, performs Pop operations, reads stack top element and is denoted as arg1.
Step 414, performs Pop operations, reads stack top element and is denoted as arg2.
Step 415, generates common factor instantiation code based on arg1 and arg2.
Step 416, generates SetIpins function call code based on arg1 and arg2.
Step 417, generates attribute statement code and SetInpins function call code.
Step 418, generates SetOutpins function call code.
Step 419, generates confirm code.
Step 420, the node object that the code of generation is created (statement code is used for declaration node object, Other codes arrange node object for utilizing the information of three aspects of node) title stacked, and proceed to Step 402.
Step 421, code building based on stacked storage submits data namely DSIL code to.
Submit to before data, it is also possible to the code of stacked storage is checked, such as carry out syntax check with Debug.
Design to DSIL illustrates the most again.
DSIL essence belongs to internal DSL, is the API set with certain logic realized based on JavaScript Closing, therefore its grammer is completely the same with JavaScript.It comprises Wire, DataObject, Filter, Group, Limit, FieldExt, Order, FJoin and Union, altogether 9 kinds of object types.Wire is between node Connecting line type, a Wire object represents an effective connecting line.And remaining type is all node class Type, their instance object represents a graphical nodes consistent with its business.
Wire type has two kinds of methods of setAttribute and confirm;SetAttribute is mainly responsible for setting The base attribute of Wire, in addition, the attribute of Wire can also be entered by instantiation parameter when instantiation Row is arranged.Confirm method is that connecting line information is deposited by the request to service end initiation storage connecting line information Storage.
Other kinds of member method is all consistent, mainly have setAttribute, setInpins, setOutpins and Confirm method, the effect of setAttribute with confirm therein is consistent with the two method of Wire, SetInpins Yu setOutpins is used to the input arranging JSON node and output information.
As a example by data_source, designing a model as shown in Figure 7 of class.
Step 204, runs vectogram of equal value for DSIL code building SOL and obtains the vector of equal value with SQL Figure.
The basic language of DSIL is JavaScript, uses the OO programming mode of JavaScript, Rely on API and the Runtime class that DSIL Runtime Library provides, in short, DSIL is to operate in Load in the environment of DSIL Runtime Library, Runtime class figure such as Fig. 8 that DSIL relies on Shown in, wherein, BasePrototype is the base class of all node classes, confirm, setInpins of all node classes All being inherited from such with setOutpins method, this succession is the Prototype characteristic by JavaScript Realize.Two classes of Wire Yu Pin are completely self-contained classes, do not have any parent, and wherein Pin more meets Model class, is the parameter type of method setInpins and setOutpins.
The implementing of draw library that DSIL Runtime Library relies on is made by Raphael based on SVG Storehouse completes, and is the further encapsulation on the basis of the API of Raphael storehouse;Its pattern primitive drawn out Element is all independent SVG element, as it is shown in figure 9, step 204 can be realized by following steps:
Step 501, obtains drawing board DOM object.
Step 502, Raphael 2D creates painting canvas Paper.
Step 503, pulls control item to painting canvas.
Step 504, obtains SysWidgetID and obtains mouse coordinates.
Step 505, sends to CGI layer and creates space request.
Step 506, if be successfully obtained the NodeID of return, if it is, perform step 507;Otherwise End processes.
Step 507, arranges initial XY.
Step 508, draws Paper.xxx ().
It should be noted that Paper.xxx () method here is the canonical function in Raphael storehouse, step 508 are meant that, according to the concrete condition Selection and call corresponding graphic plotting function of present node.
Step 509, it may be judged whether complete, if completed, terminating to process, otherwise, utilizing XY_Compute_CurrentPosition function calculates present node coordinate.
The effect of XY_Compute_CurrentPosition function is to calculate present node coordinate.
The class figure of the content of above-mentioned process is illustrated in fig. 10 shown below, and wherein, Heightlight_area is the back of the body of node Scape, the colour switching when choosing, embody the effect highlighted;Prcess_fadebackArea is display node The progress bar of current progress status;State_fadebackArea is then node running status feedback;Text_area Display nodename;Del_btn is the button deleting present node;Help_btn is node help button; The individual icon of Icon_area display node, Conn_feellingArea is by the induction zone that node connects Territory;NodePane is the main body of node, and the element of above-mentioned several fields is all drawn on the basis of NodePane.
In the embodiment of the present invention, characterized the syntax tree structure of object code by sequence node, by node The resolving of sequence creates readable medium content (intermediate language code), in order to data craft participates in With interfere conversion process, follow-up can based on intermediate language code generate vectogram, reduce by object code to The complexity of vector graphics conversion.
One of ordinary skill in the art will appreciate that: all or part of step realizing said method embodiment can Completing with the hardware relevant by programmed instruction, aforesaid program can be stored in an embodied on computer readable and deposit In storage media, this program upon execution, performs to include the step of said method embodiment;And aforesaid storage Medium includes: movable storage device, random access memory (RAM, Random Access Memory), Read only memory (ROM, Read-Only Memory), magnetic disc or CD etc. are various can store program The medium of code.
Or, if the above-mentioned integrated unit of the present invention realizes also with the form of software function SQL processing means During as independent production marketing or use, it is also possible to be stored in a computer read/write memory medium. Based on such understanding, correlation technique is contributed by the technical scheme of the embodiment of the present invention the most in other words Part can embody with the form of software product, this computer software product be stored in one storage be situated between In matter, including some instructions with so that computer equipment (can be personal computer, server, Or the network equipment etc.) perform all or part of of method described in each embodiment of the present invention.And aforesaid deposit Storage media includes: movable storage device, RAM, ROM, magnetic disc or CD etc. are various can store program The medium of code.
The above, the only detailed description of the invention of the present invention, but protection scope of the present invention is not limited to This, any those familiar with the art, in the technical scope that the invention discloses, can readily occur in Change or replacement, all should contain within protection scope of the present invention.Therefore, protection scope of the present invention should It is as the criterion with described scope of the claims.

Claims (14)

1. a code process method, it is characterised in that described method includes:
Resolve object code and obtain the syntax tree that described object code is corresponding;
Resolve described syntax tree, determine the operation that described object code includes, and by described syntax tree is entered Row topological sorting, the sequence of operation that described object code is comprised;
Generate the operation node one to one included with described object code, and based on described object code institute Including the serializing result of operation, and the node generated generates sequence node, described sequence node institute Including the sequence serializing result that operate included with described object code of node corresponding;
Information based on each node in described sequence node is successively to each node in described sequence node Resolve, obtain the intermediate language code that described object code is corresponding.
2. the method for claim 1, it is characterised in that described generation includes with described object code Operation node one to one, including:
In terms of determining the title corresponding to the operation that described object code includes, attribute, output at least three Information;
Based on the information in terms of at least three corresponding to each described operation, it is right with each described operation to generate The node answered.
3. method as claimed in claim 2, it is characterised in that described based on each joint in sequence node Described each node is resolved by the information of point successively, obtains the intermediate language generation that described object code is corresponding Code, including:
Instantiation is at least generated based on the information in terms of at least three of the pending node in described sequence node Code, comprises the title of the node object corresponding with described pending node in described instantiation code;By institute The title of the node object set by instantiation code generated carries out stack-incoming operation.
4. method as claimed in claim 3, it is characterised in that pending based in described sequence node Information in terms of at least three of node generates instantiation code, corresponding to the instantiation code that will be generated The title of node object carries out stack-incoming operation, including:
When the entitled data source of the pending node in described sequence node, to described pending node Information in terms of at least three generates the instantiation code corresponding with described pending node;
The title of the node object of the described pending node of correspondence arranged by the instantiation code of generation enters Stack operation.
5. method as claimed in claim 3, it is characterised in that pending based in described sequence node Information in terms of at least three of node generates instantiation code, corresponding to the instantiation code that will be generated The title of node object carries out stack-incoming operation, including:
When the entitled non-data source of the pending node in described sequence node, non-common factor and unconsolidated time, The title of the node object corresponding to the processed node before described pending node carries out Pop operations, profit Correspondence is generated by the information in terms of at least three of the node object title popped and described pending node The instantiation code of described pending node and function call code;
The title of the node object of the described node of correspondence arranged by the instantiation code of generation carries out stacked behaviour Make.
6. method as claimed in claim 3, it is characterised in that pending based in described sequence node Information in terms of at least three of node generates instantiation code, corresponding to the instantiation code that will be generated The title of node object carries out stack-incoming operation, including:
When entitled common factor or the merging of described pending node, two before corresponding described pending node The title of the corresponding node object of individual processed node carries out twice Pop operations, utilizes two joints popped Point object oriented generates the instantiation code corresponding with described pending node, and the instantiation code that will obtain The title of the node object of the described node of correspondence arranged carries out stack-incoming operation.
7. the method as described in any one of claim 1 to 6, it is characterised in that described method also includes:
The application programming interfaces provided based on pre-loaded Runtime Library and operation class, perform described intermediate language Code, draws out and described node graph of a correspondence element;
The vectogram corresponding with described object code is built based on described graphic element.
8. a code processing apparatus, it is characterised in that described device includes:
First resolution unit, obtains, for resolving object code, the syntax tree that described object code is corresponding;
Second resolution unit, is used for resolving described syntax tree, determines the operation that described object code includes, and By described syntax tree is carried out topological sorting, the sequence of operation that described object code is comprised;
Sequence node signal generating unit, for generating the operation node one to one included with described object code, And serializing result of based on the operation included by described object code, and the node generated generates node Sequence, the serializing of the sequence of the node included by described sequence node operation included with described object code Result is corresponding;
Code generating unit, for information based on each node in described sequence node successively to described joint Each node in point sequence resolves, and obtains the intermediate language code that described object code is corresponding.
9. device as claimed in claim 8, it is characterised in that described sequence node signal generating unit, including:
Output subelement, for determining title corresponding to the operation that described object code includes, attribute, defeated Go out the information in terms of at least three;
Node generates subelement, is used for based on the information in terms of at least three corresponding to each described operation, Generate the node corresponding with each described operation.
10. device as claimed in claim 9, it is characterised in that
Described code generating unit is additionally operable at least three side based on the pending node in described sequence node The information in face at least generates instantiation code, comprises corresponding with described pending node in described instantiation code The title of node object;The title of the node object set by instantiation code that will be generated carries out stacked Operation.
11. devices as claimed in claim 10, it is characterised in that described code generating unit includes:
First code generation module, for when the entitled data source of the pending node in described sequence node Time, the information in terms of at least three of described pending node is generated the reality corresponding with described pending node Example code;
First stack operation module, for the described pending joint of correspondence arranged by the instantiation code of described generation The title of the node object of point carries out stack-incoming operation.
12. devices as claimed in claim 10, it is characterised in that described code generating unit includes:
Second stack operation module, for when the pending node in described sequence node entitled non-data source, Non-common factor and unconsolidated time, the name of the node object corresponding to the processed node before described pending node Claim to carry out Pop operations, wait to locate described in the correspondence that the instantiation code generated by second code generation module is arranged The title of the node object of reason node carries out stack-incoming operation;
Described second code generation module, for utilizing the node object title popped and described pending Information in terms of at least three of node generates the instantiation code corresponding with described pending node and function Call code.
13. devices as claimed in claim 10, it is characterised in that described code generating unit includes:
3rd stack operation module, for when described pending node entitled common factor or merge time, to described The title of the corresponding node object of two processed nodes before pending node carries out the behaviour that pops twice Make, the node of the described pending node of correspondence that the instantiation code obtained by third generation code generation module is arranged The title of object carries out stack-incoming operation;
Described third generation code generation module, treats with described for utilizing two the node object titles popped to generate Process the instantiation code that node is corresponding.
14. devices as described in any one of claim 7 to 13, it is characterised in that described device also includes:
Intermediate language code running unit, for the application programming interfaces provided based on pre-loaded Runtime Library With operation class, perform described intermediate language code, draw out and described node graph of a correspondence element;
The vectogram corresponding with described object code is built based on described graphic element.
CN201510256398.XA 2015-05-19 2015-05-19 Code processing method and device and computer readable medium Active CN106293653B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510256398.XA CN106293653B (en) 2015-05-19 2015-05-19 Code processing method and device and computer readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510256398.XA CN106293653B (en) 2015-05-19 2015-05-19 Code processing method and device and computer readable medium

Publications (2)

Publication Number Publication Date
CN106293653A true CN106293653A (en) 2017-01-04
CN106293653B CN106293653B (en) 2020-11-06

Family

ID=57632426

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510256398.XA Active CN106293653B (en) 2015-05-19 2015-05-19 Code processing method and device and computer readable medium

Country Status (1)

Country Link
CN (1) CN106293653B (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109062560A (en) * 2018-07-25 2018-12-21 北京百度网讯科技有限公司 Method and apparatus for generating information
CN109542926A (en) * 2018-11-06 2019-03-29 北京新唐思创教育科技有限公司 block processing method and computer storage medium
CN109582528A (en) * 2018-09-11 2019-04-05 阿里巴巴集团控股有限公司 State monitoring method, device, electronic equipment and computer readable storage medium
CN109815136A (en) * 2019-01-02 2019-05-28 腾讯科技(武汉)有限公司 A kind of data processing method and device of service operation
CN109933331A (en) * 2019-03-07 2019-06-25 杭州时趣信息技术有限公司 Data transfer device and associated component between a kind of client-server
CN109976713A (en) * 2017-12-28 2019-07-05 中国电信股份有限公司 Script processing method and device for Service Assembly
CN111240772A (en) * 2020-01-22 2020-06-05 腾讯科技(深圳)有限公司 Data processing method and device based on block chain and storage medium
CN111435372A (en) * 2019-01-11 2020-07-21 阿里巴巴集团控股有限公司 Data display method and system, data editing method and system, equipment and medium
CN113094026A (en) * 2021-04-09 2021-07-09 中国工商银行股份有限公司 Code processing method and device
CN113721896A (en) * 2021-06-25 2021-11-30 中债金科信息技术有限公司 Optimization processing method and device for financial fraud modeling language
CN113760271A (en) * 2020-08-17 2021-12-07 北京沃东天骏信息技术有限公司 Method and device for generating codes for describing pages
CN114706571A (en) * 2022-06-02 2022-07-05 杭州比智科技有限公司 DSL-based declarative visualization chart development method and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6594783B1 (en) * 1999-08-27 2003-07-15 Hewlett-Packard Development Company, L.P. Code verification by tree reconstruction
CN102203734A (en) * 2008-10-31 2011-09-28 三星电子株式会社 Conditional processing method and apparatus
CN102999323A (en) * 2011-09-16 2013-03-27 北京百度网讯科技有限公司 Method for generating object code, and data processing method and device
CN103645986A (en) * 2013-11-29 2014-03-19 北京广利核系统工程有限公司 Generation method and reconstruction method of visualization syntax tree of compiler
CN104199831A (en) * 2014-07-31 2014-12-10 深圳市腾讯计算机系统有限公司 Information processing method and device
US20150082276A1 (en) * 2013-09-18 2015-03-19 Vmware, Inc. Extensible code auto-fix framework based on xml query languages

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6594783B1 (en) * 1999-08-27 2003-07-15 Hewlett-Packard Development Company, L.P. Code verification by tree reconstruction
CN102203734A (en) * 2008-10-31 2011-09-28 三星电子株式会社 Conditional processing method and apparatus
CN102999323A (en) * 2011-09-16 2013-03-27 北京百度网讯科技有限公司 Method for generating object code, and data processing method and device
US20150082276A1 (en) * 2013-09-18 2015-03-19 Vmware, Inc. Extensible code auto-fix framework based on xml query languages
CN103645986A (en) * 2013-11-29 2014-03-19 北京广利核系统工程有限公司 Generation method and reconstruction method of visualization syntax tree of compiler
CN104199831A (en) * 2014-07-31 2014-12-10 深圳市腾讯计算机系统有限公司 Information processing method and device

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109976713A (en) * 2017-12-28 2019-07-05 中国电信股份有限公司 Script processing method and device for Service Assembly
CN109062560A (en) * 2018-07-25 2018-12-21 北京百度网讯科技有限公司 Method and apparatus for generating information
CN109582528A (en) * 2018-09-11 2019-04-05 阿里巴巴集团控股有限公司 State monitoring method, device, electronic equipment and computer readable storage medium
CN109582528B (en) * 2018-09-11 2023-02-28 创新先进技术有限公司 State monitoring method and device, electronic equipment and computer readable storage medium
CN109542926B (en) * 2018-11-06 2021-04-09 北京新唐思创教育科技有限公司 Block processing method and computer storage medium
CN109542926A (en) * 2018-11-06 2019-03-29 北京新唐思创教育科技有限公司 block processing method and computer storage medium
CN109815136B (en) * 2019-01-02 2022-03-29 腾讯科技(武汉)有限公司 Data processing method and device for service operation
CN109815136A (en) * 2019-01-02 2019-05-28 腾讯科技(武汉)有限公司 A kind of data processing method and device of service operation
CN111435372A (en) * 2019-01-11 2020-07-21 阿里巴巴集团控股有限公司 Data display method and system, data editing method and system, equipment and medium
CN109933331A (en) * 2019-03-07 2019-06-25 杭州时趣信息技术有限公司 Data transfer device and associated component between a kind of client-server
CN111240772A (en) * 2020-01-22 2020-06-05 腾讯科技(深圳)有限公司 Data processing method and device based on block chain and storage medium
CN113760271A (en) * 2020-08-17 2021-12-07 北京沃东天骏信息技术有限公司 Method and device for generating codes for describing pages
CN113094026A (en) * 2021-04-09 2021-07-09 中国工商银行股份有限公司 Code processing method and device
CN113094026B (en) * 2021-04-09 2024-02-06 中国工商银行股份有限公司 Code processing method and device
CN113721896A (en) * 2021-06-25 2021-11-30 中债金科信息技术有限公司 Optimization processing method and device for financial fraud modeling language
CN114706571A (en) * 2022-06-02 2022-07-05 杭州比智科技有限公司 DSL-based declarative visualization chart development method and system

Also Published As

Publication number Publication date
CN106293653B (en) 2020-11-06

Similar Documents

Publication Publication Date Title
CN106293653A (en) Code process method and device
CN107450902B (en) Method and system for visual modeling
CN112199086B (en) Automatic programming control system, method, device, electronic equipment and storage medium
CN113449858B (en) Neural network model processing method and related equipment
US20030200533A1 (en) Method and apparatus for creating software objects
CN106528613B (en) Intelligent answer method and device
CN106648662A (en) Engineering cost calculation description language BCL-based report generation device and generation method
Selonen et al. Transformations between UML diagrams
de Lara Jaramillo et al. Using meta-modelling and graph grammars to create modelling environments
Schreiber Pragmatics of the knowledge level
CN106096159B (en) A kind of implementation method of distributed system behavior simulation analysis system under cloud platform
Bruno et al. Petri-net based simulation of manufacturing cells
Poulakos et al. Towards an accessible interface for story world building
Hormann Programs for machine learning Part I
JPH04205423A (en) Program forming device
Bapst et al. Integrated multi-agent architecture for assisted document recognition
CN106155668A (en) A kind of graphic representation method of macrolanguage
Guenther Shiro-A language to represent alternatives
Kontogiannis Program representation and behavioural matching for localizing similar code fragments
Knirsch et al. A note on modeling agent systems by graph transformation
JPH09330212A (en) Programming language processing system
Gray et al. PARSE-EDIT: a parallel program design tool
Bayer et al. Development of a modular software framework for supporting architects during early design phases
Khokhlov et al. Meetci: A computational intelligence software design automation framework
Kobayashi et al. Object-oriented modeling of software patterns

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant