Commit 2ce88624 authored by yann300's avatar yann300

add isYulAstNode

parent 94833230
...@@ -233,7 +233,7 @@ class DebuggerUI { ...@@ -233,7 +233,7 @@ class DebuggerUI {
<p class="mt-2 ${css.debuggerLabel}">Debugger Configuration</p> <p class="mt-2 ${css.debuggerLabel}">Debugger Configuration</p>
<div class="mt-2 ${css.debuggerConfig} custom-control custom-checkbox"> <div class="mt-2 ${css.debuggerConfig} custom-control custom-checkbox">
<input class="custom-control-input" id="debugGeneratedSourcesInput" onchange=${(event) => { this.opt.debugWithGeneratedSources = event.target.checked }} type="checkbox" title="Debug with generated sources"> <input class="custom-control-input" id="debugGeneratedSourcesInput" onchange=${(event) => { this.opt.debugWithGeneratedSources = event.target.checked }} type="checkbox" title="Debug with generated sources">
<label data-id="debugGeneratedSourcesLabel" class="form-check-label custom-control-label" for="debugGeneratedSourcesInput">Debug Generated sources if available (>= Solidity 0.7.2)</label> <label data-id="debugGeneratedSourcesLabel" class="form-check-label custom-control-label" for="debugGeneratedSourcesInput">Debug Generated sources if available (from Solidity 0.7.2)</label>
</div> </div>
</div> </div>
${this.txBrowser.render()} ${this.txBrowser.render()}
......
...@@ -12,7 +12,15 @@ const isObject = function(obj: any): boolean { ...@@ -12,7 +12,15 @@ const isObject = function(obj: any): boolean {
export function isAstNode(node: Record<string, unknown>): boolean { export function isAstNode(node: Record<string, unknown>): boolean {
return ( return (
isObject(node) && isObject(node) &&
// 'id' in node && 'id' in node &&
'nodeType' in node &&
'src' in node
)
}
export function isYulAstNode(node: Record<string, unknown>): boolean {
return (
isObject(node) &&
'nodeType' in node && 'nodeType' in node &&
'src' in node 'src' in node
) )
...@@ -200,7 +208,7 @@ export class AstWalker extends EventEmitter { ...@@ -200,7 +208,7 @@ export class AstWalker extends EventEmitter {
} }
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
walkFullInternal(ast: AstNode, callback: Function) { walkFullInternal(ast: AstNode, callback: Function) {
if (isAstNode(ast)) { if (isAstNode(ast) || isYulAstNode(ast)) {
// console.log(`XXX id ${ast.id}, nodeType: ${ast.nodeType}, src: ${ast.src}`); // console.log(`XXX id ${ast.id}, nodeType: ${ast.nodeType}, src: ${ast.src}`);
callback(ast); callback(ast);
for (const k of Object.keys(ast)) { for (const k of Object.keys(ast)) {
...@@ -223,7 +231,7 @@ export class AstWalker extends EventEmitter { ...@@ -223,7 +231,7 @@ export class AstWalker extends EventEmitter {
// Normalizes parameter callback and calls walkFullInternal // Normalizes parameter callback and calls walkFullInternal
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
walkFull(ast: AstNode, callback: any) { walkFull(ast: AstNode, callback: any) {
if (isAstNode(ast)) return this.walkFullInternal(ast, callback); if (isAstNode(ast) || isYulAstNode(ast)) return this.walkFullInternal(ast, callback);
} }
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
......
import { isAstNode, AstWalker } from './astWalker'; import { isAstNode, isYulAstNode, AstWalker } from './astWalker';
import { AstNode, LineColPosition, LineColRange, Location } from "./types"; import { AstNode, LineColPosition, LineColRange, Location } from "./types";
import { util } from "@remix-project/remix-lib"; import { util } from "@remix-project/remix-lib";
...@@ -31,7 +31,7 @@ export function lineColPositionFromOffset(offset: number, lineBreaks: Array<numb ...@@ -31,7 +31,7 @@ export function lineColPositionFromOffset(offset: number, lineBreaks: Array<numb
* @param astNode The object to convert. * @param astNode The object to convert.
*/ */
export function sourceLocationFromAstNode(astNode: AstNode): Location | null { export function sourceLocationFromAstNode(astNode: AstNode): Location | null {
if (isAstNode(astNode) && astNode.src) { if (isAstNode(astNode) && isYulAstNode(astNode) && astNode.src) {
return sourceLocationFromSrc(astNode.src) return sourceLocationFromSrc(astNode.src)
} }
return null; return null;
......
import tape from "tape"; import tape from "tape";
import { import {
AstNode, isAstNode, AstNode, isAstNode ,
LineColPosition, lineColPositionFromOffset, LineColPosition, lineColPositionFromOffset,
LineColRange, Location, LineColRange, Location,
SourceMappings, sourceLocationFromAstNode, SourceMappings, sourceLocationFromAstNode,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment