threewebcode / W3

Three Web World
Apache License 2.0
0 stars 0 forks source link

Solidity Compiler #11

Open threewebcode opened 1 year ago

threewebcode commented 1 year ago

Table of Content

  1. Scanner
  2. Parser
  3. Generator
threewebcode commented 1 year ago

The checker is created to do the view and pure function check. The view function and pure function are put together and use one class to do the work. The visit and endVisit methods of the class is used to analyze whether the syntax is enforced the syntax rule or not.

The function can be decorated with pure or view modifier and it indicates that the state variables can not be changed in these functions.

In the function body, there are various statements and they have different types. For example, the variable may be defined and operated. The member of type may be accessed. Every scenarios are analyzed. The foundation of analysis that the immutable cases are known. The mutable attribute is labeled when it violates the immunity set.

threewebcode commented 1 year ago

There is a directive named using namespace in C++ language. It means that all code items in that namespace can be used directly. The namespace is a concept and method of organizing codes in C++ language. It stands for one type of code units.

The function type has input parameters and return parameters. Both of these parameters have their types. The function is declared to get the function identifier from the function declaration. The low-level code formats can be generated by leveraging the contract definition data structure. The new names are in the yul expression and representation. The queue is used for function processor. The local variable, state variable, immutable variable, function can be placed into queue.

threewebcode commented 1 year ago

The TypeChecker is used to perform the type validation. The type check belongs to the steps in the front-end of language compiler. Each token has its name and attributes. There are private section and public section in the body of class declaration. In the function declaration of class, the modifier is behind each subject. This is in reverse order of normal sentence.

threewebcode commented 1 year ago

There are some variables stored and available in the global context. The function call can be depicted and represented in the graph manner.

The interface directory encompasses all of exported functionalities in that library. That is the exported parts in that library. The namespace can be nested and formed in the chain manner. The variable is decorated by const keyword. The types.h file declares all types used in the abstract syntax tree. The AST.h file defines the data structure of abstract syntax tree for the whole language.

The contract definition can be converted to JSON format. If the variable definition and its slot are known, its storage layout can be calculated. The compiler is responsible for accepting json input and producing json output.

The documentation in the solidity source file is natural language format. NatSpec is the specification format of natural language in the solidity file.

threewebcode commented 1 year ago

The gas should be estimated when the function is provided and its assembly codes are generated. The file path and content are managed by mapping type. The main task of compiler is to transform the source code into byte code. Type is the base type and array, integer, mapping, struct type are its derived types. The encode is finished by a function and purposed to transform the value form. Some utilities are created to help the compilation process. Some are assert functions. Some are related to encoding and decoding. The type conversion can be accomplished by compiler utilities. The source type and target type are used to determine the transformation rule. The variables and states can be moved into different storage location by the help of compiler utility.

threewebcode commented 1 year ago

The begin and end is the index that stands for location in the whole content. The special characters are used to divide the whole content and the complete content is parsed by the function. The class is inside of the namespace scope. The parser is defined and created by a class. The parser can parse the line of content by token tag. The characters of code content are divided by the tag. The source unit is represented or converted into a node. The node is managed by one data structure. The data types are declared to stand for the elements in the source codes. If the character unit is not divided into different types, there is no difference between them because all of them are characters. The location of data is enumerated into three values: memory, calldata and storage. When the type is confirmed to be finalized, the data size is determined. The category of type is typed as enumeration. The common properties and behaviors are wrapped as a base class. The specific types are to extend the base type and support its specific facets.

threewebcode commented 1 year ago

The node is delegated to the class. The node represents the code unit in the source code. The node in the tree can be visited and analyzed for further steps. The node visitors are defined in the formal folder. The array slice can be predicted from the source pointer. The rules are extracted from the syntax. The rules are used to compute the array slice. Bounded model checker is performed on the statement by the node visitor. The node is used and passed as input parameter. Its structure is analyzed and checked against predefined rules. Constrained Horn Clauses are logic checker which can be performed on the statement. The statement is verified by the formal grammar. The context is used and created in the statement encoding cases. The data type accessor is formatted and converted into data access format. The invariants are collected from the expression.The methods of model checker are executed to do various validation and verification. The models are managed and arranged by the engine and assigned to do the check work. The relationship between the engine and models are associated by model checker setting. The statement and expression are predicted to comply with the constraints and logic rules. The blockchain context can hold the state of blockchain and use them in the global context.