-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
350daf7
commit ce32257
Showing
22 changed files
with
1,573 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { Expression } from '../../../awst/nodes' | ||
import type { SourceLocation } from '../../../awst/source-location' | ||
import type { PType } from '../../ptypes' | ||
import { ARC4BoolClass, ARC4BooleanType, type ARC4EncodedType } from '../../ptypes/arc4-types' | ||
import type { InstanceBuilder, NodeBuilder } from '../index' | ||
import { ClassBuilder } from '../index' | ||
import { Arc4EncodedBaseExpressionBuilder } from './base' | ||
|
||
export class BoolClassBuilder extends ClassBuilder { | ||
readonly ptype = ARC4BoolClass | ||
|
||
newCall(args: ReadonlyArray<NodeBuilder>, typeArgs: ReadonlyArray<PType>, sourceLocation: SourceLocation): InstanceBuilder { | ||
throw new Error('Method not implemented.') | ||
} | ||
} | ||
|
||
export class BoolExpressionBuilder extends Arc4EncodedBaseExpressionBuilder<ARC4EncodedType> { | ||
constructor(expression: Expression) { | ||
super(expression, ARC4BooleanType) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { nodeFactory } from '../../../awst/node-factory' | ||
import type { Expression } from '../../../awst/nodes' | ||
import { StringConstant } from '../../../awst/nodes' | ||
import type { SourceLocation } from '../../../awst/source-location' | ||
import { wtypes } from '../../../awst/wtypes' | ||
import type { PType } from '../../ptypes' | ||
import { stringPType } from '../../ptypes' | ||
import type { ARC4EncodedType } from '../../ptypes/arc4-types' | ||
import { ARC4StrClass, ARC4StringType } from '../../ptypes/arc4-types' | ||
import type { InstanceBuilder, NodeBuilder } from '../index' | ||
import { ClassBuilder } from '../index' | ||
import { parseFunctionArgs } from '../util/arg-parsing' | ||
import { Arc4EncodedBaseExpressionBuilder } from './base' | ||
|
||
export class StrClassBuilder extends ClassBuilder { | ||
readonly ptype = ARC4StrClass | ||
|
||
newCall(args: ReadonlyArray<NodeBuilder>, typeArgs: ReadonlyArray<PType>, sourceLocation: SourceLocation): InstanceBuilder { | ||
const { | ||
args: [initialValue], | ||
} = parseFunctionArgs({ | ||
args, | ||
typeArgs, | ||
genericTypeArgs: 0, | ||
funcName: this.typeDescription, | ||
callLocation: sourceLocation, | ||
argSpec: (a) => [a.optional(stringPType)], | ||
}) | ||
|
||
if (!initialValue) { | ||
return new StrExpressionBuilder( | ||
nodeFactory.stringConstant({ | ||
value: '', | ||
sourceLocation: sourceLocation, | ||
wtype: wtypes.arc4StringAliasWType, | ||
}), | ||
) | ||
} | ||
const expr = initialValue.resolve() | ||
if (expr instanceof StringConstant) { | ||
return new StrExpressionBuilder( | ||
nodeFactory.stringConstant({ | ||
value: expr.value, | ||
sourceLocation: sourceLocation, | ||
wtype: wtypes.arc4StringAliasWType, | ||
}), | ||
) | ||
} else { | ||
return new StrExpressionBuilder( | ||
nodeFactory.aRC4Encode({ | ||
value: expr, | ||
wtype: wtypes.arc4StringAliasWType, | ||
sourceLocation, | ||
}), | ||
) | ||
} | ||
} | ||
} | ||
|
||
export class StrExpressionBuilder extends Arc4EncodedBaseExpressionBuilder<ARC4EncodedType> { | ||
constructor(expression: Expression) { | ||
super(expression, ARC4StringType) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.