Comparing version 0.10.0-next.6 to 0.10.0
@@ -7,3 +7,3 @@ import { Type } from '@cashscript/utils'; | ||
import { SymbolTable, Symbol } from './SymbolTable.js'; | ||
export declare type Ast = SourceFileNode; | ||
export type Ast = SourceFileNode; | ||
export declare abstract class Node { | ||
@@ -196,2 +196,2 @@ location: Location; | ||
} | ||
export declare type ConsoleParameterNode = LiteralNode | IdentifierNode; | ||
export type ConsoleParameterNode = LiteralNode | IdentifierNode; |
@@ -9,3 +9,3 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
*/ | ||
export default class ThrowingErrorListener extends ErrorListener { | ||
class ThrowingErrorListener extends ErrorListener { | ||
syntaxError(recognizer, offendingSymbol, line, charPositionInLine, message, e) { | ||
@@ -17,2 +17,3 @@ const capitalisedMessage = message.charAt(0).toUpperCase() + message.slice(1); | ||
ThrowingErrorListener.INSTANCE = new ThrowingErrorListener(); | ||
export default ThrowingErrorListener; | ||
//# sourceMappingURL=ThrowingErrorListener.js.map |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { Artifact } from '@cashscript/utils'; | ||
@@ -3,0 +2,0 @@ import { PathLike } from 'fs'; |
@@ -48,5 +48,5 @@ import { Type } from '@cashscript/utils'; | ||
export declare class TypeError extends CashScriptError { | ||
actual?: Type | Type[] | undefined; | ||
expected?: Type | Type[] | undefined; | ||
constructor(node: Node, actual?: Type | Type[] | undefined, expected?: Type | Type[] | undefined, message?: string); | ||
actual?: (Type | Type[]) | undefined; | ||
expected?: (Type | Type[]) | undefined; | ||
constructor(node: Node, actual?: (Type | Type[]) | undefined, expected?: (Type | Type[]) | undefined, message?: string); | ||
} | ||
@@ -53,0 +53,0 @@ export declare class InvalidParameterTypeError extends TypeError { |
@@ -76,3 +76,3 @@ import { hexToBin } from '@bitauth/libauth'; | ||
node.functions = node.functions.map((f, i) => { | ||
const locationData = { location: f.location }; | ||
const locationData = { location: f.location, positionHint: PositionHint.START }; | ||
const stackCopy = [...this.stack]; | ||
@@ -88,4 +88,3 @@ const selectorIndex = this.getStackIndex('$$'); | ||
} | ||
// All functions are if-else statements, except the final one which is | ||
// enforced with NUMEQUALVERIFY | ||
// All functions are if-else statements, except the final one which is enforced with NUMEQUALVERIFY | ||
this.emit(encodeInt(BigInt(i)), locationData); | ||
@@ -184,3 +183,3 @@ this.emit(Op.OP_NUMEQUAL, locationData); | ||
emitReplace(index, node) { | ||
const locationData = { location: node.location }; | ||
const locationData = { location: node.location, positionHint: PositionHint.END }; | ||
this.emit(encodeInt(BigInt(index)), locationData); | ||
@@ -232,4 +231,4 @@ this.emit(Op.OP_ROLL, locationData); | ||
const symbol = parameter.definition; | ||
// If the variable is not on the stack, then we add the final stack usage to the console log | ||
const stackIndex = this.getStackIndex(parameter.name, true); | ||
// If the variable is not on the stack, then we add the final stack usage to the console log | ||
if (stackIndex === -1) { | ||
@@ -254,3 +253,3 @@ if (!this.finalStackUsage[parameter.name]) { | ||
this.scopeDepth += 1; | ||
this.emit(Op.OP_IF, { location: node.ifBlock.location }); | ||
this.emit(Op.OP_IF, { location: node.ifBlock.location, positionHint: PositionHint.START }); | ||
let stackDepth = this.stack.length; | ||
@@ -260,3 +259,3 @@ node.ifBlock = this.visit(node.ifBlock); | ||
if (node.elseBlock) { | ||
this.emit(Op.OP_ELSE, { location: node.elseBlock.location }); | ||
this.emit(Op.OP_ELSE, { location: node.elseBlock.location, positionHint: PositionHint.START }); | ||
stackDepth = this.stack.length; | ||
@@ -286,3 +285,3 @@ node.elseBlock = this.visit(node.elseBlock); | ||
node.size = this.visit(node.size); | ||
this.emit(Op.OP_NUM2BIN, { location: node.location }); | ||
this.emit(Op.OP_NUM2BIN, { location: node.location, positionHint: PositionHint.END }); | ||
this.popFromStack(); | ||
@@ -306,3 +305,3 @@ } | ||
visitMultiSig(node) { | ||
this.emit(encodeBool(false), { location: node.location }); | ||
this.emit(encodeBool(false), { location: node.location, positionHint: PositionHint.START }); | ||
this.pushToStack('(value)'); | ||
@@ -318,13 +317,12 @@ node.parameters = this.visitList(node.parameters); | ||
visitInstantiation(node) { | ||
const nodeLocationData = { location: node.location }; | ||
if (node.identifier.name === Class.LOCKING_BYTECODE_P2PKH) { | ||
// OP_DUP OP_HASH160 OP_PUSH<20> | ||
this.emit(hexToBin('76a914'), nodeLocationData); | ||
this.emit(hexToBin('76a914'), { location: node.location, positionHint: PositionHint.START }); | ||
this.pushToStack('(value)'); | ||
// <pkh> | ||
this.visit(node.parameters[0]); | ||
this.emit(Op.OP_CAT, nodeLocationData); | ||
this.emit(Op.OP_CAT, { location: node.location, positionHint: PositionHint.END }); | ||
// OP_EQUAL OP_CHECKSIG | ||
this.emit(hexToBin('88ac'), nodeLocationData); | ||
this.emit(Op.OP_CAT, nodeLocationData); | ||
this.emit(hexToBin('88ac'), { location: node.location, positionHint: PositionHint.END }); | ||
this.emit(Op.OP_CAT, { location: node.location, positionHint: PositionHint.END }); | ||
this.popFromStack(2); | ||
@@ -334,10 +332,10 @@ } | ||
// OP_HASH160 OP_PUSH<20> | ||
this.emit(hexToBin('a914'), nodeLocationData); | ||
this.emit(hexToBin('a914'), { location: node.location, positionHint: PositionHint.START }); | ||
this.pushToStack('(value)'); | ||
// <script hash> | ||
this.visit(node.parameters[0]); | ||
this.emit(Op.OP_CAT, nodeLocationData); | ||
this.emit(Op.OP_CAT, { location: node.location, positionHint: PositionHint.END }); | ||
// OP_EQUAL | ||
this.emit(hexToBin('87'), nodeLocationData); | ||
this.emit(Op.OP_CAT, nodeLocationData); | ||
this.emit(hexToBin('87'), { location: node.location, positionHint: PositionHint.END }); | ||
this.emit(Op.OP_CAT, { location: node.location, positionHint: PositionHint.END }); | ||
this.popFromStack(2); | ||
@@ -347,10 +345,10 @@ } | ||
// OP_HASH256 OP_PUSH<32> | ||
this.emit(hexToBin('aa20'), nodeLocationData); | ||
this.emit(hexToBin('aa20'), { location: node.location, positionHint: PositionHint.START }); | ||
this.pushToStack('(value)'); | ||
// <script hash> | ||
this.visit(node.parameters[0]); | ||
this.emit(Op.OP_CAT, nodeLocationData); | ||
this.emit(Op.OP_CAT, { location: node.location, positionHint: PositionHint.END }); | ||
// OP_EQUAL | ||
this.emit(hexToBin('87'), nodeLocationData); | ||
this.emit(Op.OP_CAT, nodeLocationData); | ||
this.emit(hexToBin('87'), { location: node.location, positionHint: PositionHint.END }); | ||
this.emit(Op.OP_CAT, { location: node.location, positionHint: PositionHint.END }); | ||
this.popFromStack(2); | ||
@@ -361,3 +359,3 @@ } | ||
// OP_RETURN | ||
this.emit(hexToBin('6a'), nodeLocationData); | ||
this.emit(hexToBin('6a'), { location: node.location, positionHint: PositionHint.START }); | ||
this.pushToStack('(value)'); | ||
@@ -367,4 +365,5 @@ const { elements } = node.parameters[0]; | ||
elements.forEach((element) => { | ||
const elementLocationData = { location: element.location }; | ||
this.visit(element); | ||
// The element comes first, then all other opcodes have PositionHint.END because they come after the element | ||
const elementLocationData = { location: element.location, positionHint: PositionHint.END }; | ||
// Push the element's size (and calculate VarInt) | ||
@@ -431,3 +430,3 @@ this.emit(Op.OP_SIZE, elementLocationData); | ||
node.expression = this.visit(node.expression); | ||
this.emit(compileUnaryOp(node.operator), { location: node.location }); | ||
this.emit(compileUnaryOp(node.operator), { location: node.location, positionHint: PositionHint.END }); | ||
this.popFromStack(); | ||
@@ -438,3 +437,3 @@ this.pushToStack('(value)'); | ||
visitNullaryOp(node) { | ||
this.emit(compileNullaryOp(node.operator), { location: node.location }); | ||
this.emit(compileNullaryOp(node.operator), { location: node.location, positionHint: PositionHint.START }); | ||
this.pushToStack('(value)'); | ||
@@ -451,3 +450,3 @@ return node; | ||
const stackIndex = this.getStackIndex(node.name); | ||
this.emit(encodeInt(BigInt(stackIndex)), { location: node.location }); | ||
this.emit(encodeInt(BigInt(stackIndex)), { location: node.location, positionHint: PositionHint.START }); | ||
// If the final use is inside an if-statement, we still OP_PICK it | ||
@@ -462,7 +461,7 @@ // We do this so that there's no difference in stack depths between execution paths | ||
}; | ||
this.emit(Op.OP_ROLL, { location: node.location }); | ||
this.emit(Op.OP_ROLL, { location: node.location, positionHint: PositionHint.START }); | ||
this.removeFromStack(stackIndex); | ||
} | ||
else { | ||
this.emit(Op.OP_PICK, { location: node.location }); | ||
this.emit(Op.OP_PICK, { location: node.location, positionHint: PositionHint.START }); | ||
} | ||
@@ -476,3 +475,3 @@ this.pushToStack('(value)'); | ||
visitBoolLiteral(node) { | ||
this.emit(encodeBool(node.value), { location: node.location }); | ||
this.emit(encodeBool(node.value), { location: node.location, positionHint: PositionHint.START }); | ||
this.pushToStack('(value)'); | ||
@@ -482,3 +481,3 @@ return node; | ||
visitIntLiteral(node) { | ||
this.emit(encodeInt(node.value), { location: node.location }); | ||
this.emit(encodeInt(node.value), { location: node.location, positionHint: PositionHint.START }); | ||
this.pushToStack('(value)'); | ||
@@ -488,3 +487,3 @@ return node; | ||
visitStringLiteral(node) { | ||
this.emit(encodeString(node.value), { location: node.location }); | ||
this.emit(encodeString(node.value), { location: node.location, positionHint: PositionHint.START }); | ||
this.pushToStack('(value)'); | ||
@@ -494,3 +493,3 @@ return node; | ||
visitHexLiteral(node) { | ||
this.emit(node.value, { location: node.location }); | ||
this.emit(node.value, { location: node.location, positionHint: PositionHint.START }); | ||
this.pushToStack('(value)'); | ||
@@ -497,0 +496,0 @@ return node; |
// Generated from src/grammar/CashScript.g4 by ANTLR 4.13.1 | ||
// noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols | ||
import { ATNDeserializer, DFA, Lexer, LexerATNSimulator, PredictionContextCache, Token } from "antlr4"; | ||
export default class CashScriptLexer extends Lexer { | ||
class CashScriptLexer extends Lexer { | ||
constructor(input) { | ||
@@ -460,2 +460,3 @@ super(input); | ||
CashScriptLexer.DecisionsToDFA = CashScriptLexer._ATN.decisionToState.map((ds, index) => new DFA(ds, index)); | ||
export default CashScriptLexer; | ||
//# sourceMappingURL=CashScriptLexer.js.map |
export * from './Errors.js'; | ||
export * as utils from '@cashscript/utils'; | ||
export { compileFile, compileString } from './compiler.js'; | ||
export declare const version = "0.10.0-next.6"; | ||
export declare const version = "0.10.0"; |
export * from './Errors.js'; | ||
export * as utils from '@cashscript/utils'; | ||
export { compileFile, compileString } from './compiler.js'; | ||
export const version = '0.10.0-next.6'; | ||
export const version = '0.10.0'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "cashc", | ||
"version": "0.10.0-next.6", | ||
"version": "0.10.0", | ||
"description": "Compile Bitcoin Cash contracts to Bitcoin Cash Script or artifacts", | ||
@@ -14,7 +14,7 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/Bitcoin-com/cashscript/issues" | ||
"url": "https://github.com/CashScript/cashscript/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Bitcoin-com/cashscript.git" | ||
"url": "git+https://github.com/CashScript/cashscript.git" | ||
}, | ||
@@ -53,4 +53,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@bitauth/libauth": "^2.0.0", | ||
"@cashscript/utils": "^0.10.0-next.6", | ||
"@bitauth/libauth": "^3.0.0", | ||
"@cashscript/utils": "^0.10.0", | ||
"antlr4": "^4.13.1-patch-1", | ||
@@ -67,6 +67,6 @@ "commander": "^7.1.0", | ||
"jest": "^29.4.1", | ||
"typescript": "^4.1.5", | ||
"typescript": "^5.5.4", | ||
"url-join": "^5.0.0" | ||
}, | ||
"gitHead": "b26f1f20b89df6d857a5860eebd3bcc7668faa4e" | ||
"gitHead": "cd3031b60dc4ca2d2351608dfd838a50bcc7bbb9" | ||
} |
# CashScript | ||
[![Build Status](https://travis-ci.org/Bitcoin-com/cashscript.svg)](https://travis-ci.org/Bitcoin-com/cashscript) | ||
[![Coverage Status](https://img.shields.io/codecov/c/github/Bitcoin-com/cashscript.svg)](https://codecov.io/gh/Bitcoin-com/cashscript/) | ||
[![Build Status](https://travis-ci.org/CashScript/cashscript.svg)](https://travis-ci.org/CashScript/cashscript) | ||
[![Coverage Status](https://img.shields.io/codecov/c/github/CashScript/cashscript.svg)](https://codecov.io/gh/CashScript/cashscript/) | ||
[![NPM Version](https://img.shields.io/npm/v/cashscript.svg)](https://www.npmjs.com/package/cashscript) | ||
@@ -17,3 +17,3 @@ [![NPM Monthly Downloads](https://img.shields.io/npm/dm/cashscript.svg)](https://www.npmjs.com/package/cashscript) | ||
## The CashScript Compiler | ||
CashScript features a compiler as a standalone command line tool, called `cashc`. It can be installed through npm and used to compile `.cash` files into `.json` artifact files. These artifact files can be imported into the CashScript JavaScript SDK (or other SDKs in the future). The `cashc` NPM package can also be imported inside JavaScript files to compile `.cash` files without using the command line tool. | ||
CashScript features a compiler as a standalone command line tool, called `cashc`. It can be installed through npm and used to compile `.cash` files into `.json` artifact files. These artifact files can be imported into the CashScript TypeScript SDK (or other SDKs in the future). The `cashc` NPM package can also be imported inside JavaScript files to compile `.cash` files without using the command line tool. | ||
@@ -20,0 +20,0 @@ ### Installation |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
323884
7588
- Removed@bitauth/libauth@2.1.0(transitive)
Updated@bitauth/libauth@^3.0.0
Updated@cashscript/utils@^0.10.0