CN110262804A - JavaScript based on program slice continues transmitting style method for transformation - Google Patents

JavaScript based on program slice continues transmitting style method for transformation Download PDF

Info

Publication number
CN110262804A
CN110262804A CN201910510690.8A CN201910510690A CN110262804A CN 110262804 A CN110262804 A CN 110262804A CN 201910510690 A CN201910510690 A CN 201910510690A CN 110262804 A CN110262804 A CN 110262804A
Authority
CN
China
Prior art keywords
program
style
slice
conversion
node
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.)
Pending
Application number
CN201910510690.8A
Other languages
Chinese (zh)
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.)
Nanjing Post and Telecommunication University
Nanjing University of Posts and Telecommunications
Original Assignee
Nanjing Post and Telecommunication University
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 Nanjing Post and Telecommunication University filed Critical Nanjing Post and Telecommunication University
Priority to CN201910510690.8A priority Critical patent/CN110262804A/en
Publication of CN110262804A publication Critical patent/CN110262804A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/311Functional or applicative languages; Rewrite languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/51Source to source
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Library & Information Science (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention discloses a kind of, and the JavaScript based on program slice continues transmitting style (Continuation-passing style CPS) method for transformation, including the synchronization codes step according to direct style, complete program slice step, execute conversion process step, Real time displaying conversion results step.Write code in a synchronous manner first, with this as input, the calling node in program is marked using additional parameter, then according to the callback variable provided just now to progress program forward slicing at the point, data dependence relation is found according to forward slicing result figure, it is completed to continue the automatic conversion for transmitting style according to dependence, it is converted manually without programmer, code after transformed maintains the structure and name variable of original program as far as possible, the readability for increasing code facilitates the later period to carry out test maintaining.Finally be laid out at the end Web using Bootstrap technology, will be transformed after code be shown on the page.

Description

JavaScript based on program slice continues transmitting style method for transformation
Technical field
The present invention relates to continue transmitting style and program slice field in functional expression programming, and in particular to one kind is based on program The JavaScript of slice continues transmitting style method for transformation.
Background technique
The history of functional expression programming is very long, this 2 years burning hot with React, the concept of functional expression programming It comes into vogue.Although popular language (such as Java, C++) does not support functional expression to program instantly, functional expression is compiled The concept of journey has played very big effect in a program, solves many problems, transmits style than continuity as mentioned herein (CPS).Different with Lisp, Haskell, JavaScript is not pure Functional Programming, but JavaScript belongs to one kind Multilingual normal form, that is to say, that function programming technology can be applied in JavaScript.
In web application of today, omnipresent to the Asynchronous Request of remote service in JavaScript, this non-resistance The continuity of plug task is expressed as a call back function, then using the call by result of the request function.It is this in continuous function The coding style for capturing the rest part calculated is known as continuing transmitting style.The code for continuing transmitting style also has disadvantage a: side Face, different from our common direct-type coding styles, the code for continuing transmitting style is more obscure, is unfavorable for normally reading It writes.On the other hand, it is more time-consuming to be converted to continuity transmitting style manually by programmer for direct style code, therefore is bred The tool of many CPS conversions, but the code quality of different conversion instrumental translations is also different, there are many problems.For example, this A little frames generally use conservative method, wherein each function call is converted to CPS, will lead to script two so mutually solely The vertical calling being independent of each other, can nest together after conversion, can not correctly run so as to cause program.Set forth herein a kind of bases In the CPS method for transformation of program slice, can effectively solve the above problems.
Mark Weiser [1] gave the concept of program slice in 1979 first: some output and journey in program The division statement of sequence has relationship, deletes other sentences or control predicate and exports no any influence to this.Program slice is The subset of program, having on the value calculated in specific position directly or indirectly influences.Program slice is typically employed in code Debugging, software maintenance etc..Program slice can substantially be divided into forward slicing and backward slicing.In brief, slice is searched backward The sentence of slice standard is influenced, and is sliced all sentences searched by slice criteria influences forward.The forward slicing of program is can The sentence set that can be influenced by variate-value at the program point.Forward slicing can generate control dependence at corresponding program point and Data dependence relation.Wherein data dependence discloses the inner link between sentence in terms of existing data flow.
The information disclosed in the background technology section is intended only to increase the understanding to general background of the invention, without answering When being considered as recognizing or imply that the information constitutes the prior art already known to those of ordinary skill in the art in any form.
Summary of the invention
The purpose of the present invention is to provide a kind of, and the JavaScript based on program slice continues transmitting style method for transformation, Mainly using data dependence relation in program slice to program carry out continue transmitting style conversion, with this come improve program can The property read, maintainability and responsiveness.To overcome above-mentioned defect in the prior art.
To achieve the above object, the present invention provides a kind of, and the JavaScript based on program slice continues transmitting style turn Change method, comprising the following steps:
Step 1: according to the synchronization codes step of direct style: writing pre-inversion first with synchronous mode (direct style) Program indicates the call node (calling node) for needing to convert in program using additional parameter callback.With synchronous side Formula writes code and simplifies programmer's writing difficulty, in order to which subsequent CPS conversion is laid the groundwork;
Step 2: completing program slice step: corresponding forward direction being made to the point of invocation marked with callback using slice tool Slice generates the corresponding sentence set influenced by variate-value at the program point.
Step 3: execute conversion process step: the sentence set of the program forward slicing in step 2 includes the control at this point Dependence processed and data dependence relation carry out CPS conversion using wherein data dependence relation at this point, i.e., will call node It is converted into the calling with initial parameter and a readjustment parameter, wherein readjustment parameter return one is given with resultful function and adjusted User.
Step 4: Real time displaying conversion results step: an interface is built using Bootstrap technology at the end Web, by journey Result after sequence code is transformed is shown in webpage.
The technical solution that the present invention further limits are as follows:
Preferably, in above-mentioned technical proposal, according to the synchronization codes specific steps of direct style in the step 1 are as follows:
Step 1.1: writing the program code for needing to convert according to general direct style, add an additional parameter callback The calling node for needing to convert in label program;
Step 1.2: and then these calling nodes are put into one group of set { c1, c2, c3..... }, spare two parts.
Preferably, in above-mentioned technical proposal, program slice specific steps are completed in the step 2 are as follows:
Step 2.1: the set { c1, c2, c3..... } in traversal step 1.2, using slice tool to wherein call node c1 into Row forward slicing obtains the set for controlling dependence and data dependence relation at the node accordingly;
Step 2.2: the control dependence in step 2.1 at calling node c1 is removed from set, leave behind data according to The relationship of relying;
Step 2.3: c1 being deleted from set, iterative step 2.1 and step 2.2, until collection is combined into sky.
Preferably, in above-mentioned technical proposal, conversion process specific steps are executed in the step 3 are as follows:
Step 3.1: the set { c1, c2, c3..... } in traversal step 1.2 filters out journey according to the dependence in step 2 Conversion or incoherent sentence are not needed in sequence;
Step 3.2: node c1 will be called to be converted into the calling with initial parameter and a readjustment parameter, that is, carried out corresponding CPS conversion;
Step 3.3: c1 being deleted from set, continues cycling through traversal set, until collection is combined into sky, until being fully completed conversion.
Preferably, in above-mentioned technical proposal, Real time displaying conversion results specific steps in the step 4 are as follows:
Step 4.1: an interface is built using Bootstrap technology in WEB terminal, by result of the program code after transformed in net It is shown in page.
Compared with prior art, the invention has the following beneficial effects: (1) obtains program point using program slicing technique Data dependence relation carries out CPS conversion according to data dependence relation, avoids mutually independent calling function originally and is converting It nests together later, improves the correctness of conversion.
(2) code after transformed remains original name variable and program structure as far as possible, improves code It is maintainable and readable, facilitate programmer is subsequent to test and debug.
Detailed description of the invention:
Fig. 1 is the overall flow figure that JavaScript continues transmitting style conversion process;
Fig. 1 .1 is the code schematic diagram of addition label;
Fig. 2 is the forward slicing flow chart for obtaining program point.
Specific embodiment:
Specific embodiments of the present invention will be described in detail below, it is to be understood that protection scope of the present invention is not had The limitation of body embodiment.
Unless otherwise explicitly stated, otherwise in entire disclosure and claims, term " includes " or its change Changing such as "comprising" or " including " etc. will be understood to comprise stated element or component, and not exclude other members Part or other component parts.
The present invention relates to continue transmitting style and program slice field in functional expression programming, and in particular to one kind is based on program The JavaScript of slice continues transmitting style method for transformation.Mainly using data dependence relation in program slice to program into Row continues the conversion of transmitting style, improves programmed readability, maintainability and responsiveness with this.Overview flow chart such as Fig. 1 institute Show, the specific steps are as follows:
Step 1: according to the synchronization codes of direct style:
Step 1.1: writing the program code for needing to convert according to general direct style, add an additional parameter callback The calling node for needing to convert in label program, by taking the program of file is written in an Asynchronous Request city temperature again as an example, addition Shown in the following Fig. 1 .1 of the code of label;
Step 1.2: and then three calling nodes in the program are put into one group of set { c1, c2, c3 }, spare two parts are respectively Set 1 and set 2.
Step 2: complete weather request program slice step:
Step 2.1: the set 1 { c1, c2, c3 } in traversal step 1.2, using slice tool to wherein first calling node c1 Forward slicing is carried out, can be easy to obtain the collection for controlling dependence and data dependence relation at the node accordingly in this way It closes;
Step 2.2: by the control dependence in step 2.1 at calling node c1 from set 1 in delete, leave behind data according to The relationship of relying, data dependence are the key that this CPS conversion places;
Step 2.3: c1 being deleted from set 1, circulation step 2.1 and step 2.2, until it is empty for gathering 1.
Step 3: execute conversion process step:
Step 3.1: the set 2 { c1, c2, c3 } in traversal step 1.2 filters out request day according to the dependence in step 2 Conversion or incoherent sentence are not needed in the program of gas;
Step 3.2: by call node c1 be converted into initial parameter and one readjustment parameter (callback) calling, i.e., into The corresponding CPS conversion of row;
Step 3.3: c1 being deleted from set 2, continues cycling through traversal set 2, until gathering 2 for sky, is fully completed and is converted into Only.
Step 4: Real time displaying conversion results step:
Step 4.1: designing a web interface for showing using Bootstrap framework technology, the interface left side can input Source code, the right show the code after conversion.
The aforementioned description to specific exemplary embodiment of the invention is in order to illustrate and illustration purpose.These descriptions It is not wishing to limit the invention to disclosed precise forms, and it will be apparent that according to the above instruction, can much be changed And variation.The purpose of selecting and describing the exemplary embodiment is that explaining specific principle of the invention and its actually answering With so that those skilled in the art can be realized and utilize a variety of different example embodiments of the invention and each Kind different selection and change.The scope of the present invention is intended to be limited by claims and its equivalents.

Claims (4)

1. a kind of JavaScript based on program slice continues transmitting style method for transformation, it is characterised in that: including following step It is rapid:
Step 1: according to the synchronization codes step of direct style: writing pre-inversion journey first with the synchronous mode of direct style Sequence indicates the call node for needing to convert in program using additional parameter callback;
Step 2: completing program slice step: corresponding forward direction being made to the call point marked with callback using slice tool Slice generates the corresponding sentence set influenced by variate-value at the program point;
Step 3: execute conversion process step: the sentence set of the program forward slicing in step 2 include this point at control according to The relationship of relying and data dependence relation, carry out CPS conversion using wherein data dependence relation at this point, i.e., will call Node To adjust back the calling of parameter with initial parameter and one, wherein adjusting back parameter returns to one with resultful function to calling Person;
Step 4: Real time displaying conversion results step: an interface is built using Bootstrap technology in WEB terminal, by program generation Result after code is transformed is shown in webpage.
2. the Javascript based on program slice continues transmitting style method for transformation as described in claim 1, feature exists In: according to the synchronization codes specific steps of direct style in the step 1 are as follows:
Step 1.1: writing the program code for needing to convert according to general direct style, add an additional parameter callback The calling node for needing to convert in label program;
Step 1.2: and then these calling nodes are put into one group of set { c1, c2, c3..... }, spare two parts.
3. the Javascript based on program slice continues transmitting style method for transformation as described in claim 1, feature exists In: program slice specific steps are completed in the step 2 are as follows:
Step 2.1: the set { c1, c2, c3..... } in traversal step 1.2, using slice tool to wherein call node c1 into Row forward slicing obtains the set for controlling dependence and data dependence relation at the node accordingly;
Step 2.2: the control dependence in step 2.1 at calling node c1 is removed from set, leave behind data according to The relationship of relying;
Step 2.3: c1 being deleted from set, iterative step 2.1 and step 2.2, until collection is combined into sky.
4. the Javascript based on program slice continues transmitting style method for transformation as described in claim 1, feature exists In: conversion process specific steps are executed in the step 3 are as follows:
Step 3.1: the set { c1, c2, c3..... } in traversal step 1.2 filters out journey according to the dependence in step 2 Conversion or incoherent sentence are not needed in sequence;
Step 3.2: node c1 will be called to be converted into the calling with initial parameter and a readjustment parameter, that is, carried out corresponding CPS conversion;
Step 3.3: c1 being deleted from set, continues cycling through traversal set, until collection is combined into sky, until being fully completed conversion.
CN201910510690.8A 2019-06-13 2019-06-13 JavaScript based on program slice continues transmitting style method for transformation Pending CN110262804A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910510690.8A CN110262804A (en) 2019-06-13 2019-06-13 JavaScript based on program slice continues transmitting style method for transformation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910510690.8A CN110262804A (en) 2019-06-13 2019-06-13 JavaScript based on program slice continues transmitting style method for transformation

Publications (1)

Publication Number Publication Date
CN110262804A true CN110262804A (en) 2019-09-20

Family

ID=67918147

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910510690.8A Pending CN110262804A (en) 2019-06-13 2019-06-13 JavaScript based on program slice continues transmitting style method for transformation

Country Status (1)

Country Link
CN (1) CN110262804A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030145314A1 (en) * 2002-01-31 2003-07-31 Khoa Nguyen Method of efficient dynamic data cache prefetch insertion
CN101873323A (en) * 2010-06-21 2010-10-27 南京邮电大学 Web service platform based on program slicing technique
CN103970845A (en) * 2014-04-28 2014-08-06 南京邮电大学 Webpage filtering method based on program slicing technology
CN104572476A (en) * 2015-01-30 2015-04-29 南京邮电大学 Software safety testing method based on program slicing
CN107622015A (en) * 2017-09-25 2018-01-23 北京因特睿软件有限公司 A kind of dataflow analysis method, device, equipment and medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030145314A1 (en) * 2002-01-31 2003-07-31 Khoa Nguyen Method of efficient dynamic data cache prefetch insertion
CN101873323A (en) * 2010-06-21 2010-10-27 南京邮电大学 Web service platform based on program slicing technique
CN103970845A (en) * 2014-04-28 2014-08-06 南京邮电大学 Webpage filtering method based on program slicing technology
CN104572476A (en) * 2015-01-30 2015-04-29 南京邮电大学 Software safety testing method based on program slicing
CN107622015A (en) * 2017-09-25 2018-01-23 北京因特睿软件有限公司 A kind of dataflow analysis method, device, equipment and medium

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
ERIC THIVIERGE: "Efficient compilation of tail calls and continuations to JavaScript", 《SCHEME "12: PROCEEDINGS OF THE 2012 ANNUAL WORKSHOP ON SCHEME AND FUNCTIONAL PROGRAMMING》 *
LAURE PHILIPS: "Dependence-Driven Delimited CPS Transformation for JavaScript", 《GPCE 2016: PROCEEDINGS OF THE 2016 ACM SIGPLAN INTERNATIONAL CONFERENCE ON GENERATIVE PROGRAMMING: CONCEPTS AND EXPERIENCES》 *
佚名: "在线代码格式化", 《HTTPS://WEB.ARCHIVE.ORG/WEB/20180104114132/HTTP://TOOL.OSCHINA.NET/CODEFORMAT/JS/》 *
喻钢: "用异常处理机制获取程序继续", 《北京工业大学学报》 *

Similar Documents

Publication Publication Date Title
CN108121542B (en) MyBatis-based SQL statement configuration method and system
CN102063324B (en) Method and system for implementing automatic programming
CN108399130A (en) Method, device and equipment for automatically generating test case and readable storage medium
CN106201642B (en) A kind of template automation compiling loading method and system based on NODEJS
CN101464799A (en) MPI parallel programming system based on visual modeling and automatic skeleton code generation method
CN106372032B (en) A kind of FPGA dynamic reconfiguration methods
JPS6375835A (en) Apparatus for generating intended code, program, list and design document
CN104407863A (en) Abstract control model programming device and method
US20080244541A1 (en) Code translator and method of automatically translating modeling language code to hardware language code
CN103186467B (en) Data correctness verification method and device
CN103605556A (en) Virtual test subject integrally-constructing system and method
CN109840083A (en) Web pages component template construction method, device, computer equipment and storage medium
WO2024045436A1 (en) Graphical high-level synthesis circuit performance analysis method, system, apparatus, and medium
CN111930373A (en) Method and device for efficiently creating quantitative transaction strategy based on flow chart
CN106598843B (en) A kind of software log behavior automatic identifying method based on program analysis
CN110262804A (en) JavaScript based on program slice continues transmitting style method for transformation
CN105988792A (en) Nuclear power software development automation system and method
CN114610301A (en) Front-end code generation method and device, electronic equipment and storage medium
CN104731705B (en) A kind of dirty data propagation path based on complex network finds method
CN109828753A (en) A kind of behavior drives the visualizing editing method and its device of drama document in exploitation
CN111124414A (en) Abstract syntax tree word-taking method based on operation link
CN109615241A (en) A kind of software Bug allocating method based on convolution sum Recognition with Recurrent Neural Network
CN111708572B (en) Automatic control flow chart generation method based on Clang program structure
Zhang et al. A dynamic form rendering method for web multi-front framework
JP2007510196A (en) Dialogue control for dialogue system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190920