add isYulAstNode

pull/5370/head
yann300 4 years ago
parent 80f617e20e
commit da90b2df38
  1. 2
      apps/remix-ide/src/app/tabs/debugger/debuggerUI.js
  2. 14
      libs/remix-astwalker/src/astWalker.ts
  3. 4
      libs/remix-astwalker/src/sourceMappings.ts
  4. 2
      libs/remix-astwalker/tests/sourceMappings.ts

@ -233,7 +233,7 @@ class DebuggerUI {
<p class="mt-2 ${css.debuggerLabel}">Debugger Configuration</p>
<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">
<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>
${this.txBrowser.render()}

@ -12,7 +12,15 @@ const isObject = function(obj: any): boolean {
export function isAstNode(node: Record<string, unknown>): boolean {
return (
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 &&
'src' in node
)
@ -200,7 +208,7 @@ export class AstWalker extends EventEmitter {
}
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
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}`);
callback(ast);
for (const k of Object.keys(ast)) {
@ -223,7 +231,7 @@ export class AstWalker extends EventEmitter {
// Normalizes parameter callback and calls walkFullInternal
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
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

@ -1,4 +1,4 @@
import { isAstNode, AstWalker } from './astWalker';
import { isAstNode, isYulAstNode, AstWalker } from './astWalker';
import { AstNode, LineColPosition, LineColRange, Location } from "./types";
import { util } from "@remix-project/remix-lib";
@ -31,7 +31,7 @@ export function lineColPositionFromOffset(offset: number, lineBreaks: Array<numb
* @param astNode The object to convert.
*/
export function sourceLocationFromAstNode(astNode: AstNode): Location | null {
if (isAstNode(astNode) && astNode.src) {
if (isAstNode(astNode) && isYulAstNode(astNode) && astNode.src) {
return sourceLocationFromSrc(astNode.src)
}
return null;

@ -1,6 +1,6 @@
import tape from "tape";
import {
AstNode, isAstNode,
AstNode, isAstNode ,
LineColPosition, lineColPositionFromOffset,
LineColRange, Location,
SourceMappings, sourceLocationFromAstNode,

Loading…
Cancel
Save